Catalog My learning Blog
Browser Security Headers: CORS, CSP and Cookies Explained · Phase 5 · Lesson 23 · 6 min read

Cross-Origin-Resource-Policy (CORP) Explained

On this page
  1. Learning Objective
  2. Concept Explanation
  3. Worked Example: Closing a Login-State Oracle With One Header
  4. Real-World Examples
  5. Review Questions & Answers

Learning Objective

Explain how CORP lets a resource declare who may embed it, distinguish it from CORS and from COEP, and apply it to close side-channel leaks against endpoints that were never meant to be loaded cross-origin.

Concept Explanation

Cross-Origin-Resource-Policy is the mirror image of everything else in this course. CORS is a resource saying who may read it. CORP is a resource saying who may load it at all, including as an embedded subresource where no reading occurs. It takes one of three values: same-origin, meaning only the exact same origin may load this; same-site, meaning any host on the same registrable domain may; and cross-origin, meaning anyone may. The header is trivially cheap to send and is the most underused control in the set.

The reason it matters is the leak surface established in this course's second lesson. A resource that cannot be read can still be observed: whether it loaded, how long it took, what dimensions an image has, whether it consumed unusual memory. If a JSON endpoint returns different content for a logged-in user than for an anonymous one, a cross-origin page can often distinguish the two from load success or timing alone, without ever reading a byte. CORP: same-origin removes that surface completely, because the load fails before any observable difference exists, and it does so with no application logic at all.

The three-way distinction with CORS and COEP is worth stating carefully, because the headers interact. CORS answers "may this origin read the response body." CORP answers "may this origin load this resource in any embedding context." COEP is set by the embedding document and demands that its subresources carry one of those two opt-ins. So CORP is what a resource sends, COEP is what a document requires, and the pair is what makes cross-origin isolation possible: the previous lesson's require-corp value is literally a demand that every subresource carry a satisfying CORP header.

Choosing values is straightforward once framed as a default. Every API endpoint, every HTML document, and everything returning user-specific data should carry CORP: same-origin. Assets intended to be shared across an organization's own hosts should carry same-site. Only genuinely public assets meant for embedding anywhere, a public CDN's fonts, images, and scripts, should carry cross-origin. The instinct to send cross-origin everywhere to avoid breakage is exactly backwards; the right default is same-origin with deliberate exceptions.

Two operational notes. First, CORP blocks no-cors loads specifically: a request made with CORS that passes the CORS check is allowed regardless, so adding CORP does not break a properly configured cross-origin fetch. Second, if you serve assets from a CDN that other properties embed, moving to same-origin will break them, so this is another case for a staged rollout: inventory who embeds what, set the header on the endpoints that should never be embedded first, and work outward. Endpoints returning authenticated JSON are the highest-value and lowest-risk place to start.

HeaderSet byQuestion it answers
Access-Control-Allow-OriginThe resourceMay script on this origin read my response body?
Cross-Origin-Resource-PolicyThe resourceMay this origin load me at all, even as a subresource?
Cross-Origin-Embedder-PolicyThe embedding documentMust everything I load have opted in to being loaded by me?
Cross-Origin-Opener-PolicyThe documentMay other windows retain a reference into my context group?

Worked Example: Closing a Login-State Oracle With One Header

The endpoint below leaks whether a user is logged in through nothing but load success, which no CORS configuration prevents. One header removes the oracle.

HTTP
# The endpoint: 200 with JSON when authenticated, 302 to /login otherwise.
GET /api/profile/avatar HTTP/1.1
Cookie: __Host-session=...

# THE LEAK - an attacker page never reads a byte, it just observes the load:
<img src="https://app.example.com/api/profile/avatar"
     onload="report('logged in')" onerror="report('logged out')">

# CORS does not help. Access-Control-Allow-Origin governs READING, and this
# attack performs no read at all; the img tag makes a no-cors request whose
# success or failure is the entire signal.

# THE FIX - one header, no application change:
HTTP/1.1 200 OK
Content-Type: application/json
Cross-Origin-Resource-Policy: same-origin
X-Content-Type-Options: nosniff

# The cross-origin img load now fails before any state-dependent difference
# is observable, so both the logged-in and logged-out cases look identical.

# Sensible defaults across a deployment:
location /api/      { add_header Cross-Origin-Resource-Policy same-origin; }
location /internal/ { add_header Cross-Origin-Resource-Policy same-site;   }
location /public/   { add_header Cross-Origin-Resource-Policy cross-origin; }
One resource answering three different questions through three headers, with CORP shown rejecting a no-cors embed that CORS would never have examined, closing a load-success side channel.
One resource answering three different questions through three headers, with CORP shown rejecting a no-cors embed that CORS would never have examined, closing a load-success side channel.

Real-World Examples

  • CORP was originally introduced as a Spectre mitigation to let servers keep sensitive responses out of an attacker's renderer process entirely, complementing Chrome's Cross-Origin Read Blocking by letting the resource owner state the restriction explicitly rather than relying on the browser's content-type heuristics to infer it.
  • The XS-Leaks research community maintains a public wiki cataloguing cross-site leak techniques built on observable signals such as load success, frame counting, and timing, and consistently lists CORP: same-origin as the single most effective mitigation for the subresource-based subset, because it removes the observable difference at the point of the load rather than trying to equalize behavior afterward.
Best PracticeDefault every API endpoint and authenticated response to Cross-Origin-Resource-Policy: same-origin, and grant cross-origin only to assets genuinely intended for public embedding. It is a single header with no application changes that closes an entire class of side-channel oracle that no CORS configuration can address.

Review Questions & Answers

Because CORS governs reading and the attack performs no read. An image tag issues a no-cors request whose only observable output is whether it loaded, and if the endpoint behaves differently for authenticated and anonymous users, that binary outcome is the leak. CORS never enters the picture, since the browser was never asked to expose the response to script. CORP works at the load itself, so the request fails before any state-dependent difference becomes observable.

They are two halves of the same handshake. CORP is sent by a resource to declare which origins may load it. COEP is sent by a document to demand that every cross-origin subresource it loads has made such a declaration, or was fetched with CORS. COEP: require-corp is literally a requirement that subresources carry a satisfying CORP header, which is why cross-origin isolation depends on resource owners across the web adopting CORP.

Because it grants every origin on the internet permission to embed the resource, which reinstates exactly the side-channel surface the header exists to close. The value is correct only for assets genuinely meant for public embedding, such as a public CDN's fonts and images. Setting it everywhere to avoid breaking something is the same instinct that produces permissive CORS policies, and it produces the same result: a control that is present in configuration but provides nothing.

No. CORP governs no-cors loads; a request made with CORS that passes the CORS check is permitted regardless of the CORP value. That is what makes the header safe to add broadly: it blocks the embedding paths that were never legitimate while leaving properly configured cross-origin API calls working, which is why authenticated JSON endpoints are the highest-value and lowest-risk place to start a rollout.