Fact-checked by Grok 2 weeks ago

Same-origin policy

The same-origin policy (SOP) is a critical mechanism implemented by web browsers that restricts how a document or loaded from one origin can interact with resources from a different origin, thereby isolating potentially malicious content to prevent unauthorized access to sensitive data. This policy primarily aims to protect users by blocking cross-origin reads of data, such as preventing a on a malicious site from extracting information from a user's or banking session through the (DOM). An is defined by the combination of a protocol (e.g., HTTP or ), host ( or ), and port number (if specified); two resources share the same only if all three components match exactly. For instance, https://[example.com](/page/Example.com):443 and https://[example.com](/page/Example.com) are considered the same , but http://[example.com](/page/Example.com) differs due to the protocol mismatch. This strict definition ensures that content from unrelated sites cannot interfere with each other without explicit permission. Under the SOP, browsers block most cross-origin interactions, including reading properties or methods on DOM objects from another origin, though certain operations like writing data (e.g., via form submissions or hyperlinks) and embedding resources (e.g., images or scripts) are permitted to support basic web functionality. Relaxations to the policy exist to enable legitimate cross-origin communication, such as Cross-Origin Resource Sharing (CORS), which allows servers to specify safe origins via HTTP headers, and the deprecated document.domain property, which once permitted relaxing the policy for subdomains but is now discouraged due to security vulnerabilities. Special cases include about:blank and javascript: URLs inheriting the parent origin in some contexts, while data: URLs receive a unique, empty origin.

Fundamentals

Definition and Core Principles

The same-origin policy (SOP) is a fundamental mechanism implemented in web browsers to isolate content loaded from different origins, preventing malicious scripts from one site from accessing or manipulating resources from another site without explicit permission. This policy ensures that documents and scripts are confined to their originating context, thereby protecting user data from unauthorized access or interference by potentially hostile . At its core, the SOP defines an origin as a tuple consisting of the scheme (such as HTTP or HTTPS), the host (domain name or IP address), and the port number, requiring exact matches across all three components for two resources to be considered same-origin. It primarily restricts reading from or writing to the Document Object Model (DOM) of another origin, meaning a script cannot inspect or modify elements, properties, or methods in a cross-origin document. However, the policy does not universally block all cross-origin interactions; for instance, loading passive resources like images, stylesheets, or scripts via HTML elements (e.g., <img> or <script> tags) is generally permitted, though these resources cannot directly access the embedding page's DOM. A practical example illustrates this: a script executing on https://example.com (port 443 by default) cannot read the DOM content of an loaded from https://api.example.com (typically port 443 but considered distinct due to the subdomain host difference), enforcing even within the same . This principle originated in the early evolution of web browsers to counter risks posed by malicious scripts that could exploit the initially permissive model of web interactions, where untrusted code from one site might steal sensitive information from another.

Security Objectives

The same-origin policy (SOP) primarily aims to safeguard sensitive user data, such as and , by prohibiting cross-site access to these resources, thereby preventing unauthorized retrieval or manipulation by scripts from different origins. This restriction is crucial for thwarting impersonation attacks, where a malicious site could otherwise pose as a legitimate one to steal credentials or session information. By enforcing origin-based isolation, SOP ensures that data associated with one site remains inaccessible to others, mitigating risks of in multi-origin browsing sessions. A key benefit of SOP lies in its isolation of browsing contexts, which effectively prevents session hijacking by limiting the scope of script interactions and protecting authentication tokens from cross-site interference. Additionally, it facilitates the secure embedding of third-party content, such as images or scripts, without granting full DOM access to the embedded resources, allowing controlled integration while maintaining security boundaries. Without SOP, a hypothetical scenario could unfold where a malicious advertisement script on a benign page accesses and relays sensitive banking data from a shared DOM context, leading to widespread data breaches. In the broader web security model, SOP serves as a foundational mechanism that complements protocols like , which secures data transmission, and (CSP), which further refines resource loading controls, together forming layered defenses against common web threats. This integration underscores SOP's role in establishing trust zones based on origin matching principles, enhancing overall resilience without relying on client-side permissions alone.

Origin Determination

Components of an Origin

In web security, an origin under the same-origin policy is fundamentally defined as either an opaque origin or a structured tuple consisting of three components: the scheme (also known as the protocol, such as "http" or "https"), the host (the domain name or IP address, including subdomains), and the port number (a 16-bit unsigned integer or null for the default port associated with the scheme). The scheme identifies the protocol used to access the resource, the host specifies the network location, and the port distinguishes between multiple services on the same host, with defaults of 80 for "http" and 443 for "https" when the port is null. These components form the basis for determining whether two resources share the same origin, ensuring isolation based on network addressing elements. Special cases arise for certain schemes or contexts where origins deviate from the standard tuple structure. For instance, the "localhost" host is treated as a unique tuple origin with the scheme ("http" or "https"), host string "localhost", and null port, making resources like http://localhost and http://localhost:3000 distinct due to the explicit port. In contrast, "file://" URLs, which access local files directly, are assigned an opaque origin that serializes to "null" and cannot be compared meaningfully with other origins, rendering them incomparable for same-origin checks. Similarly, "data:" URIs, which embed data inline without network retrieval, always receive a null opaque origin to prevent cross-origin interactions. Examples illustrate how these components differentiate origins. The URL https://www.example.com:8080 has a different origin from http://www.example.com because the schemes ("https" vs. "http") mismatch, even though the host and default port (null for both) align otherwise. Subdomains further highlight host sensitivity: https://sub.example.com and https://example.com represent distinct origins due to the differing host strings, preventing direct access between them without relaxation mechanisms. Opaque origins serve as a security fallback for scenarios beyond standard network schemes, such as when privacy features, like those blocking third-party tracking, force an opaque origin to obscure the true and prevent origin-based inferences. This opaqueness ensures that such resources cannot participate in same-origin comparisons, effectively treating each as unique and isolated.

Rules for Comparing Origins

Browsers determine whether two origins are the same using a precise comparison algorithm outlined in RFC 6454, which treats an origin as a consisting of a scheme, host, and port. Two origins are the same their schemes match exactly (case-sensitive but serialized in lowercase), their hosts match after , and their ports match numerically or both use the scheme's default port (such as 80 for HTTP or 443 for ). Host comparison involves normalizing the host component to lowercase ASCII and, for internationalized domain names (IDNs), applying the IDNA2008 ToASCII with flags for STD3 ASCII rules and DNS length verification to produce Punycode-encoded forms (prefixed with "xn--"). IP address literals are compared directly as strings without further encoding; IPv4 addresses use dotted-decimal notation, while addresses are enclosed in brackets and have hexadecimal components lowercased for consistency. This ensures that equivalent representations, like "" and "", or IDN variants, are treated as identical after normalization, but distinct hosts like "" and "127.0.0.1" remain different origins despite resolving to the same address. Port comparison requires exact numeric equality, but defaults are handled implicitly: if a port is unspecified in the URL, it assumes the scheme's standard value, and two such origins match only if both omit the port or both specify the same non-default value. Opaque origins (such as those from data: schemes) are and never match tuple-based origins unless both are the same opaque identifier. In cases involving redirects, the origin for same-origin policy enforcement is derived solely from the final URL after all redirects, regardless of intermediate steps; a redirect chain crossing origins does not alter the policy application to the loaded resource. Browser implementations introduce minor nuances in edge cases. For instance, and assign the about:blank the same as its embedding document (the parent or opener), enabling seamless access within the same browsing context.

Historical Development

Early Origins in Browsers

The same-origin policy (SOP) was developed by engineers at in 1995 as a foundational security mechanism for the newly introduced in 2.0. This policy emerged in response to the growing capabilities of web browsers, particularly the ability to embed frames and scripts, which introduced vulnerabilities in the mid-1990s web environment. Prior browsers like NCSA Mosaic, released in 1993, lacked any form of origin-based isolation, allowing unrestricted access between documents regardless of source, which highlighted the need for such protections as the web evolved. The primary motivation for inventing the SOP was to mitigate "framing attacks," where a malicious webpage embedded in could or manipulate sensitive from the parent window or other frames, such as user credentials in third-party or resources. For instance, without restrictions, a script from an untrusted site could read properties of a framed from a different , enabling or unauthorized interactions. This concern arose shortly after JavaScript's debut in December 1995 with Navigator 2.0 beta, as scripting amplified risks in cross-frame scenarios. The policy enforced isolation by comparing and host components of origins, aiming to prevent such exploits while preserving legitimate same-site functionality. Early implementations of the SOP in were partial, applying restrictions primarily to access to the (DOM) but not fully across all browser features, such as certain image or form submissions. These limitations reflected the rapid development pace of the era, influenced by the absence of security boundaries in predecessors like , and set the stage for iterative refinements in subsequent browser releases.

Key Milestones and Standardization

In the early 2000s, browser vendors began refining the same-origin policy (SOP) to address evolving web threats, with (released in 2001) introducing security zones that allowed administrators to configure trust levels for different site categories, potentially relaxing certain restrictions like script execution but maintaining core SOP boundaries for cross-origin access. , launched in 2004, enhanced SOP enforcement through its rendering engine and XPCOM component , enabling stricter isolation of scripts and DOM access across origins to mitigate risks from emerging JavaScript-heavy applications. The Web Hypertext Application Technology Working Group () significantly influenced SOP standardization between 2007 and 2010 by incorporating it into the HTML Living Standard, which clarified the origin tuple (scheme, host, port) and provided a unified definition for browser interoperability. In 2009, researcher Adam Barth published an IETF draft outlining the principles of SOP, emphasizing its role in isolating untrusted content while allowing controlled interactions, which informed subsequent specifications. During the 2010s, key updates expanded SOP's flexibility without undermining its security foundations. (CORS) was introduced in a W3C Working Draft on July 27, 2010, enabling servers to specify safe cross-origin HTTP requests via headers like Access-Control-Allow-Origin, thus standardizing a mechanism to bypass SOP for and Fetch API calls. HTML5's postMessage API, specified in the Web Messaging Candidate Recommendation of May 1, 2012, provided a for cross-origin messaging between windows and iframes, requiring explicit origin validation to prevent unauthorized data leakage. Post-2020 developments have integrated with broader privacy initiatives, such as Google's (announced in 2020), which enforces same-origin storage for like Protected Audience and Topics to limit cross-site tracking while respecting SOP boundaries. In July 2024, Google abandoned plans to deprecate third-party cookies in (previously delayed to early 2025 following regulatory reviews), but continues advancing that complement SOP by reducing cross-origin identifier sharing and strengthening isolation against tracking without altering core policy enforcement.

Browser Implementation

Enforcement in DOM and JavaScript

The same-origin policy enforces restrictions on client-side access to the (DOM) and APIs to prevent unauthorized interactions between resources from different origins. When a script attempts to access DOM elements or properties across origins, browsers throw a SecurityError exception, such as "Blocked a frame with origin 'https://example.com' from accessing a cross-origin frame" or "Permission denied to access property 'x'". These restrictions ensure that a document from one origin cannot read or modify the DOM of another origin, thereby protecting sensitive data like user inputs or session information. Access to properties like window.frames or window.frames[index] is limited to same-origin frames; attempting to retrieve or manipulate a cross-origin frame's content, such as through frame.contentDocument or frame.contentWindow, results in the aforementioned SecurityError. Similarly, methods like document.getElementById() cannot be used to query elements within a cross-origin document, as the entire document object is inaccessible, preventing scripts from extracting or altering content like form data or dynamically generated elements. These DOM barriers are evaluated based on origin comparison rules, where schemes, hosts, and ports must match exactly for access to be granted. JavaScript APIs are also constrained by the same-origin policy to limit cross-origin data leakage. The XMLHttpRequest object and the Fetch API default to same-origin requests, blocking synchronous or asynchronous access to resources from different origins and throwing errors if credentials are involved without proper authorization; for instance, fetch('https://other-origin.com/api') will fail with a network error visible in the console unless relaxed via mechanisms like CORS. Access to sensitive properties such as location.href on a cross-origin Window object is prohibited, returning an opaque or null value instead to avoid exposing navigation details or enabling phishing attacks. In the context of iframes, the same-origin policy applies to embedded documents, treating cross-origin content as isolated by default. The sandbox attribute on the <iframe> element imposes additional restrictions by placing the framed content in a unique, opaque origin, which fails all same-origin checks even if the actual origins match; without the allow-same-origin token, scripts cannot access the iframe's DOM or APIs, and features like forms or plugins are disabled to mitigate risks like . Combining allow-scripts with allow-same-origin is discouraged, as it could bypass these protections and allow malicious scripts to interact freely. Violations of these enforcement rules are surfaced through debugging tools for developer awareness and troubleshooting. Browser consoles log specific errors, such as SecurityError for DOM access attempts or "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource" for API calls, providing details on the blocked origin and reason. Developer tools, including the Network panel, display blocked requests with status indicators like "(blocked:sop)" or "(failed) net::ERR_BLOCKED_BY_CLIENT", allowing inspection of headers and payloads without exposing sensitive data.

Network-Level Controls

The same-origin policy (SOP) is enforced at the network level primarily through restrictions on how web applications can initiate and interact with HTTP requests and resource loads, preventing unauthorized cross-origin data access. Browsers block cross-origin requests made via the (XHR) API or the by default, allowing only same-origin requests to proceed without additional server-side permissions. This enforcement ensures that JavaScript from one origin cannot read sensitive data from another origin's server unless explicitly permitted. For non-simple requests—those involving non-standard methods (e.g., PUT, DELETE), custom headers, or specific content types—browsers automatically send a preflight OPTIONS request to the target server to verify if the actual request is allowed, further strengthening network isolation. Certain resource types are exempt from strict SOP blocking during loading to support common web functionality, but access to their contents remains restricted. For instance, HTML elements like <script>, <img>, and <link rel="stylesheet"> can load resources from cross-origin servers, enabling the inclusion of external , images, and stylesheets. However, these loaded resources are treated as opaque; JavaScript cannot inspect or manipulate their contents if cross-origin. Specifically, for images loaded via <img>, the browser permits rendering and retrieval of like dimensions, but pixel-level data access is prohibited. This read-only behavior extends to canvas elements: drawing a cross-origin into a <canvas> taints the canvas, blocking operations such as getImageData() or toDataURL() to prevent extraction of restricted data. Network-level SOP also influences caching and client-side storage mechanisms to maintain origin isolation. Service workers, which intercept network requests for offline capabilities, respect SOP by limiting fetches to same-origin resources or cross-origin ones only if server-permitted; cross-origin cache entries cannot be read or modified by scripts from different origins. Similarly, IndexedDB databases are partitioned strictly by origin, meaning each origin maintains isolated storage namespaces, preventing cross-origin access to stored data such as user preferences or application state. This partitioning ensures that even within the same browser, data from one site remains inaccessible to another. Implementations vary across browsers, particularly in mobile environments where additional platform constraints apply. For example, Safari enforces stricter origin isolation due to its integration with the app ecosystem and privacy features like Intelligent Tracking Prevention, which includes enhanced storage partitioning to limit cross-site data persistence and network interactions. These variations can result in more aggressive blocking of certain cross-origin behaviors compared to desktop counterparts, prioritizing user in constrained device contexts.

Relaxing the Policy

Cross-Origin Resource Sharing (CORS)

is a standardized mechanism that allows servers to relax the same-origin policy by explicitly permitting cross-origin HTTP requests from specified through HTTP response headers. The core of this mechanism involves the server including the Access-Control-Allow-Origin header in its response, which specifies the allowed (s) or uses a wildcard (*) to permit any . For requests that include credentials such as cookies, HTTP authentication, or client-side SSL certificates, the server must set Access-Control-Allow-Credentials: true and cannot use the wildcard for the , ensuring that only trusted can access sensitive data. This header-based opt-in approach enables secure data sharing for APIs while maintaining browser-enforced restrictions. For certain "non-simple" requests—such as those using methods like PUT, DELETE, or , or including custom headers—the first issues a preflight request using the HTTP OPTIONS method to check permissions before sending the actual request. This preflight includes headers like Access-Control-Request-Method to indicate the intended method and Access-Control-Request-Headers to list any non-standard headers. The responds with Access-Control-Allow-Methods to approve methods and Access-Control-Allow-Headers to permit specific headers, along with a maximum age for caching the preflight result to reduce overhead. In contrast, simple requests (limited to GET, , or HEAD methods with standard headers like Accept or Content-Type for certain values) bypass preflight and proceed directly if the is allowed. CORS responses are categorized as transparent (readable by JavaScript if allowed) or opaque (in no-cors mode, where content is inaccessible to prevent leaks, though the request still occurs for side effects like loading images). Even with CORS enabled, it does not grant full DOM access to cross-origin resources; instead, it facilitates data retrieval via APIs like fetch() or XMLHttpRequest, without allowing script execution or structural manipulation of the loaded document. Security limitations are critical: misconfigurations, such as using Access-Control-Allow-Origin: * alongside credentials, can expose user data to malicious sites by enabling unauthorized access to authenticated endpoints, potentially leading to information disclosure or session hijacking. CORS was standardized as a W3C Recommendation on , 2014, building on earlier browser implementations to provide a uniform cross-origin access model. By 2025, it achieves universal adoption in modern browsers, with full support in (since version 13), (since 3.5), (since 6), (since 12), and (since 12.1), covering over 95% of global usage and integrating seamlessly with network-level controls for request validation.

document.domain Property

The document.domain property of the interface allows to get or set the domain portion of the current document's , as determined for the same- policy. By setting this property to a parent domain, scripts can relax the policy's restrictions, enabling limited cross- interactions between documents from the same site but different subdomains, such as allowing access to each other's DOM elements. This adjustment affects the host component of the , treating subdomains like sub.example.com and api.example.com as equivalent after setting both to example.com. Under the security model, the property can only be shortened to a valid parent domain suffix (e.g., from sub.example.com to example.com), and it cannot be lengthened or set to an unrelated domain to prevent arbitrary origin manipulation. For the relaxation to enable bidirectional access, both interacting documents must explicitly set document.domain to the identical parent value; otherwise, the same-origin policy remains enforced. This mutual requirement and suffix limitation were designed to mitigate risks while allowing controlled subdomain communication. Historically, document.domain was used in applications for iframe-based communication, such as third-party widgets from subdomains or between a main site and its sub-resources without full cross-origin mechanisms. A typical example involves a script in an from sub.example.com:
javascript
if (document.domain !== '[example.com](/page/Example.com)') {
  document.domain = '[example.com](/page/Example.com)';
}
After setting, the iframe can then access the parent window's DOM, like window.parent.document.getElementById('element'), provided the parent document at [example.com](/page/Example.com) has similarly set its domain. The setter for document.domain is deprecated due to its weakening of same-origin policy protections, which can expose sites to attacks like where malicious scripts exploit domain resolution tricks to gain unauthorized access. It also complicates modern features relying on strict origin isolation, such as SharedWorker origin keys. The setter for document.domain is deprecated across browsers. In Chromium-based browsers like and , it was made immutable by default starting in version 115 (July 2023), though sites can opt out via the Origin-Agent-Cluster header to restore functionality for compatibility. Firefox has deprecated the setter but continues to support it. Developers are encouraged to migrate to secure alternatives like the postMessage API for cross-document messaging.

Cross-Document Messaging

Cross-Document Messaging enables secure communication between browsing contexts from different origins, such as a parent window and an embedded iframe or a popup window, without violating the same-origin policy. The primary mechanism is the window.postMessage() method, which allows a window to send data to another window, along with an optional targetOrigin parameter specifying the expected origin of the recipient. The syntax is targetWindow.postMessage(message, targetOrigin, [transfer]), where message can be any serializable object, such as strings, arrays, or JSON-serialized data, and transfer (introduced later) lists transferable objects like ArrayBuffer instances to avoid cloning overhead. To receive messages, the target window adds an event listener for the message event on window, accessing the data via event.data, the sender's origin via event.origin, and the sender window via event.source. Developers must validate event.origin in the listener to ensure the message comes from a trusted source, as the same-origin policy prevents direct access to the sender's DOM. Security is paramount in cross-document messaging, as improper use can lead to data leakage or spoofing attacks. Specifying an exact targetOrigin, such as 'https://example.com', restricts delivery to windows from that origin, preventing interception by malicious frames; using '*' allows delivery to any origin, which is risky if sensitive data is involved, as attackers could embed the content and eavesdrop. On the receiving end, always check event.origin against expected values before processing event.data, and ignore messages from untrusted origins to mitigate origin confusion attacks where a malicious site mimics a legitimate sender. This design relaxes the same-origin policy only for message passing, maintaining isolation for DOM and script execution. Common use cases include embedding third-party widgets, such as payment forms or feeds in iframes, where the parent page sends configuration data and receives callbacks without exposing internal . Another frequent application is popup-based flows, where an opener launches a cross-origin for , and the posts success status back upon completion, enabling seamless user experiences. The supports structured data like objects, facilitating complex interactions such as passing user preferences or event notifications between frames. The postMessage API was introduced in the HTML5 specification drafts around 2008 as part of the feature to address the need for controlled cross-origin communication. It gained initial browser support in Firefox 3, , and Opera 9.5 by mid-2008, with broader adoption following the W3C Candidate Recommendation in 2012. An enhancement for transferable objects was added in 2011, allowing transfer of large binary data like ArrayBuffer or ImageBitmap via the third parameter, improving performance for high-volume scenarios such as media processing between windows. Despite its flexibility, cross-document messaging has limitations: it permits only asynchronous and does not grant direct DOM access or script execution across origins, enforcing the same-origin policy for structural interactions. Messages are cloned by default (except transferables), which can incur memory costs for large payloads, and there is no built-in mechanism for request-response patterns, requiring custom acknowledgments. Additionally, while it supports communication with iframes (subject to their enforcement under the same-origin policy), it cannot bypass sandboxing or other frame restrictions.

JSONP and WebSockets

JSONP (JSON with Padding) is a technique that circumvents the same-origin policy by leveraging the browser's exception for loading external scripts via the <script> tag, which permits cross-origin resource inclusion without enforcement of SOP restrictions on script execution. In this method, a client requests data from a remote server by appending a callback parameter to the URL, such as ?callback=func, prompting the server to wrap the JSON response in a function call named after the provided callback; the browser then executes this as JavaScript upon loading the script. For example, to fetch data, a page might include <script src="https://api.example.com/data?callback=parseData"></script>, where parseData is a predefined function that processes the returned object like parseData({ "key": "value" });. This approach evades blocks on cross-origin (XHR) but is limited to GET requests and cannot include custom headers or support methods like , making it unsuitable for complex interactions. Moreover, JSONP is vulnerable to (XSS) attacks, as the server response is directly executed as script; a malicious or compromised could inject harmful code instead of valid data, potentially compromising the client. Since the introduction of (CORS), JSONP has been discouraged due to its security risks and limitations, with modern browsers and APIs favoring CORS for safer cross-origin data access. WebSockets provide a protocol-level exception to traditional SOP enforcement by enabling full-duplex, persistent communication over a single TCP connection, distinct from HTTP-based restrictions. Connections use ws:// or secure wss:// URIs, where the browser initiates an HTTP upgrade handshake that includes an Origin header specifying the requesting page's origin for server-side validation. Although browsers permit cross-origin WebSocket connections without strict SOP blocking during the handshake—relying instead on the origin-based security model—the server must verify the Origin header to prevent unauthorized access from differing origins, often by echoing it back or rejecting mismatches. Once established, the connection allows bidirectional data exchange, bypassing many SOP limitations on resource interaction but requiring server-enforced policies to maintain security. To enhance authentication, WebSockets support subprotocols negotiated via the Sec-WebSocket-Protocol header during the handshake, which can incorporate custom mechanisms like tokens or credentials beyond basic origin checks. For instance, a client might instantiate a connection with const socket = new WebSocket('ws://example.com/socket', ['auth-protocol']);, where the server validates the origin and subprotocol before completing the upgrade. This setup ensures controlled cross-origin real-time communication while mitigating risks through rigorous server-side origin and protocol validation.

Exceptions and Edge Cases

Non-Enforced Resources

The same-origin policy (SOP) does not prevent the loading of certain resources from cross-origin sources, allowing web pages to embed external content for functionality while imposing restrictions on reading or accessing that content programmatically. Specifically, elements such as <img>, <video>, <audio>, <object>, <embed>, <script>, <link>, and <style> can fetch and incorporate cross-origin resources without SOP enforcement blocking the initial load. This exemption facilitates practical , such as displaying images from content delivery networks (CDNs) or loading stylesheets from third-party services, without compromising the overall model by permitting unrestricted data extraction. However, these loads come with strict read limitations to mitigate risks like disclosure. For cross-origin loaded via <img>, the allows rendering and access to like dimensions through the .src , but drawing the onto a <canvas> element taints the canvas, preventing methods such as getImageData() from extracting data and thereby avoiding "pixel stealing" attacks where sensitive could be inferred from contents. Similarly, cross-origin scripts loaded with <script> execute in the page's but prohibit access to their raw or detailed error , ensuring the loaded code cannot be inspected or manipulated programmatically. For CSS resources, including those via <link> or inline <style>, and background specified in stylesheets, the content loads and applies without blockage, but programmatic access to the raw CSS text or embedded data is denied unless the resource is same-origin. Fonts declared with @font-face also load cross-origin in most , enabling typography from external sources, though advanced uses may require additional permissions. HTML forms provide another example of non-enforced cross-origin interaction, where <form> submissions to a different are permitted, allowing to be sent without SOP intervention. The response from such a submission, however, cannot be read by in the originating page unless it is same- or explicitly allowed via mechanisms like CORS, preventing unauthorized access to potentially sensitive reply . Fetch requests initiated without CORS configuration similarly allow the network transfer but return an opaque response that blocks reading the body or headers, maintaining the policy's protective boundaries. These controlled exceptions balance usability—such as enabling advertisements, embedded media, and distributed resource hosting—with by isolating loaded content from script-level inspection.

Credentialed Cross-Origin Access

In the context of the same-origin policy (), credentialed cross-origin access refers to mechanisms that allow the inclusion of authentication credentials, such as cookies, HTTP authentication headers, or client-side certificates, in requests to origins different from the requesting site's origin. This is primarily facilitated through APIs like (XHR) or the Fetch API, where the withCredentials property for XHR or the credentials: 'include' option for Fetch instructs the browser to attach credentials to cross-origin requests. However, SOP restricts such requests by default, requiring explicit server-side opt-in via mechanisms like (CORS) to prevent unauthorized access. For credentialed requests to succeed cross-origin, the must respond with the Access-Control-Allow-Credentials: true header, alongside an Access-Control-Allow-Origin header specifying the exact (wildcards like * are incompatible with credentials). Without this opt-in, browsers block the response from being read by , even if the request is sent, to mitigate risks of credential leakage. This enforcement ensures that only trusted servers can receive and process authenticated cross-origin traffic. Reusable authentication credentials, such as access tokens stored in client-side storage or , pose risks in cross-origin contexts if not properly isolated by SOP. These credentials can be inadvertently included in unauthorized requests, potentially enabling attacks where a malicious site exploits the user's authenticated session on another domain. For instance, an token granted for one service might be reused in a cross-origin request to manipulate resources if isolation fails. Under SOP, storage mechanisms like localStorage and cookies are inherently same-origin, meaning they cannot be accessed or shared across different origins. As of mid-2025, Chrome implements storage partitioning to further restrict cross-origin access to such storage in embedded contexts (e.g., iframes), isolating data per top-level site to prevent tracking and unauthorized credential sharing. This ensures that third-party embeds receive partitioned storage, blocking direct access to shared credentials unless explicitly allowed via attributes like CHIPS (Cookies Having Independent Partitioned State). To mitigate these risks, SameSite cookie attributes provide granular control over credential transmission in cross-origin scenarios. The SameSite=Lax mode allows cookies in top-level navigations and safe HTTP methods (e.g., GET) but blocks them in cross-site requests, while SameSite=Strict prevents sending cookies entirely on cross-site requests, offering stronger . These attributes, combined with partitioned storage options, help enforce SOP by limiting credential exposure without fully disabling cross-origin functionality. A practical example involves a cross-origin Fetch request: fetch('https://api.example.com/data', { credentials: 'include' }) from https://client.com. If the server does not include Access-Control-Allow-Origin: https://client.com and Access-Control-Allow-Credentials: true in its response, the will send the request with but block access to the response body, logging a CORS error in the console. This demonstrates SOP's role in protecting credentialed data unless explicitly permitted.

Security Threats

Information Disclosure Attacks

The same-origin policy (SOP) aims to prevent cross-origin access to sensitive data, but it does not block all forms of information leakage, particularly through indirect side-channel attacks that infer data without direct DOM access. These attacks, often categorized as cross-site leaks (XS-Leaks), exploit subtle behavioral differences in browser APIs, network responses, or resource handling to disclose user-specific information such as login status, browsing history, or account details. While SOP enforces strict , vulnerabilities arise from observable side effects like timing variations, messages, or rendering artifacts that attackers can measure or detect cross-origin. Cross-site scripting (XSS) represents a foundational for SOP-related information disclosure, as the policy does not prevent the injection of malicious scripts into a vulnerable same-origin context. When an attacker injects via reflected, stored, or DOM-based XSS on a target site, the script executes with the site's full privileges, bypassing SOP restrictions to read sensitive data like session cookies, local storage, or DOM elements containing personal . For instance, an injected script can access document.cookie to exfiltrate authentication tokens, enabling without needing cross-origin permissions. This leakage occurs because SOP treats the injected code as same-origin, granting it unrestricted access to the victim's data within that origin. Timing attacks, including cache probing, further undermine SOP by measuring resource load times to infer cross-origin states. In a typical cache-probing XS-Leak, an attacker embeds a cross-origin (e.g., an or ) on their site and times its fetch; if previously from a target site visit, the load is faster due to hits, revealing whether the user accessed that . This exploits SOP's allowance for non-credentialed cross-origin fetches while using timing side-channels—often amplified by high-resolution APIs like performance.now()—to detect login status or without direct access. Early research demonstrated such attacks could achieve high accuracy (over 95%) in distinguishing from uncached , though modern have implemented mitigations like cache partitioning that reduce their effectiveness. CSS history sniffing, though largely deprecated in modern browsers, historically exploited SOP weaknesses via stylesheet rules to leak browsing history. Attackers applied CSS selectors like :visited to cross-origin links on their page; browsers styled visited links differently (e.g., color changes) based on the user's history, allowing to detect style differences through computed properties or measurements, inferring prior visits without violating direct checks. This side-channel persisted despite because CSS rendering occurs before full isolation enforcement, enabling leaks of up to thousands of URLs per session in vulnerable implementations. Browsers like and mitigated it by randomizing or restricting :visited styles, but remnants inform ongoing XS-Leak research. Pixel tracking evasions leverage SOP's canvas tainting mechanism, where attempting to read pixel data from a cross-origin image drawn to a <canvas> element throws a security error if tainted, indirectly leaking resource availability. An attacker loads a target site's user-specific image (e.g., a profile avatar) into an <img> tag, draws it to the canvas, and calls getImageData(); a "tainted canvas" exception confirms successful cross-origin load (indicating the user is authenticated, as unauthenticated requests might return 404 errors), while no error suggests failure. This bypasses SOP's read restrictions by using error presence as a binary oracle for sensitive states, such as account existence, without CORS approval. Such techniques, part of broader error-based XS-Leaks, can detect or personalization with near-perfect reliability in non-CORS scenarios. Modern vectors, including speculative execution side-channels like , interact with SOP by exploiting CPU branch prediction to transiently access isolated memory, potentially leaking cross-origin data. In browser contexts, Spectre variants (e.g., Variant 1) mislead to load same-origin secrets into shared caches, which attackers probe via timing to reconstruct data like passwords from other origins, violating SOP's . This hardware-level attack amplifies SOP weaknesses, as transient executions leave measurable cache artifacts before isolation restores; browsers mitigate via site (process-per-site rendering), reducing shared state exposure. Studies show unmitigated browsers could leak up to 4 KB/s of cross-origin data, underscoring the need for layered defenses beyond SOP.

Cross-Site Request Forgery (CSRF)

Cross-Site Request Forgery (CSRF) is a web security vulnerability that exploits the trust a web application has in an authenticated user's browser, allowing an attacker to induce actions on the target site without the user's consent. In this attack, a malicious website or resource tricks the user's browser into sending unauthorized requests to a different origin where the user is authenticated, often leveraging the browser's automatic inclusion of session cookies or other credentials. The core mechanism relies on the attacker embedding cross-origin requests—such as via HTML forms, images, or scripts—within their own site, which the browser executes in the context of the victim's session. The Same-Origin Policy (SOP) provides partial protection against CSRF by restricting the attacker's ability to read the response from the forged request, thereby preventing the malicious site from confirming the success of the action. However, SOP does not block the initiation or transmission of the request itself; browsers permit cross-origin writes, such as loading an <img> tag with a source pointing to https://bank.com/transfer?amount=1000&to=attacker or submitting a hidden form to the target origin. This limitation arises because SOP primarily enforces read isolation, allowing state-changing operations like GET or POST requests to proceed if they include credentials from the user's active session. To mitigate CSRF, web applications commonly implement synchronizer tokens, where a unique, unpredictable value is included in legitimate requests and validated server-side to ensure the request originates from the expected site. Another key defense is the SameSite attribute on , which instructs browsers to withhold from cross-site requests, effectively blocking credentialed cross-origin in many scenarios. SOP complements these measures by isolating origins, making it harder for attackers to inspect or manipulate responses, though it alone cannot fully prevent the forgery of requests. A classic example involves a banking application vulnerable to CSRF: if a user authenticated to bank.com visits malicious.com, the latter could embed an auto-submitting form targeting bank.com/transfer, initiating an unauthorized funds transfer using the user's session cookies. Techniques like , intended for cross-origin data fetching, can exacerbate CSRF risks if misused for state-changing operations, as they bypass some restrictions on script execution. As of 2025, CSRF vulnerabilities have diminished in modern web applications due to widespread adoption of frameworks with built-in protections and browser defaults like SameSite=Lax, but they persist in legacy systems and custom lacking robust validation. Reports indicate that while not as prevalent as in earlier decades, CSRF remains a notable in environments with credentialed cross-origin , underscoring the ongoing need for layered defenses alongside . The Same-origin policy (SOP) partitions web storage mechanisms such as , localStorage, and sessionStorage to ensure they are accessible only to resources from the same origin, preventing cross-origin scripts from reading or modifying data stored under a different origin. This partitioning applies strictly in scenarios like iframes, where third-party embedded content cannot access or alter the parent document's storage, thereby blocking unauthorized data extraction or tampering by malicious embeds. Despite this isolation, the cookie's Domain attribute can be exploited to set cookies broadly across a domain and its , allowing related-domain attackers—such as those controlling a vulnerable —to shadow or hijack intended for the primary through techniques like cookie overwriting. Subdomain configurations without strict scoping further enable cross-site cookie setting, where an attacker on a compromised can inject that propagate to sibling subdomains, potentially facilitating or unauthorized access. Sensitive cookie data can leak cross-origin via the Referer header in HTTP requests, which browsers include by default and may expose domain-specific identifiers or tokens to untrusted parties. Similarly, mishandling of the postMessage API, intended for controlled cross-origin communication, can result in storage leaks if origin validation is inadequate, allowing attackers to exfiltrate cookie-derived data through unverified message passing. To mitigate third-party cookie tracking while preserving functionality, the Cookies Having Independent Partitioned State (CHIPS) proposal, implemented in 2024, partitions such cookies by top-level site, restricting their access to the embedding context and preventing cross-site linkage. Attackers can force cookie modifications in cross-origin iframes by leveraging permissive Domain attributes or subdomain control, embedding malicious frames that set or overwrite cookies for the parent domain if third-party restrictions are bypassed. Cross-site scripting (XSS) vulnerabilities enable direct mutation of origin-specific storage, as injected scripts execute in the victim's context and can arbitrarily read, alter, or delete localStorage and sessionStorage entries, often leading to data theft or persistent backdoors. Browser updates have strengthened these protections: Safari's Intelligent Tracking Prevention (ITP), introduced in 2017 and fully blocking third-party by default since 2020, limits cross-site storage access to prevent tracking without user consent. Google's planned a complete third-party phase-out by early 2025 to align with goals, but as of November 2025, this deprecation has been paused indefinitely, maintaining partial support while promoting alternatives like .

Modern Extensions

Cross-Origin Embedder Policy (COEP)

The Cross-Origin Embedder Policy (COEP) is an HTTP response header that allows web developers to declare a policy for how their document loads and embeds cross-origin resources, requiring explicit permission from those resources to prevent unauthorized access. Introduced to enhance web security in the early 2020s, COEP addresses vulnerabilities in resource embedding by enforcing that cross-origin embeds, such as images, scripts, and fonts, must include appropriate Cross-Origin Resource Policy (CORP) or Cross-Origin Resource Sharing (CORS) headers. Its primary purpose is to mitigate cross-origin data exfiltration attacks, such as those exploiting tainted canvases to extract pixel data from images or using fonts to leak information via timing side-channels, thereby promoting safer resource isolation. By opting into COEP, documents can achieve cross-origin isolation, unlocking access to high-performance features like SharedArrayBuffer that were previously restricted due to security concerns. COEP supports several directives to balance security and usability. The default value, unsafe-none, permits loading cross-origin resources without restrictions, maintaining backward compatibility but offering no additional protection. The require-corp directive enforces strict controls, blocking any cross-origin resource that lacks a CORP header (e.g., Cross-Origin-Resource-Policy: cross-origin) or CORS configuration, ensuring only trusted embeds are allowed. In contrast, the credentialless mode provides a more flexible opt-in for third-party resources; it loads them without user credentials (e.g., cookies), stripping sensitive data while still enabling cross-origin isolation without requiring the remote server to add CORP headers. This mode is particularly useful for embedding unconfigurable third-party content, such as analytics scripts, while mitigating risks associated with credentialed access. Browser support for COEP began with and version 83 in April 2020, followed by version 79 later that year, and version 15.2 in December 2021. The credentialless directive has narrower adoption, supported in and from version 96 (October 2021) and from version 119 (November 2023). For example, a setting Cross-Origin-Embedder-Policy: require-corp will fail to load an from https://example.com/image.jpg unless that resource includes a CORP header like Cross-Origin-Resource-Policy: cross-origin; otherwise, the load is blocked, and any attempt to draw the onto a would result in a , preventing . This enforcement extends to other embeds like scripts and fonts, ensuring comprehensive protection against attacks.

Cross-Origin Opener Policy (COOP)

The Cross-Origin Opener Policy () is an HTTP response header that governs how a top-level interacts with other documents opened via mechanisms like window.open(), by controlling whether they share the same browsing context group. When set to same-origin, the policy instructs the browser to place cross-origin documents in a separate browsing context group, effectively severing the opener relationship and preventing access to the original 's global object or DOM. This isolation occurs upon navigation, ensuring that potential cross-origin interactions are blocked at the browsing context level. The primary purpose of is to mitigate advanced security threats, including side-channel attacks like , by enabling origin isolation that prevents timing-based data leaks across different origins sharing a . It also defends against reverse tabnabbing, a technique where a malicious cross-origin page opened in a new tab can navigate or manipulate the original tab's location or content via the window.opener reference. By enforcing separate browsing context groups, COOP ensures that such manipulations are impossible without explicit policy alignment. As of October 2025, major services like have enabled COOP to protect against XS-Search attacks. COOP interacts with the Cross-Origin Embedder Policy (COEP) to achieve cross-origin , a state where a and its embedder cannot access each other's resources unless explicitly allowed, providing comprehensive mitigations for shared-memory vulnerabilities in modern APIs. Together, these policies enable secure use of features requiring , such as high-resolution timers or shared buffers. The header supports three main values: unsafe-none (the default, permitting shared browsing contexts with no restrictions), same-origin (enforcing strict for cross-origin navigations), and same-origin-allow-popups (allowing popups to share contexts if they declare a compatible policy). COOP was standardized in 2021 as part of the Living Standard by the , with broad browser support emerging around that time ( 83+, 79+, 15.2+).

Integration with Fetch and Service Workers

The , introduced as a modern replacement for , integrates with the same-origin policy () through configurable request modes that govern cross-origin access. The supports four primary modes: "same-origin," which restricts requests exclusively to the document's origin, preventing any cross-origin fetches; "cors," which permits cross-origin requests only if the target server explicitly allows them via () headers; "no-cors," which enables simple cross-origin requests (such as for images or scripts) but returns an opaque Response object, limiting access to headers, body, or status details; and "navigate," used specifically for top-level navigation requests. These modes ensure that SOP enforcement remains consistent while providing developers with flexible control over network interactions, such as including credentials like cookies via the credentials option (e.g., fetch(url, {mode: 'cors', credentials: 'include'})), which requires CORS preflight checks for non-simple requests. Service Workers extend SOP compliance by acting as client-side proxies that intercept network requests within their registered scope, which is inherently tied to a specific . Registration occurs via navigator.serviceWorker.register(scope), where the scope path must be same- relative to the registration , locking the worker to that and preventing cross- interference. Upon activation, a Service Worker listens for fetch events and can modify requests or responses, but it must respect SOP: for instance, the onfetch handler receives a FetchEvent with the original request's , and any synthetic responses or redirects are subject to the same CORS and opacity rules as direct fetches (e.g., cross- responses remain opaque unless CORS-enabled). This -bound interception enhances caching and offline capabilities for progressive web apps while upholding security boundaries, as demonstrated in code like self.addEventListener('fetch', event => { if (new URL(event.request.url).[origin](/page/Origin) === self.location.[origin](/page/Origin)) { event.respondWith(cachedResponse); } });. Recent enhancements to Service Workers and related APIs address privacy concerns in cross-origin contexts through partitioning mechanisms. Specifications from 2023 onward introduced partitioned Service Workers, where workers in third-party iframes are isolated per top-level site to prevent cross-site tracking, affecting registration and fetch interception by scoping and events to the embedding rather than the worker's own. Complementing this, Private State Tokens provide a mechanism for anonymous cross-origin authentication, allowing a site to request tokens from a trusted (same or different ) to prove user legitimacy without revealing identifiers, integrated with Fetch via token redemption headers while adhering to SOP via opt-in lists. These features enable safer cross-origin interactions in scenarios like fraud detection. Looking ahead, the Fetch API and Service Workers are aligning with emerging protocols like WebTransport, which extends low-latency bidirectional communication over while enforcing SOP through origin checks on session establishment and data streams, ensuring cross-origin usage requires explicit permissions similar to CORS. The WebTransport specification was updated to Working Draft on October 22, 2025. For progressive web apps (PWAs), ongoing standardization efforts explore targeted SOP relaxations, such as multi-origin scopes for federated PWAs, to improve installation and offline functionality without compromising core security principles, though implementations remain proposal-stage as of 2025.

References

  1. [1]
    Same-origin policy - Security - MDN Web Docs - Mozilla
    Sep 26, 2025 · The same-origin policy is a critical security mechanism that restricts how a document or script loaded by one origin can interact with a resource from another ...Definition of an origin · Changing origin · Cross-origin network access
  2. [2]
    RFC 6454 - The Web Origin Concept - IETF Datatracker
    This document describes the principles behind the so-called same- origin policy ... For example, consider a user agent that executes scripts on behalf of origins.
  3. [3]
    Same Origin Policy - Web Security
    Jan 6, 2010 · The same-origin policy restricts which network messages one origin can send to another. For example, the same-origin policy allows inter-origin HTTP requests.Missing: core | Show results with:core
  4. [4]
    Same-origin policy (SOP) | Web Security Academy - PortSwigger
    The same-origin policy is a web browser security mechanism that aims to prevent websites from attacking each other.
  5. [5]
  6. [6]
  7. [7]
  8. [8]
  9. [9]
  10. [10]
  11. [11]
  12. [12]
  13. [13]
  14. [14]
  15. [15]
  16. [16]
  17. [17]
  18. [18]
    A timeline of Web browser security - The Parallax View
    Aug 30, 2016 · It also introduces a basic same-origin policy to isolate potentially malicious documents. Loading. What's up, bugs? October 10, 1995. Netscape ...
  19. [19]
    Internet Explorer security zones registry entries for advanced users
    Oct 12, 2020 · This article describes how and where Internet Explorer security zones and privacy settings are stored and managed in the registry.Missing: origin | Show results with:origin
  20. [20]
    Cross-Origin Resource Sharing - W3C
    This is the 27 July 2010 W3C Working Draft of the "Cross-Origin Resource Sharing" document. It is expected that this document will progress ...Missing: history | Show results with:history
  21. [21]
    HTML5 Web Messaging - W3C
    May 1, 2012 · This specification defines two mechanisms for communicating between browsing contexts in HTML documents.4 Cross-Document Messaging · 5 Channel Messaging · 5.3 Message Ports
  22. [22]
    Request additional migration time with the third-party cookie ...
    Nov 20, 2023 · The deprecation trial only enables third-party cookies for the origin registered for the trial. After activation third-party cookies will be ...
  23. [23]
    Error: Permission denied to access property "x" - MDN Web Docs
    Sep 11, 2025 · ... SecurityError: Blocked a frame with origin "x" from accessing a ... same-origin policy. Examples. No permission to access document. html<|separator|>
  24. [24]
    HTMLIFrameElement: contentWindow property - Web APIs | MDN
    Sep 25, 2023 · Access to the Window returned by contentWindow is subject to the rules defined by the same-origin policy, meaning that if the iframe is same- ...
  25. [25]
    Cross-Origin Resource Sharing (CORS) - HTTP - MDN Web Docs
    Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its ownMissing: principles | Show results with:principles
  26. [26]
    XMLHttpRequest - Web APIs | MDN
    Aug 26, 2025 · A boolean. If true, the same origin policy will not be enforced on the request. Instance methods. XMLHttpRequest.abort().Using XMLHttpRequest · XMLHttpRequest: send() method · XMLHttpRequest APIMissing: restrictions | Show results with:restrictions
  27. [27]
    Using the Fetch API - MDN Web Docs
    Aug 20, 2025 · same-origin (the default): only send and include credentials for same-origin requests. include : always include credentials, even cross-origin.
  28. [28]
    CORS errors - HTTP - MDN Web Docs - Mozilla
    Jul 4, 2025 · Cross-Origin Resource Sharing (CORS) is a standard that allows a server to relax the same-origin policy. This is used to explicitly allow ...CORS request did not succeed · Reason: CORS header...Missing: objectives | Show results with:objectives
  29. [29]
  30. [30]
  31. [31]
  32. [32]
    State Partitioning - Privacy on the web | MDN
    Sep 23, 2025 · State Partitioning is a broad effort by Mozilla to rework how Firefox manages client-side state (ie, data stored in the browser) to mitigate the ability of ...
  33. [33]
    Access-Control-Allow-Origin header - HTTP - MDN Web Docs
    Jul 4, 2025 · The HTTP Access-Control-Allow-Origin response header indicates whether the response can be shared with requesting code from the given origin.
  34. [34]
    Cross-Origin Resource Sharing and Why We Need Preflight Requests
    Mar 18, 2024 · The access-control-allow-origin header is one of the main CORS headers a server can use to show what requests it will allow. The value of this ...
  35. [35]
    Authoritative guide to CORS (Cross-Origin Resource Sharing) for ...
    Jan 16, 2022 · CORS is a security mechanism that allows a web page from one domain or Origin to access a resource with a different domain (a cross-domain ...What Is Cors? · How Cors Works? · Advanced Configuration
  36. [36]
    What is CORS (cross-origin resource sharing)? - PortSwigger
    Cross-origin resource sharing (CORS) is a browser mechanism which enables controlled access to resources located outside of a given domain.
  37. [37]
    Security implications of cross-origin resource sharing (CORS ... - Snyk
    Sep 13, 2023 · CORS lets web applications bypass SOP limitations, enabling communication between various web services and allowing cross-origin requests. ...
  38. [38]
    Cross-Origin Resource Sharing - W3C
    Jan 16, 2014 · This document defines a mechanism to enable client-side cross-origin requests. Specifications that enable an API to make cross-origin requests to resources can ...Missing: history | Show results with:history<|separator|>
  39. [39]
  40. [40]
    Document: domain property - Web APIs - MDN Web Docs - Mozilla
    Sep 25, 2025 · The domain property of the Document interface gets/sets the domain portion of the origin of the current document, as used by the same-origin policy.
  41. [41]
    Chrome will disable modifying document.domain to relax the same ...
    Jan 11, 2022 · Websites set document.domain to make it possible for same-site documents to communicate more easily. Because this change relaxes the same-origin ...
  42. [42]
    Chrome disables modifying document.domain | Blog
    May 30, 2023 · Warning: As we've announced in January 2022, we are deprecating the document.domain setter starting in Chrome 115. If your website relies on ...Missing: timeline | Show results with:timeline
  43. [43]
  44. [44]
    Window: postMessage() method - Web APIs - MDN Web Docs
    Sep 18, 2025 · Cross-Origin-Opener-Policy with same-origin as value (protects your origin from attackers) · Cross-Origin-Embedder-Policy with require-corp or ...
  45. [45]
  46. [46]
    Transferable objects - Lightning fast | Blog - Chrome for Developers
    Dec 9, 2011 · With transferable objects, data is transferred from one context to another. It is zero-copy, which vastly improves the performance of sending data to a Worker.Missing: enhancement | Show results with:enhancement
  47. [47]
    JSONP - W3Schools
    $$myJSON = '{ "name":"John", "age":30, "city":"New York" }'; echo "myFunc(".$myJSON.");"; ?> ... The result returns a call to a function named "myFunc" with the ...
  48. [48]
    What is JSONP, and why was it created? - Stack Overflow
    Jan 14, 2010 · This trick makes it possible for the server to "inject" javascript code directly in the Client browser and this with bypassing the "same origin" ...
  49. [49]
    Cross Site Scripting (XSS) - OWASP Foundation
    XSS attacks inject malicious scripts into trusted websites, allowing attackers to send code to users, who execute it without knowing it's not trusted.DOM based XSS Prevention · DOM-based XSS vulnerability · DOM Based XSSMissing: JSONP | Show results with:JSONP
  50. [50]
    Web Applications Working Group Teleconference -- 02 Nov 2009
    Nov 2, 2009 · Discusses why CORS is an improvement of what is done today. RE: Also worth discussing is JSONP, which is horrendously evil. JS: Asks Microsoft ...
  51. [51]
    RFC 6455 - The WebSocket Protocol - IETF Datatracker
    The WebSocket Protocol enables two-way communication between a client running untrusted code in a controlled environment to a remote host.
  52. [52]
    Writing WebSocket servers - Web APIs | MDN
    Jun 24, 2025 · Note: All browsers send an Origin header. You can use this header for security (checking for same origin, automatically allowing or denying, etc ...The WebSocket handshake · Exchanging data frames · Pings and Pongs: The...
  53. [53]
    WebSocket() constructor - Web APIs
    Oct 30, 2025 · The WebSocket() constructor returns a new WebSocket object and immediately attempts to establish a connection to the specified WebSocket URL.
  54. [54]
    Use cross-origin images in a canvas - HTML - MDN Web Docs
    Sep 18, 2025 · The key is to use the crossorigin attribute by setting crossOrigin on the HTMLImageElement into which the image will be loaded. This tells the ...Missing: location. | Show results with:location.
  55. [55]
    XMLHttpRequest: withCredentials property - Web APIs | MDN
    Jun 24, 2025 · Setting withCredentials has no effect on same-origin requests. In addition, this flag is also used to indicate when cookies are to be ignored in ...
  56. [56]
    Request: credentials property - Web APIs - MDN Web Docs
    May 19, 2025 · Only send and include credentials for same-origin requests. This is the default. include. Always include credentials, even for cross-origin ...
  57. [57]
    Cross-Site Request Forgery Prevention - OWASP Cheat Sheet Series
    If an attacker is able to take over a subdomain (not uncommon with cloud services) your CORS configuration would allow them to bypass the same origin policy and ...<|control11|><|separator|>
  58. [58]
    OAuth 2.0 authentication vulnerabilities | Web Security Academy
    In this section, we'll teach you how to identify and exploit some of the key vulnerabilities found in OAuth 2.0 authentication mechanisms.Missing: reusable | Show results with:reusable
  59. [59]
    Third-party cookies | Privacy Sandbox - Google
    Set up Chrome to simulate the state when third-party cookies are blocked by user choice. Start testing. Migrate to privacy preserving solutions. Once you have ...Third-party cookie restrictions · Storage Partitioning · Debug third-party cookie...
  60. [60]
    SameSite cookies explained | Articles - web.dev
    May 7, 2019 · SameSite cookies use an attribute to restrict cookies to first-party or same-site contexts, with options like Strict, Lax, or None.
  61. [61]
    SameSite - OWASP Foundation
    SameSite prevents the browser from sending this cookie along with cross-site requests. The main goal is to mitigate the risk of cross-origin information leakage ...
  62. [62]
    Fetch: Cross-Origin Requests - The Modern JavaScript Tutorial
    Oct 18, 2022 · Cross-origin fetch requests to other domains/ports/protocols require special headers due to CORS. Safe requests are sent directly, while unsafe ...
  63. [63]
    XS Leaks - OWASP Cheat Sheet Series
    Same Origin Policy (SOP)¶ · Two URLs are considered as same-origin if their protocol, port, and host are the same · Any origin can send a request to another ...
  64. [64]
    Cross-site leaks (XS-Leaks) - Security - MDN Web Docs
    Oct 17, 2025 · Cross-site leaks (also called XS-Leaks) are a class of attack in which an attacker's site can derive information about the target site.Sample Cross-Site Leaks · Defenses Against Cross-Site... · Fetch MetadataMissing: disclosure | Show results with:disclosure
  65. [65]
    Cross Site Scripting Prevention - OWASP Cheat Sheet Series
    In order for an XSS attack to be successful, an attacker must be able to insert and execute malicious content in a webpage. Thus, all variables in a web ...Missing: JSONP | Show results with:JSONP
  66. [66]
    [PDF] Cache Timing Attacks Revisited: Efficient and Repeatable Browser ...
    Jul 13, 2016 · In order to make the timing attacks scalable and avoid cache contamination, we use Web Workers and timeouts on probing requests. Previously,.
  67. [67]
    Cache Probing | XS-Leaks Wiki
    May 9, 2025 · Cache probing detects if a resource is cached by the browser, using timing differences or error events to check if a resource is cached.
  68. [68]
    [PDF] I Still Know What You Visited Last Summer: Leaking Browsing ...
    Abstract—History sniffing attacks allow web sites to learn about users' visits to other sites. The major browsers have recently adopted a defense against the ...
  69. [69]
    [PDF] Browser history re:visited - UCSD CSE
    Jul 22, 2018 · Much like browsers enforce the same-origin policy (SOP) in a principled way—ensuring that one origin1 cannot read sensitive data from another.
  70. [70]
    [PDF] Understanding Cross-site Leaks and Defenses - SecWeb
    Through cross-site leaks (XS-Leaks), an adversary can try to circumvent the same-origin policy and extract information about responses, which in turn reveals ...
  71. [71]
    Mitigating Spectre with Site Isolation in Chrome
    Jul 11, 2018 · In theory, a website could use such an attack to steal information from other websites, violating the Same Origin Policy. All major browsers ...
  72. [72]
    [PDF] Exploiting Speculative Execution - Spectre Attacks
    Spectre attacks exploit speculative execution to induce a victim to perform operations that leak confidential information via side channels, using transient ...Missing: policy | Show results with:policy
  73. [73]
    Post-Spectre Web Development - W3C
    Mar 16, 2021 · [SPECTRE] This revelation has pushed web browsers to shift their focus from the platform-level origin boundary to an OS-level process boundary.
  74. [74]
    Cross Site Request Forgery (CSRF) - OWASP Foundation
    CSRF attacks target functionality that causes a state change on the server, such as changing the victim's email address or password, or purchasing something.Prevention Measures That Do... · Examples · How Does The Attack Work?
  75. [75]
    Cross-site request forgery (CSRF) - Security - MDN Web Docs
    Oct 17, 2025 · In a cross-site request forgery (CSRF) attack, an attacker tricks the user or the browser into making an HTTP request to the target site from a malicious site.
  76. [76]
  77. [77]
    CWE-352: Cross-Site Request Forgery (CSRF)
    For example, use anti-CSRF packages such as the OWASP CSRFGuard. [REF-330]. Another example is the ESAPI Session Management control, which includes a ...
  78. [78]
    CSRF in 2025: Not Dead, Just Different - Ghost Security
    Aug 19, 2025 · And while modern web frameworks have better defenses baked in, CSRF is still very much alive in 2025, especially in custom APIs ...Missing: prevalence | Show results with:prevalence
  79. [79]
    Cross-Site Request Forgery (CSRF) - Invicti
    Prevalence: discovered often ; Scope: web applications with authentication ; Technical impact: attacker triggers unauthorized actions ; Worst-case consequences: ...
  80. [80]
    Web Storage API - MDN Web Docs - Mozilla
    Feb 22, 2025 · localStorage is partitioned by origin only. All documents with the same origin have access to the same localStorage area, and it persists even ...Missing: policy | Show results with:policy
  81. [81]
    [PDF] Can I Take Your Subdomain? Exploring Same-Site Attacks in the ...
    Aug 11, 2021 · Hence, related- domain attackers can trivially break cookie confidentiality and abuse of stolen cookies [62], e.g., to perform session hijack-.
  82. [82]
    Can I take Your Subdomain? Exploring Same-Site Attacks in the ...
    We then show how these vulnerable subdomains can be exploited to compromise same-site web applications by focusing on attacks against cookies, bypasses of web ...Introduction · Evaluation · Third-Party Services
  83. [83]
    [PDF] Attacking and Defending postMessage in HTML5 Websites
    The postMessage mechanism in HTML5 enables Web content from different origins to communicate with each other, thus relaxing the same origin policy.
  84. [84]
    Hijacking OAUTH flows via Cookie Tossing - Snyk Labs
    Nov 26, 2024 · Exploiting Cookie Tossing. The behavior of both the Domain and Path attributes can be leveraged to perform a Cookie Tossing attack. When an ...
  85. [85]
    Cross-site scripting (XSS) - Security - MDN Web Docs
    Oct 30, 2025 · In a successful XSS attack, the attacker is able to subvert the same-origin policy by tricking the target site into executing malicious code ...<|separator|>
  86. [86]
    Tracking Prevention in WebKit
    Full Third-Party Cookie Blocking. ITP by default blocks all third-party cookies. There are no exceptions to this blocking. Third-party cookie access can only be ...
  87. [87]
    Google cancels Chrome cookie deprecation - ContentGrip
    May 2, 2025 · Google just confirmed it will no longer remove third-party cookies from Chrome, officially abandoning a years-long effort to overhaul how digital tracking ...
  88. [88]
    Cross-Origin Embedder Policy
    Sep 29, 2020 · This document sketches out a potential opt-in mechanism which relies upon explicit declaration of a Cross-Origin-Resource-Policy for each embedded resource.Introduction · Framework · Integrations · Implementation Considerations
  89. [89]
    Why you need "cross-origin isolated" for powerful features - web.dev
    May 4, 2020 · Cross Origin Opener Policy (COOP) allows you to ensure that a top-level window is isolated from other documents by putting them in a different ...
  90. [90]
    Load cross-origin resources without CORP headers using COEP
    Jul 29, 2021 · credentialless is a new value for the Cross-Origin-Embedder-Policy header. Similar to require-corp, it can enable cross-origin isolation.Challenges With Enabling... · Credentialless To The Rescue · Faq
  91. [91]
    Cross-Origin-Embedder-Policy - Expert Guide to HTTP headers
    Jun 20, 2022 · The HTTP Cross-Origin-Embedder-Policy response header prevents a document from accessing cross-origin resources that don't explicitly grant permission to do so.
  92. [92]
    Making your website "cross-origin isolated" using COOP and COEP
    Apr 13, 2020 · And we have come up with the idea of going in the opposite direction: a new COEP "credentialless" mode that allows loading resources without the ...
  93. [93]
    "Cross-Origin-Embedder-Policy" | Can I use... Support tables for ...
    "Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
  94. [94]
    headers HTTP header: Cross-Origin-Embedder-Policy: credentialless
    headers HTTP header: Cross-Origin-Embedder-Policy: credentialless ; Chrome. 4 - 95 : Not supported. 96 - 140 : Supported. 141 ; Edge *. 12 - 95 : Not supported.
  95. [95]
  96. [96]
    A Spectre proof-of-concept for a Spectre-proof web
    Mar 12, 2021 · Cross-Origin Opener Policy (COOP) lets developers ensure that their application window will not receive unexpected interactions from other ...
  97. [97]
  98. [98]
    Tabnabbing Attacks and Prevention - AppSec Monkey
    Apr 5, 2021 · There is a relatively new browser security feature called Cross-Origin Opener Policy . You can use COOP to prevent the attack where a malicious ...
  99. [99]
    opaque origin - HTML Standard - whatwg
    Origins are the fundamental currency of the web's security model. Two actors in the web platform that share an origin are assumed to trust each other.Missing: core principles
  100. [100]
    headers HTTP header: Cross-Origin-Opener-Policy - CanIUse
    headers HTTP header: Cross-Origin-Opener-Policy. Usage % of. all users, all tracked, tracked desktop, tracked mobile.
  101. [101]
    Fetch Standard - whatwg
    Oct 10, 2025 · The unsafe-request flag is set by APIs such as fetch() and XMLHttpRequest to ensure a CORS-preflight fetch is done based on the supplied method ...
  102. [102]
    Service Workers - W3C
    Mar 6, 2025 · Service workers enable this by allowing Caches to fetch and cache off-origin items. Some restrictions apply, however. First, unlike same-origin ...
  103. [103]
    Using Service Workers - Web APIs | MDN
    Oct 30, 2025 · The service worker code is fetched and then registered using serviceWorkerContainer.register() . If successful, the service worker is executed ...ServiceWorkerContainer · Install event · Fetch eventMissing: respect SOP locked
  104. [104]
    Storage Partitioning | Privacy Sandbox
    Jun 13, 2025 · The Web Locks API allows code running in one tab or worker of the same origin to acquire a lock for a shared resource while some work is ...Missing: policy | Show results with:policy
  105. [105]
    Private State Token API - GitHub Pages
    Jul 18, 2024 · Tokens can be redeemed from a different origin than the fetching one. Private State Tokens API performs cross site anonymous authentication ...
  106. [106]
    Private State Tokens - Privacy Sandbox
    The site uses the Private State Token API to check if the user's browser has trust tokens stored for issuers that the site trusts. Private state tokens are ...Why do we need Private State... · How do Private State Tokens... · Use cases
  107. [107]
    WebTransport - W3C
    Oct 22, 2025 · This document defines a set of ECMAScript APIs in WebIDL to allow data to be sent and received between a browser and server.
  108. [108]
    Progressive Web Apps in multi-origin sites
    Aug 19, 2019 · Same-origin policy imposes many restrictions for sites built on top of multiple origins that want to achieve a coherent PWA experience. For that ...Missing: relaxations future