Cross-Origin-Resource-Policy
CORP specifies which origins can include your resources, providing protection against cross-origin attacks.
Results in 1–3 minutes · Free · No signup required
Why It Matters
Prevents your resources from being loaded by cross-origin documents without permission, protecting against Spectre attacks and resource theft.
How We Check
We check for CORP header and verify appropriate values (same-origin, same-site, or cross-origin) based on resource type.
Good vs Bad Values
| Value | Verdict | Why |
|---|---|---|
Cross-Origin-Resource-Policy: same-origin | Good | Only your own origin can load the resource in no-cors mode. The right default for private images, API responses and anything with user data. |
Cross-Origin-Resource-Policy: same-site | Good | Your origin and its sibling subdomains may load it. Use for assets shared between www and app on one registrable domain. |
Cross-Origin-Resource-Policy: cross-origin | Good | Anyone may embed it. Right for public CDN assets, fonts, logos and images that pages with COEP must be able to load. |
same-origin on authenticated downloads and user uploads | Good | Stops other sites embedding private files by guessing URLs, and limits Spectre-style reads of their contents. |
cross-origin on public images and scripts | Good | A deliberate opt-in; it is how CDNs let `Cross-Origin-Embedder-Policy: require-corp` pages use their files. |
Cross-Origin-Resource-Policy: same-site on a CDN host used by a different registrable domain | Bad | Valid syntax, wrong scope. Pages on the other domain can no longer load the files. |
Cross-Origin-Resource-Policy: * | Bad | Wildcards are not defined. The value is invalid and ignored. |
Cross-Origin-Resource-Policy: same-origin, cross-origin | Bad | Only a single token is allowed. A list is invalid and the scanner reports it as such. |
Cross-Origin-Resource-Policy: anonymous | Bad | That is a `crossorigin` attribute value, not a CORP value. It is ignored. |
Header missing | Bad | Any site can embed the resource in no-cors mode, and its bytes can end up in the attacker's process where side-channel attacks can reach them. |
How to Fix
Add Cross-Origin-Resource-Policy: same-origin for sensitive resources. Use cross-origin only for intentionally public resources.
Nginx — split by location so private and public files get different policies:
location /assets/public/ {
add_header Cross-Origin-Resource-Policy "cross-origin" always;
}
location / {
add_header Cross-Origin-Resource-Policy "same-origin" always;
}
Apache (requires mod_headers):
Header always set Cross-Origin-Resource-Policy "same-origin"
<LocationMatch "^/assets/public/">
Header always set Cross-Origin-Resource-Policy "cross-origin"
</LocationMatch>
Next.js — next.config.js. List the narrower rule so the public path is not given both values:
async headers() {
return [
{ source: "/((?!images/public).*)", headers: [{ key: "Cross-Origin-Resource-Policy", value: "same-origin" }] },
{ source: "/images/public/:path*", headers: [{ key: "Cross-Origin-Resource-Policy", value: "cross-origin" }] },
];
}
Express with Helmet: helmet.crossOriginResourcePolicy({ policy: "same-site" }) (Helmet's default is same-origin). Cloudflare: a Transform Rule per path pattern; give R2 or Pages assets a cross-origin rule when other sites embed them.
Choosing a value. Ask who legitimately loads the file. If only your pages, same-origin. If your pages across subdomains, same-site. If other websites (including partners and your own second domain), cross-origin. If unsure, start with same-site for internal assets and cross-origin for the public ones.
Verify with curl -sI https://example.com/logo.png | grep -i cross-origin-resource-policy, then load the file from a page on another origin and read the console. A blocked embed is reported as ERR_BLOCKED_BY_RESPONSE.NotSameOrigin.
Common Mistakes
- Setting `same-origin` on the whole site and breaking public assets: Open Graph images, avatars, and fonts or scripts served to other domains stop loading in pages that embed them.
- Putting `cross-origin` everywhere to be safe. It disables the protection; reserve it for files that are meant to be public.
- Believing it replaces CORS. CORP controls whether no-cors embedding is allowed; CORS controls whether a script may read the response. They solve different problems.
- Expecting it to stop `curl` or server-side fetches. CORP is enforced by browsers only; it is not access control.
- Forgetting that pages running under `Cross-Origin-Embedder-Policy: require-corp` need every cross-origin file to send `cross-origin` (or be loaded with CORS).
- Setting it only on HTML. The value matters for the resources: images, scripts, stylesheets, video and JSON files.
Frequently Asked Questions
What is Cross-Origin-Resource-Policy?
CORP specifies which origins can include your resources, providing protection against cross-origin attacks.
Why does Cross-Origin-Resource-Policy matter for website security?
Prevents your resources from being loaded by cross-origin documents without permission, protecting against Spectre attacks and resource theft.
How do I fix Cross-Origin-Resource-Policy issues?
Add Cross-Origin-Resource-Policy: same-origin for sensitive resources. Use cross-origin only for intentionally public resources.
Related Security Checks
Check Your Website Now
Run a free security scan to check for Cross-Origin-Resource-Policy issues and 61 other security checks.
Scan Your Website Free