Skip to main content
ExplainerWeb SecurityExplainer· 4 min read· in Technology

How the Protocol-Host-Port Triple Defines the Security Boundary of a Web Document

The Same-Origin Policy relies on a strict combination of protocol, host, and port to isolate web documents from one another. Understanding this tuple reveals why modern browsers permit cross-site embedding but block cross-site data reading.

By Wei Zhang

Web Standards Authors 35%Security Researchers 35%Application Developers 30%
Web Standards Authors
Focuses on strict specification compliance and deprecating legacy workarounds.
Security Researchers
Views the policy as a porous boundary requiring constant vigilance against read/write asymmetry exploits.
Application Developers
Prioritizes functionality and seamless cross-domain resource sharing via CORS.

Perspectives this story doesn't cover

  • Legacy Enterprise System Administrators

The short answer

  • The Same-Origin Policy isolates web documents based on a strict match of protocol, host, and port.
  • If any of the three variables differ, the browser blocks scripts from reading the target's Document Object Model.
  • The policy is asymmetrical: it blocks cross-origin reading but permits cross-origin embedding of images and scripts.
  • Historical workarounds like the document.domain setter are being actively deprecated by web standards bodies.
  • Modern web applications rely on CORS headers to securely relax the boundary for authorized cross-origin requests.
  • Newer headers like COOP and COEP are required to enforce true memory isolation against hardware vulnerabilities.

The exact moment a web application's security is determined happens in milliseconds within the browser's network stack, right before a script attempts to read the Document Object Model (DOM). The browser evaluates three specific variables: the protocol, the host, and the port. If this triple matches the origin of the target data, access is granted. If even one variable differs, the browser enforces a hard boundary. This mechanism is the reason a malicious script in one tab cannot quietly read the session cookies of a banking application open in another.[1][2]

Known formally as the Same-Origin Policy (SOP), this concept was first introduced in 1995 with the release of Netscape Navigator 2.02. Over the subsequent three decades, it has remained the fundamental currency of the web's security model. As the WHATWG HTML standard states, "Two actors in the web platform that share an origin are assumed to trust each other and to have the same authority."[1][5]

The boundary is strictly defined by the tuple. For example, a document loaded from an HTTP connection cannot read data from an HTTPS connection on the same domain because the protocol differs. Similarly, a script running on port 80 cannot access data on port 81 due to a port mismatch, even if the host and protocol are identical.[2][3]

An origin is defined by the exact match of scheme, host, and port.

However, the marketing language surrounding web security often presents the Same-Origin Policy as an impenetrable vault. In reality, the architecture is highly porous by design. The policy distinguishes sharply between sending information and receiving it, creating a read/write asymmetry that allows the modern web to function.[2][9]

Browsers routinely permit cross-origin embedding. An HTML document can load images via the image tag, execute scripts, and apply stylesheets from entirely different domains. As the Mozilla Developer Network (MDN) documentation notes, "Cross-origin embedding is typically allowed... Cross-origin reads are typically disallowed."[2][3]

Without this "allow sending" and "allow embedding" exception, the web as a hyperlinked ecosystem would break. If origins could only link to and load resources from themselves, content delivery networks (CDNs) and distributed media would be impossible. The policy specifically targets read access to prevent data exfiltration, rather than isolating the document entirely.[5][8]

This porous nature means developers must actively manage the boundary. When a browser sends an HTTP request from one origin to another, it automatically includes any relevant authentication cookies. If the Same-Origin Policy did not block the reading of the response, a malicious site could easily parse a user's private inbox or financial dashboard.[2][8]

This porous nature means developers must actively manage the boundary.

Historically, the implementation of the protocol-host-port triple has not been uniform. Internet Explorer, for instance, famously did not include the port number when calculating the origin tuple. This meant that a script running on port 80 could access data on port 8080 of the same host, a quirk that persisted in enterprise environments for years and required specific workarounds.[8]

The historical and structural numbers behind the Same-Origin Policy.

To bypass the strict restrictions of the triple when necessary, developers historically relied on the document.domain setter. This allowed subdomains to synchronously access each other's DOMs by truncating their hostnames to a common superdomain, effectively rewriting the host variable of the tuple on the fly.[1][2]

Today, the document.domain approach is actively deprecated. The WHATWG specification warns developers to "Avoid using the document.domain setter. It undermines the security protections provided by the same-origin policy." Modern browsers are phasing out this capability because it breaks the isolation required for shared hosting environments.[1]

Instead, the industry has standardized on Cross-Origin Resource Sharing (CORS). CORS operates via HTTP headers, allowing a server to explicitly declare which external origins are permitted to read its responses. The Access-Control-Allow-Origin header acts as a cryptographic permission slip, relaxing the strict tuple check only when cryptographically verified.[3][4]

As web applications have evolved into complex, multi-threaded software, the basic Same-Origin Policy has proven insufficient against advanced hardware vulnerabilities like Spectre. This has led to the introduction of Cross-Origin Opener Policy (COOP) and Cross-Origin Embedder Policy (COEP).[1][4]

These newer headers enforce "cross-origin isolation," a state where the browser guarantees that a document does not share a memory process with cross-origin content. According to the OWASP HTTP Headers Cheat Sheet, COOP "allows you to ensure a top-level document does not share a browsing context group with cross-origin documents."[4]

Same-Origin requires a strict triple match, while Same-Site evaluates only the scheme and registrable domain.

The distinction between "Same-Origin" and "Same-Site" also confuses many implementations. While an origin requires an exact match of the protocol, host, and port, a "site" is defined only by the scheme and the registrable domain. Thus, two different subdomains are cross-origin but same-site, a distinction that dictates how modern cookies are routed.[1][2]

Ultimately, the protocol-host-port triple remains the bedrock of web security. While new headers and isolation modes continue to layer on top of it, the fundamental check—evaluating those three variables before granting DOM access—is the single mechanism keeping the open web from collapsing into a massive data breach.[1][9]

Jargon, explained

Tuple
A mathematical term for a finite ordered list of elements; in web security, it refers to the three-part combination of protocol, host, and port.
Document Object Model (DOM)
The programming interface that represents an HTML document as a tree of objects, allowing scripts to read and manipulate the page content.
Cross-Origin Resource Sharing (CORS)
An HTTP-header based mechanism that allows a server to indicate any origins other than its own from which a browser should permit loading resources.
Cross-Origin Opener Policy (COOP)
A security header that ensures a top-level document does not share a browsing context group with cross-origin documents, isolating it from attacks like Spectre.

Sources

Source coverage

9 outlets

3 viewpoints surfaced

Web Standards Authors 35%Security Researchers 35%Application Developers 30%
  1. [1]WHATWGWeb Standards Authors

    HTML Standard: Origins

    Read on WHATWG →
  2. [2]MDN Web DocsWeb Standards Authors

    Same-origin policy - Security

    Read on MDN Web Docs →
  3. [3]web.devApplication Developers

    Same-origin policy

    Read on web.dev →
  4. [4]OWASPSecurity Researchers

    HTTP Headers - OWASP Cheat Sheet Series

    Read on OWASP →
  5. [5]Wikipedia

    Same-origin policy

    Read on Wikipedia →
  6. [6]PentesterLabSecurity Researchers

    Same-Origin Policy (SOP): Definition & Security Context

    Read on PentesterLab →
  7. [7]GeeksforGeeksApplication Developers

    What is Same Origin Policy (SOP)?

    Read on GeeksforGeeks →
  8. [8]PortSwiggerSecurity Researchers

    Same-origin policy

    Read on PortSwigger →
  9. [9]Factlen Editorial Team

    Synthesis by Factlen editorial team

    Read on Factlen Editorial Team →

Comments

Stay informed

Every angle. Every day.

Get Technology stories with full source coverage and perspective breakdowns delivered to your inbox.