Join our Newsletter — 33% off our NHI Course
Home› Guides› Same-Origin Policy and Browser Security Model Guide: Origins,…
Guide Web & API Security

Same-Origin Policy and Browser Security Model Guide: Origins, Sites and Isolation Explained

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 11 min read
On this page

The same-origin policy is the browser rule that stops a page from one origin reading data belonging to another, and almost every web security control is an exception to it or a reinforcement of it. An origin is the combination of scheme, host and port, and the policy lets pages send requests and embed content across origins while blocking them from reading the results. CORS, CSP, cookie attributes, postMessage, COOP and COEP, Fetch Metadata and Chrome's Site Isolation all make sense only once you know what the policy does and does not cover. This explainer sets out the model as browsers implement it today: origins versus sites, what is allowed and blocked, where the gaps are, and how to design applications that sit safely inside it. It is for application security engineers, web developers and testers, and it builds on the Client-Side Security Guide.

Key takeaways

  • Origin means scheme, host and port: https://app.example.com and https://api.example.com are different origins, and so are http and https versions of the same host.
  • The policy blocks reads, not requests: cross-origin form posts, redirects and embeds are allowed by default, which is why CSRF, clickjacking and cross-site leaks exist.
  • Cookies follow a different, weaker boundary: they are scoped by domain and path and sent by site, not origin, so subdomains can share and overwrite them.
  • Site is not origin: a site is scheme plus registrable domain (eTLD+1). SameSite cookies, Sec-Fetch-Site and Chrome's process isolation use sites, so a weak subdomain is inside the same boundary.
  • Isolation headers close the side channels: after Spectre, the policy alone is not enough; CORP, COOP, COEP and Fetch Metadata let servers stop their data entering an attacker's process.

What it is

The same-origin policy (SOP) is a set of restrictions enforced by browsers, defined across the WHATWG HTML and Fetch standards and first written up as an IETF document in RFC 6454. Under the HTML standard an origin is either a tuple origin (scheme, host, port, and an optional domain set by document.domain) or an opaque origin, an internal value that serialises as null and equals only itself. Two tuple origins are the same origin when scheme, host and port all match.

Compared with https://shop.example.com/cartSame origin?Same site?Why
https://shop.example.com/accountYesYesOnly the path differs
https://shop.example.com:8443/NoYesPort differs; site ignores port
https://login.example.com/NoYesHost differs; same registrable domain
http://shop.example.com/NoNoScheme differs; sites are schemeful
https://shop.example.co.uk/NoNoDifferent registrable domain
https://alice.github.io/ versus https://bob.github.io/NoNogithub.io is on the Public Suffix List, so each is its own site

A site is the scheme plus the registrable domain, found using the Public Suffix List (which is why .co.uk and .github.io count as suffixes). The HTML standard also keeps a "schemelessly same site" definition that ignores the scheme, and it advises preferring same-origin checks over same-site checks wherever possible.

How it works

What crosses the boundary

InteractionDefault across originsControl that changes it
Navigations, links, redirects, form submissions (writes)Allowed, with cookies subject to SameSiteCSRF tokens, SameSite cookies, Fetch Metadata checks
Embedding scripts, styles, images, media, fonts, framesAllowed; the embedder uses but cannot read the bytesCORP, X-Frame-Options or CSP frame-ancestors, COEP
Reading a response with fetch or XMLHttpRequestBlockedCORS response headers opt in
Scripting another window's DOMBlocked; only postMessage, focus, blur, close and location writes allowedpostMessage with origin checks; COOP severs opener links
localStorage, sessionStorage, IndexedDBSeparate per originNone (by design)
CookiesScoped by domain and path, sent by site rulesSecure, HttpOnly, SameSite, __Host- prefix, Path

Requests without reads

A page can send a request to any origin, but the browser will not let script read the response unless the target opts in. Under the Fetch standard, requests in no-cors mode are limited to safelisted methods (GET, HEAD, POST) and safelisted headers, and return an opaque response to the page. Anything else, such as a PUT, a JSON content type or an Authorization header, requires a CORS preflight: an OPTIONS request that the server must answer with matching Access-Control-Allow-* headers before the real request is sent. Credentials mode (omit, same-origin or include) decides whether cookies and client certificates go with the request, and a response to a credentialed request cannot use the * wildcard in Access-Control-Allow-Origin. See the CORS Misconfiguration Guide.

Inherited and opaque origins

Documents at about:blank or created from javascript: URLs inherit the origin of their creator, so a popup opened with window.open() shares the opener's origin. data: URLs get a new, empty security context, and sandboxed iframes without allow-same-origin and most file: pages get opaque origins. That is why an Origin: null request header can come from many unrelated contexts and must never be allowlisted.

document.domain and agent clusters

Setting document.domain to a parent domain once let two subdomains script each other. It is deprecated: it resets the port, throws in sandboxed iframes, and does not affect storage APIs. Pages can send Origin-Agent-Cluster: ?1 to be placed in an origin-keyed agent cluster, which makes document.domain relaxation a no-op.

Process isolation

Chrome's Site Isolation puts pages from different sites into separate sandboxed renderer processes and limits which cross-site data a process receives. It has been on for all sites on desktop since Chrome 67, with defences against fully compromised renderers from Chrome 77. On Android it covers a subset of sites on devices with at least 2 GB of RAM, and it is not supported in Android WebView. Because it isolates by site, different origins in the same site can still share a process. Cross-Origin Read Blocking keeps HTML, XML, JSON and PDF responses out of a cross-site process unless CORS allows them, on a best-effort basis.

Isolation headers

  • Cross-Origin-Resource-Policy (CORP): same-origin or same-site tells the browser not to deliver the resource to other origins or sites even as an embed.
  • Cross-Origin-Opener-Policy (COOP): values unsafe-none, same-origin-allow-popups, same-origin and noopener-allow-popups control whether a top-level page shares a browsing context group with cross-origin windows, cutting opener references used by tabnabbing and XS-Leaks.
  • Cross-Origin-Embedder-Policy (COEP): require-corp or credentialless makes a page load only resources that opt in, which together with COOP same-origin gives a cross-origin isolated context needed for high-resolution timers and SharedArrayBuffer.
  • Fetch Metadata: browsers send Sec-Fetch-Site (same-origin, same-site, cross-site or none), Sec-Fetch-Mode and Sec-Fetch-Dest; scripts cannot set Sec- headers, so a server can reject cross-site requests to sensitive endpoints.

See the Permissions Policy, COOP, COEP and CORP Guide and the Fetch Metadata and Resource Isolation Policy Guide.

Why it matters

The policy is what stops a malicious page in one tab from reading your webmail, banking session or admin console in another. Each well-known web attack class is a way around it:

Attack classWhich gap it usesPrimary defence
Cross-site scripting (XSS)Attacker script runs inside the victim origin, so SOP does not applyOutput encoding, CSP, Trusted Types
Cross-site request forgery (CSRF)Cross-origin writes are allowed and carry cookiesSameSite cookies, CSRF tokens, Fetch Metadata
ClickjackingCross-origin framing is allowedCSP frame-ancestors, X-Frame-Options
CORS misconfigurationServer opts in to reads from untrusted originsFixed allowlist, no reflected Origin, no null
Cross-site script inclusion (XSSI) and JSONPScripts are embeddable and executed in the embedderNo JSONP, no secrets in script responses, CORP
XS-LeaksEmbeds and window references leak sizes, timings and countsCOOP, CORP, Fetch Metadata, SameSite
Spectre-class side channelsCross-origin bytes in the same process memorySite Isolation, CORP, COEP
Subdomain takeover and cookie tossingSame-site subdomain can set parent-domain cookies__Host- cookies, separate registrable domains, DNS hygiene

Design decisions

  • Separate untrusted content by registrable domain, not subdomain: user uploads, customer pages and third-party widgets should live on a different eTLD+1 (the reason many platforms use a separate domain for user content), because subdomains are same-site and can affect cookies.
  • Separate applications by hostname: two applications on one origin under different paths share storage and DOM access; OWASP ASVS 5.0 V3.5.4 asks for separate hostnames.
  • Prefer same-origin APIs to CORS: a backend-for-frontend on the same origin avoids preflights and credentialed CORS entirely. See the OAuth for Browser-Based Applications and the BFF Pattern Guide.
  • Small teams: start with secure cookie defaults, a fixed CORS allowlist, frame-ancestors and a Fetch Metadata check on state-changing routes; add COOP and CORP next. Large estates should set these at the edge or framework level so every service inherits them.

Rolling out isolation headers

  1. Inventory cross-origin dependencies: CDNs, analytics, payment frames, SSO popups and embeds.
  2. Deploy COOP and COEP with their Report-Only variants and collect violation reports.
  3. Add CORP same-site to authenticated resources and API responses; add Fetch Metadata checks in log-only mode.
  4. Fix or explicitly allow each reported breakage, then enforce route by route, starting with account and admin pages.
  5. Keep the report-only policy in place after enforcing so new breakage is visible; roll back by removing the enforcing header while leaving reporting on.

What to measure: share of authenticated responses carrying CORP; endpoints that reflect arbitrary Origin values or allow null (target zero); share of top-level pages with COOP; cross-site requests rejected by Fetch Metadata policy per day; cookies without SameSite or the __Host- prefix on session cookies.

Common misconceptions

  • "SOP stops cross-site requests." It stops reading the response. The request, and its side effects, still happen.
  • "CORS is a security control that protects my API." CORS relaxes the policy. A permissive CORS policy weakens protection; a missing one is the secure default. Server-side authorisation is still required because non-browser clients ignore CORS entirely.
  • "Subdomains are isolated from each other." They are separate origins for DOM and storage, but the same site for cookies, SameSite and Chrome's process model. A compromised or taken-over subdomain can set cookies for the parent domain.
  • "SameSite cookies make CSRF impossible." They block cross-site sending, but same-site attackers (a vulnerable sibling subdomain) are not cross-site, and Lax still sends cookies on top-level GET navigations.
  • "localStorage is safe from other sites, so it is safe for tokens." It is safe from other origins, but any XSS in your own origin can read it. See the Browser Storage Security Guide.
  • "Checking the Origin header is enough for WebSockets." It is necessary (ASVS 5.0 V4.4.2), but WebSockets are not subject to CORS, so the check must be on the server and paired with authentication.
  • Cookies: attributes and prefixes that bring cookie scope closer to origin scope. See the Cookie Security Guide.
  • Content Security Policy: restricts what an origin will load and execute, the main mitigation when XSS breaks the boundary from inside. See the Content Security Policy Guide.
  • XS-Leaks: the family of attacks that infer cross-origin state through allowed interactions. See the XS-Leaks Guide.
  • CSRF: forged cross-origin writes. See the CSRF Prevention Guide.
  • Browser extensions: extensions with host permissions operate outside the page's origin model and can read any site they are granted. See the Browser Extension Security Guide.
FrameworkReferenceWhat it requires
OWASP ASVS 5.0V3.4.2CORS Access-Control-Allow-Origin is fixed or validated against an allowlist
OWASP ASVS 5.0V3.5.4Separate applications on different hostnames to use same-origin restrictions
OWASP ASVS 5.0V3.5.5postMessage messages from untrusted origins or with invalid syntax are discarded
OWASP ASVS 5.0V3.5.6, V3.5.8No JSONP; authenticated resources loaded or embedded only when intended
OWASP ASVS 5.0V4.4.2WebSocket handshake checks Origin against an allowlist

Practitioner checklist

  • Host user-generated and third-party content on a separate registrable domain.
  • Give each application its own hostname; never share an origin between apps of different trust.
  • Use a fixed CORS allowlist; never reflect Origin, never allow null, never combine credentials with broad origins.
  • Set session cookies with the __Host- prefix, Secure, HttpOnly and SameSite.
  • Check event.origin and validate message structure in every postMessage handler.
  • Remove JSONP and keep secrets out of script responses.
  • Deploy COOP, CORP and Fetch Metadata checks via report-only first, then enforce.
  • Test for subdomain takeover and cookie tossing as part of web application testing.

Standards and references

Related NHI Mgmt Group resources: Client-Side Security Guide · CORS Misconfiguration Guide · Permissions Policy, COOP, COEP and CORP Guide · Cookie Security Guide · XS-Leaks Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.