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
2,482

hunters training

62

labs from real hacks

1,630

completions

$14,790

paid out for these bugs

11 flags captured this week·Real hacks from HackerOne · YesWeHack · Bugcrowd·No commitment·Free Academy
Free · no account

The checklist I run on every new target

47 checks ordered by cost: first what can get you in trouble, then the cheap stuff, and finally the expensive stuff — which is where the big bounties are. I'll send it to your inbox right now.

Unsubscribe in one click, from any email.

BBLabs · bug bounty training

Stop reading about bugs and start hunting them

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

No card · free Academy · cancel anytime