SOP

Informational

Same-Origin Policy

Definition

The Same-Origin Policy (SOP) is a fundamental security mechanism implemented in web browsers that restricts how scripts from one origin can interact with resources from another origin. Two URLs have the same origin if they share protocol, host and port. SOP prevents a malicious site from reading data from another site where the user is authenticated.

Impact

The security foundation of the entire modern webPrevents data theft between websitesLimits which cross-origin requests scripts can makeThe basis on which CORS, CSP and other mechanisms are built

Examples

What SOP allows and blocks

SOP compares protocol + host + port. If any of the three differs, the browser blocks scripts from reading the response. However, SOP does not block sending requests (which is why CSRF is possible), only reading the responses.

// Origin: https://example.com:443

// SAME ORIGIN (allowed):
https://example.com/page2         // ✅ same protocol, host, port
https://example.com/api/data      // ✅

// DIFFERENT ORIGIN (blocked for reading):
http://example.com/api            // ❌ different protocol
https://sub.example.com/api       // ❌ different host
https://example.com:8080/api      // ❌ different port
https://other.com/api             // ❌ different host

External references

Practice SOP 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