← Back to list
Security & Privacy
#동일 출처 정책#CORS#CSP#SameSite 쿠키#사이트 격리
Last updated · 2026-11-19

The Browser Security Model (Same-Origin Policy, CORS, CSP)

1. Overview

A. Definition

The Browser Security Model refers to the browser's built-in defense architecture that isolates and governs, on a per-origin basis, "which origin's code may access which resource" in an environment where code from countless mutually untrusted origins executes simultaneously inside a single user agent. Its root is the Same-Origin Policy (SOP), upon which are layered CORS, which safely relaxes cross-origin access, CSP (Content Security Policy), which declaratively restricts executable content, and auxiliary controls at the cookie, window, and process levels.

A browser is essentially "a runtime that downloads arbitrary, unfamiliar code and executes it immediately." A user hops across dozens of sites a day, and within a single page third-party scripts for ads, analytics, payments, and maps run together. These are potential neighbors that may share the same tab, the same memory space, and the same cookie store. Without any isolation, an ad script could read the cookies of an online-banking session open in the same page, intercept passwords entered into forms, and scrape the contents of mail in another tab. The browser security model is the foundational infrastructure built to solve exactly this problem of "mutually distrusting tenants under one roof."

The security goals this model pursues map to the classic CIA triad. Confidentiality means preventing one origin's data (cookies, DOM, response bodies) from being spied on by another origin; integrity means preventing another origin from forging state-changing requests through our session; and availability means preventing malicious scripts from exhausting resources or tricking the user into unintended actions. Each control maps to a different security property—SOP handles mainly confidentiality, SameSite/CSRF controls handle integrity, and framing controls/site isolation handle integrity and availability. Understanding this mapping lets you systematically design "which control is needed for which threat."

B. Background and Necessity

The early web was a means of exchanging static documents, but with the advent of JavaScript, Ajax, and the SPA (Single Page Application), the browser evolved into an application platform on par with an OS. As capabilities grew, so did the attack surface, and web-native threats such as XSS (cross-site scripting), CSRF (cross-site request forgery), clickjacking, and session hijacking surged. Because server-side controls ([[waf]], input validation) alone cannot guard "the boundaries between code executing on the client," the browser itself had to become the front line of Defense in Depth, drawing its own trust boundaries.

The necessity is also evident in statistics. In the OWASP Top 10 ([[owasp-top-10]]), injection and broken access control have held top ranks for years, and XSS remains among the most commonly reported web-vulnerability classes. No matter how robust the server is, a single XSS hole lets attacker script do anything with the victim's privileges. Here, CSP blocking inline script execution can fundamentally reduce the damage, and when SameSite cookies and CORS block automatic authentication of cross-origin requests, the very preconditions for CSRF collapse. In short, the browser security model is indispensable as a mitigation layer that "makes exploitation hard even when a vulnerability exists."

The browser security model is especially important because the entity executing the attack is the victim's own browser. Server-side attacks at least leave room for firewalls and IPS to filter malicious traffic arriving from outside, but attacks that unfold inside the browser disguise themselves as legitimate user sessions and requests from legitimate origins, making them hard to identify at the network perimeter. Ultimately, the responsibility for judging "who has the right to execute what code" has to descend into the browser's interior, which is the background for the browser becoming a Policy Enforcement Point beyond a mere renderer.

C. Core Characteristics

The browser security model shares several distinct design traits. First is the Deny by Default principle: SOP blocks cross-origin access at the outset and opens a passage only when there is explicit consent such as CORS or postMessage. Second is Declarative Policy: CSP, Permissions-Policy, and SameSite declare policy through headers and attributes rather than code, and the browser enforces it, so application logic and security policy are separated and easy to audit and change. Third is multi-layered defense in depth, designed so that even if one control is breached, another layer limits the damage. Fourth is Progressive Hardening, allowing staged adoption without breaking compatibility through report-only mode, fallbacks, and origin trials. These four traits are a shared strategy for realistically achieving the conflicting goal of "safely executing unfamiliar code."

2. Overall Structure and Core Components

Browser security is not a single feature but a layered defense structure in which multiple controls operate in overlapping layers. At the bottom sits SOP, which defines origins and blocks access; above it sit CORS, which selectively permits cross-origin access, CSP, which restricts content execution, SameSite, which governs cookie transmission, framing controls that prevent frame embedding, and site isolation at the process/memory level. The conceptual diagram below shows this overall structure.

flowchart TB
  U["User browser (tab/renderer process)"] --> SOP["Same-Origin Policy (SOP) — block by default"]
  SOP --> R1["Cross-document DOM access control"]
  SOP --> R2["XHR/fetch response read control"]
  SOP --> R3["Cookie/storage isolation"]
  SOP --> CORS["CORS — cross-origin relaxation with server consent"]
  SOP --> CSP["CSP — restrict executable content"]
  SOP --> CK["SameSite cookies — restrict cross-site transmission"]
  SOP --> FR["Framing control (CSP frame-ancestors / XFO)"]
  U --> ISO["Site Isolation + COOP/COEP/CORP"]
  ISO --> SPEC["Spectre-class side-channel defense, cross-origin memory isolation"]
  style SOP fill:#fde8e8,stroke:#d33,stroke-width:2px
  style ISO fill:#e8f0fe,stroke:#2f6fed,stroke-width:2px

A. Same-Origin Policy (SOP) — the Baseline of All Controls

An origin is defined by the combination of three elements: scheme, host, and port. https://bank.example:443 and http://bank.example:80 are different origins because their scheme and port differ. The core rule of SOP is that "a document/script of one origin cannot read another origin's resources." For example, a script on evil.com may send a fetch('https://bank.example/account') request, but by SOP it cannot read the response body. It also cannot access the DOM inside an iframe opened to another origin.

A subtle point that must be distinguished here is the asymmetry of "transmission is allowed but reading is blocked." SOP does not block the request itself. Thus traditional embedding such as <img src>, <script src>, and <form> is allowed even cross-origin, and it is precisely this gap—"the request goes through but the result cannot be read"—that CSRF exploits. In other words, SOP preserves confidentiality but does not itself prevent request forgery (integrity), and SameSite cookies and CSRF tokens fill this gap. Failing to grasp this asymmetry leads to the common misconception that "SOP exists, so CSRF is safe."

SOP also applies to per-origin storage isolation. Cookies, localStorage, and IndexedDB are separated by origin, so data planted by a.example cannot be read by b.example. However, cookies for historical reasons do not distinguish ports and operate on a domain/path basis, so they do not fully coincide with the origin concept—a source of confusion. The coexistence of two concepts, "origin (scheme+host+port)" and "site (based on the registrable domain, eTLD+1)," is likewise a major cause of practical confusion. SameSite cookies operate at the "site" level while SOP/CORS operate at the "origin" level, so app.example and api.example become different origins but the same site, and the two controls apply differently. If a designer fails to understand this difference in boundary definition precisely, they fall into confusion like "it's the same site, so why does CORS block it?"

One more thing to note is that SOP also has exceptions and relaxation mechanisms. If documents set document.domain to the same parent domain (now being deprecated), subdomain DOM access used to open, and windows of different origins can safely exchange data via explicit message passing through the postMessage API. In other words, SOP follows a design philosophy of "default block + explicit passage" rather than an "absolute wall," and CORS, postMessage, and CSP all share the trait of being mechanisms that open this passage under the deliberate consent of the server or developer.

B. CORS — Cross-Origin Relaxation with Server Consent

The modern web commonly separates the frontend (app.example) from the API server (api.example), so a means to safely permit cross-origin data access is needed. CORS (Cross-Origin Resource Sharing) is an HTTP-header-based protocol that relaxes SOP's strict blocking on the premise of explicit server consent. The key point is that "the party deciding whether to allow is the server that owns the data." When the browser receives a cross-origin response, it checks the Access-Control-Allow-Origin header and hands the response to the script only when the requesting origin is listed.

CORS divides requests into two classes. GET and POST (with simple content types) are sent directly as simple requests, whereas requests using PUT, DELETE, or custom headers (such as Authorization) send a preliminary check (preflight) via the OPTIONS method before the actual request. This distinction has important security implications. Because a simple request has no preflight, the request itself reaches the server as is (the browser blocks only reading the response), and precisely for this reason the idea that "CORS prevents CSRF" is only partially correct. A state-changing simple POST can be delivered without preflight, so CSRF defense must still be handled by SameSite cookies or CSRF tokens. In this preflight, the server responds with allowed methods (Access-Control-Allow-Methods), allowed headers (Access-Control-Allow-Headers), and cache time (Access-Control-Max-Age), and the browser sends the main request only when the conditions match. The sequence below shows a preflight flow including credentials.

sequenceDiagram
  participant B as "Browser (app.example)"
  participant S as "API server (api.example)"
  B->>S: OPTIONS /orders (Origin, Access-Control-Request-Method: PUT)
  S-->>B: 200 (Allow-Origin: https://app.example, Allow-Methods: PUT, Allow-Credentials: true)
  Note over B: Proceed with main request after confirming policy match
  B->>S: PUT /orders (with Cookie, withCredentials)
  S-->>B: 200 (Access-Control-Allow-Origin: https://app.example)
  Note over B: Wildcard (*) in Allow-Origin forbidden in credentialed mode

The most frequent security incident in CORS is misconfiguration. A representative pattern is trying to use Access-Control-Allow-Origin: * for development convenience while also permitting credentials, ending up reflecting the request's Origin value back verbatim and attaching Allow-Credentials: true. In this case any malicious site can call the API together with the victim's cookies and even read the response, effectively neutralizing SOP's protection. This is exactly why the specification forbids using a wildcard and credentials simultaneously.

C. CSP — Declarative Control of Executable Content

CSP (Content Security Policy) is a mechanism by which the server declares, via the Content-Security-Policy response header, "which origins' scripts, styles, images, and frames may be loaded/executed on this page," and the browser enforces it. CSP's primary goal is XSS mitigation. No matter by what path an attacker injects an inline <script>, if CSP forbids inline execution, that script will not run. In other words, CSP is a second line of defense that "keeps the payload from running even when a vulnerability exists."

CSP consists of a set of directives subdivided by resource type. default-src sets the umbrella default, while script-src, style-src, img-src, connect-src, font-src, and frame-src individually control each resource type. In addition, frame-ancestors controls the parent origins that may wrap this page, form-action the form submission targets, base-uri manipulation of the <base> tag, and upgrade-insecure-requests the automatic promotion of HTTP resources to HTTPS. In particular, connect-src restricts the targets of fetch, XHR, and WebSocket connections, so it has the second-defense effect of blocking even the path by which a script injected via XSS exfiltrates stolen data to an external server. Thus CSP handles not only "execution blocking" but also "exfiltration blocking."

Traditional CSP used an allowlist like script-src 'self' https://cdn.example, but operational experience revealed that allowlists are easily bypassed and hard to maintain. A representative bypass path is abusing a JSONP endpoint or open redirect within an allowed CDN. Thus CSP Level 3 presents the combination of a per-request random value nonce and 'strict-dynamic' as the recommended baseline. A form like script-src 'nonce-{random}' 'strict-dynamic' 'object-src' 'none' 'base-uri' 'none' is representative; it propagates trust only to child scripts loaded by a trusted script and blocks all other inline. The nonce must be newly issued per response, and the values in the header and in the markup must match. 'strict-dynamic' is designed to be ignored on older browsers without Level 3 support, naturally falling back to the allowlist, enabling gradual adoption. In practice, the standard approach is to first collect only violation reports with Content-Security-Policy-Report-Only to measure impact, then switch to enforcement mode. Also, for static inline scripts, using hash (sha256)-based allowance instead of a nonce avoids changing the value per response, which is compatible with caching—another design option to consider.

D. Auxiliary Controls — SameSite Cookies, Framing, Site Isolation

This category also includes Permissions-Policy (formerly Feature-Policy), which controls, per origin, permission to use powerful browser features. Sensitive features such as camera, microphone, location, fullscreen, and the Payment API can be individually allowed or blocked for the top-level document as well as for third-party iframes embedded within it. For example, declaring that an ad iframe is given no camera/geolocation permission at all means that even if that ad is malicious, it cannot touch sensitive features. This is a web version of privilege separation that "delegates only minimal capability to embedded third parties," a control that reduces third-party risk from a supply-chain perspective.

The cookie SameSite attribute controls automatic cookie transmission in cross-site contexts, structurally mitigating CSRF. Strict does not send cookies at all on cross-site requests, while Lax allows them only on safe methods (GET) of top-level navigation. Since 2020 (version 80), Chrome changed to treating unspecified cookies as Lax by default, blocking by default the CSRF precondition of "automatic authentication of cross-site requests." This is a symbolic shift of web security defaults toward the "safe side."

Framing controls prevent clickjacking. Clickjacking is an attack in which the attacker overlays a legitimate site with a transparent iframe so that the user, thinking they are pressing the visible button, actually clicks a sensitive button (fund transfer, granting permission, etc.) of the hidden frame. The modern replacement for the old X-Frame-Options (DENY/SAMEORIGIN) is the CSP frame-ancestors directive, which specifies which origins may wrap this page in an iframe. With frame-ancestors 'none', no site can frame it, fundamentally blocking clickjacking.

Finally, Site Isolation assigns a separate renderer process per origin, preventing CPU side-channel attacks such as Spectre/Meltdown ([[speculative-execution-branch-prediction]]), disclosed in 2018, from reading cross-origin data within one process. Because Spectre abuses the CPU microarchitecture characteristic of speculative execution rather than a software bug, it cannot be stopped by language/browser-level memory safety alone, and process isolation that "does not place sensitive data in the same address space in the first place" becomes the only fundamental countermeasure. If you then declare the Cross-Origin Isolation state with the COOP, COEP, and CORP headers, the browser guarantees that it has placed the document in a definitively isolated process and re-opens powerful features such as SharedArrayBuffer and high-precision timers. COOP requires the reference relationship between windows/popups, COEP requires explicit consent (CORP/crossorigin) for cross-origin embeds, and the isolation state holds only when the three headers mesh together.

3. Comparison of Control Mechanisms

The table below organizes each control's defense target, operating layer, and governing party. But the table is only an aid; the crux is "why such a division of labor arose." SOP lays down the strong default of blocking by default, CORS relaxes that blocking with the consent of the data owner (server), and CSP restricts execution through the declaration of the content provider (page). In other words, the controlling party is split across browser, API server, and page, so responsibility is distributed, and defense in depth holds, with another layer backing up when one is breached.

Control Primary defense target Operating layer Deciding party Limitation
SOP Cross-origin read/DOM access Browser default Browser Request transmission itself not blocked (CSRF gap)
CORS Safe cross-origin API sharing HTTP headers API server SOP neutralized on misconfiguration
CSP XSS, data exfiltration, clickjacking Response headers Page server Allowlist bypass, operational complexity
SameSite cookies CSRF Cookie attribute Application Compatibility with some legacy flows
Site Isolation / COOP·COEP Spectre side channel Process/document isolation Browser + server Reduced compatibility with OAuth popups/embeds

As the table reveals, no control is self-complete on its own. For example, CORS alone cannot stop CSRF (simple requests have no preflight), SameSite alone cannot stop XSS, and CSP alone cannot seal every path of cross-origin data exfiltration. This complementarity makes browser security not "a single setting" but "an ensemble of policies."

Let us concretize this ensemble with one attack scenario. Suppose an attacker sends the victim a malicious link and plants XSS in a bank site where the victim is logged in. (1) First, if CSP blocks inline scripts on a nonce basis, the injected payload itself cannot run. (2) Even if it runs, the connect-src restriction blocks external transmission of stolen data. (3) Even if the attacker tries to forge a transfer request cross-site, the SameSite=Strict cookie does not carry the session, so the request is treated as unauthenticated. (4) Even if they try to cover the transfer button with a transparent frame, frame-ancestors 'none' refuses the framing. If even one of the four layers works, the attack chain is broken—this is the practical value of defense in depth. The key is to design from the perspective of "residual risk reduction" as the independent product of each control's effect.

4. Application Cases

Financial API separation architecture. An internet-only bank runs its web app (app.bank) and API (api.bank) separately; the API fixes the allowed origin to the single value app.bank and uses Allow-Credentials: true while forbidding wildcards. Session cookies are set as SameSite=Strict; Secure; HttpOnly, blocking both cross-site transmission and script access. HttpOnly prevents cookies from being read in JavaScript, making session-token theft difficult even via XSS, and Secure ensures transmission only over HTTPS, preventing man-in-the-middle exposure. As a result, even when an external phishing site tries to call the balance-lookup API with the user's session, it is blocked on both CORS and SameSite and cannot read the response; the combination of the three attributes (HttpOnly, Secure, SameSite) exemplifies blocking multiple attack vectors simultaneously even for a single cookie.

Gradual CSP adoption at a large portal. A service with hundreds of millions of lines of legacy inline scripts breaks its screens if CSP is enforced at once. So it first collected violation reports for several weeks in Report-Only mode, refactored inline handlers, and then switched to a nonce-based 'strict-dynamic' policy. In cases disclosed by large services such as Google and GitHub, the number of XSS reports is reported to have decreased meaningfully after the strict-CSP transition. An important lesson gained in this process is that the bottleneck of a CSP transition is not "writing the header" but removing anti-patterns such as inline code, eval, and dynamic script generation. Applying a security control paradoxically becomes an occasion that drives code quality and architecture modernization. Therefore CSP adoption should be planned not as a one-off security task but together with a frontend refactoring roadmap.

Cross-origin isolation in a collaboration tool. A web collaboration tool that needs SharedArrayBuffer for high-performance image/video editing entered the cross-origin isolation state by setting COOP: same-origin and COEP: require-corp. However, in this process external payment and social-login popups broke, so a trade-off was needed—relaxing the payment window to COEP: credentialless or separating it into a distinct origin.

Standardizing security headers in public services. Many public agencies and large enterprises establish an organization-wide common security-header baseline and inject it uniformly at the reverse-proxy/gateway layer for all services. Bundling Content-Security-Policy, Strict-Transport-Security (HSTS), X-Content-Type-Options: nosniff, Referrer-Policy, and frame-ancestors together reduces the risk of individual application teams omitting settings each time and raises the security level uniformly at the organizational level. However, if the common policy is too strict, some services break, so a governance system that manages per-service exceptions and automated checks (header scanners) are needed alongside. This shows the trend of browser security moving out of individual developers' hands and being incorporated as a standard asset of platform engineering.

Real incident types caused by CORS misconfiguration. A pattern that recurs in many bug-bounty reports is where the API server reflects the request's Origin header value into Access-Control-Allow-Origin without validation and emits Allow-Credentials: true together. Here the attacker lures the victim into visiting a malicious page while logged in, then uses JavaScript to call the internal API together with the victim's cookies and steals personal information/tokens response and all. Another common error is implementing the allowed-origin check as string matching like endsWith('example.com'), letting through look-alike domains such as evil-example.com or example.com.evil.com. This well illustrates why CORS requires "exact origin match" and why the allowlist must be whitelisted by exact match.

5. Advanced — Latest Trends and Standards Changes

Browser security defaults are steadily moving toward the "Secure by Default" side. The defaulting of cookie SameSite=Lax was the starting point, followed by automatic blocking of mixed content, warnings on http:// form submission, and discussion of the phased removal of third-party cookies. In particular, the removal of third-party cookies is a privacy measure that blocks cross-site tracking, but it also carries large security implications, shaking the preconditions of cookie-based attacks such as CSRF and session fixation. The ad/analytics ecosystem is responding by migrating to alternatives such as the Storage Access API and the Privacy Sandbox.

CSP likewise shifted its center of gravity from allowlists to nonce/hash-based strict CSP. In the past it was thought enough to "list trustworthy CDNs," but once it became clear that a CDN harboring JSONP endpoints or open redirects becomes a bypass channel, placing trust on a per-request nonce rather than on an origin became the recommended approach. Adding Trusted Types on top forces type validation on dangerous sinks of DOM-based XSS (such as innerHTML), preventing "an injectable string from entering the execution context in the first place." Moreover, COOP/COEP/CORP that emerged after Spectre and the recently proposed Document-Isolation-Policy add a new defense axis of "memory-level cross-origin isolation," showing that browser security is expanding beyond the network and DOM into the CPU microarchitecture layer.

From the professional-engineer exam perspective, this topic is prone to appear in forms like "explain, precisely distinguishing, the relationship among SOP, CORS, and CSP" or "map the browser controls that counter a particular web attack (XSS/CSRF/clickjacking)." When composing an answer, first clearly present the definition of origin (scheme+host+port) and the default-block principle of SOP, then arrange CORS (relaxation), CSP (reinforcement), and SameSite (complement) along the axis of "how to safely relax/reinforce the default block," which establishes logical consistency. Be sure to mention each control's limitations and complementarity, and connecting the latest trends (strict CSP, SameSite defaulting, cross-origin isolation) in the conclusion makes it an advanced-level answer. Common point-losing factors are confusing SOP with CORS or asserting that CORS prevents CSRF, so these points must be pinned down precisely.

Another trend worth watching is the server-side Resource Isolation Policy that leverages Fetch Metadata (Sec-Fetch-*) headers. When the browser sends a request, it appends, via unforgeable headers, where (Sec-Fetch-Site), how (Sec-Fetch-Mode), and for what purpose (Sec-Fetch-Dest) the request originated. By looking at this metadata, the server can preemptively reject "a non-navigation request originating cross-site," adding one more layer against CSRF, information leakage, and XS-Leaks-class attacks. This shows the latest trend of defense responsibility being cooperatively redistributed between browser and server, a prime example of "browser–server cooperative security" that combines the trustworthy context information the browser provides with server policy. In sum, modern browser security is evolving simultaneously along three axes beyond the improvement of a single header: making defaults safe, refining the basis of trust, and vertically extending the defense layers (DOM→process→CPU).

6. Considerations and Implications

The strategies and implications to consider from a professional-engineer perspective when applying the browser security model in practice are as follows.

  • Design for defense in depth, but do not rely on a single control. SOP, CORS, CSP, SameSite, server-side CSRF tokens, and input validation do not replace but complement one another. In particular, overconfidence in a single control—such as "CSP exists, so XSS is fine" or "SOP exists, so CSRF is safe"—is a typical failure pattern. You must first build a threat model ([[threat-modeling]]) and map a responsible control to each attack path.

  • Balance between safe defaults and explicit configuration. Wildcard CORS, loose CSP including unsafe-inline/unsafe-eval, and SameSite-unset cookies—"looseness for convenience"—are routine causes of incidents. Following the Least Privilege principle, allow only the necessary origins, methods, and headers, and it is safer to start the policy as narrow as possible and widen it.

  • Operational visibility and gradual adoption. Controls that can break screens/features, like CSP and COEP, must be measured for impact via Report-Only and origin trials before enforcement. Collecting violation reports into logs/SIEM ([[siem]]) also lets them serve as a runtime sensor that detects actual injection attempts, doubling as defense and detection.

  • Trade-offs with compatibility and user experience. Strong isolation (COOP/COEP) can break OAuth popups, payment windows, and third-party embeds, and SameSite=Strict can harm the experience of staying logged in via external links. Choose a point suited to the service's characteristics between security strength and usability/ecosystem compatibility, and design mitigations such as credentialless and origin separation alongside.

  • Capacity to track standards changes. Browser security standards—third-party cookie removal, Trusted Types, Document-Isolation-Policy—change rapidly. Architects should avoid designs excessively coupled to specific cookie/header behaviors and place an abstraction layer so they can respond elastically to standards changes.

  • Recognizing the limits of client-side controls. The browser security model stands entirely on the premise that "a normal browser complies with the policy." If an attacker crafts requests with automation tools, a modified client, or direct HTTP calls, SOP/CORS/CSP do not apply. In other words, these are controls that prevent attacks mediated by the victim's browser, not defenses against attacks that directly target the server. Therefore server-side controls such as authentication, authorization, input validation, and rate limiting must always run in parallel with browser security, and client-side policies must not be mistaken for a trust boundary.

In sum, the browser security model is a cumulative answer to the web's fundamental challenge of "safely letting unfamiliar code coexist." Its essence is not the perfection of a single control but the overlap of multiple controls, safe defaults, and continuous standards evolution; designers must internalize this not as a checklist but as a layered design principle grounded in a threat model.

References


In one line: The browser security model is a defense-in-depth system in which, atop the strong default blocking of the Same-Origin Policy, server-consent-based CORS, the declarative execution control CSP, SameSite cookies, and site isolation operate in overlapping layers, mitigating XSS, CSRF, and side-channel attacks through an ensemble of distributed-responsibility policies rather than a single control.