❤️
SecurityHeaders.nl

Cross-Origin-Resource-Policy (CORP)

The Cross-Origin-Resource-Policy (CORP) HTTP response header allows servers to declare which origins are permitted to embed and read the current resource (such as images, fonts, scripts, or JSON APIs).

Why CORP Matters

Modern browsers allow web pages to embed cross-origin resources using tags like <img>, <video>, or <script> by default. While traditional Cross-Origin Resource Sharing (CORS) restricts JavaScript from reading cross-origin responses, it does not stop browsers from loading those resources into browser memory.

With hardware-level CPU vulnerabilities like Spectre, malicious scripts running in the same process can inspect memory buffers and extract confidential data loaded through normal tags. CORP stops this at the source by telling the browser to abort loading the resource entirely if the requesting site is not permitted.

Supported Directives

Cross-Origin-Resource-Policy: same-origin

CORP provides three protection levels:

Recommended Configuration

Apache (.htaccess)

Header always set Cross-Origin-Resource-Policy "same-origin"

Nginx

add_header Cross-Origin-Resource-Policy 'same-origin' always;

Exceptions: Public Images and Badges

If your website serves assets that are meant to be embedded on other websites (such as a dynamic verification badge or tracking pixel), you must override CORP for that specific file:

<Files "badge.php">
    Header always set Cross-Origin-Resource-Policy "cross-origin"
    Header always set Access-Control-Allow-Origin "*"
</Files>