CORS

Informational

Cross-Origin Resource Sharing

Definition

Cross-Origin Resource Sharing (CORS) is an HTTP-header-based mechanism that lets a server indicate from which origins (domain, protocol, port) a browser may load resources. CORS relaxes the Same-Origin Policy in a controlled way, letting APIs be consumed by front-ends on different domains safely.

Impact

Lets APIs be consumed by frontends on other domainsA misconfiguration can expose private data to malicious sitesPreflight (OPTIONS) requests validate permissions before the real request is sentFundamental for modern architectures with separate frontend and backend

Examples

CORS headers and the preflight flow

When the browser detects a cross-origin request meeting certain criteria (custom headers, non-simple methods), it first sends an OPTIONS (preflight) request. The server responds indicating which origins, methods and headers are allowed.

# The browser's automatic preflight request
OPTIONS /api/data HTTP/1.1
Host: api.example.com
Origin: https://app.example.com
Access-Control-Request-Method: POST
Access-Control-Request-Headers: Content-Type, Authorization

# Server response (secure configuration)
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Allow-Credentials: true
Access-Control-Max-Age: 86400

External references

Practice CORS with real labs

Apply what you've learned in safe environments based on real bug bounty reports.

See practice labs
hunters training
712

hunters training

labs from real reports
55

labs from real reports

completions
1,206

completions

in bounties practiced
$213,970

in bounties practiced

46 flags captured this week·Real reports from HackerOne · Bugcrowd · Intigriti·No commitment·Free Academy
BBLabs · bug bounty training

Stop reading about bugs and start hunting them

Create your free account and practice on labs based on real reports that paid out thousands of euros. The Academy is free forever.

No card · free Academy · cancel anytime