--- url: "https://owasp.org/www-project-secure-headers/response-headers/" titulek: "Response Headers | OWASP Secure Headers Project" h1: "Response Headers" popis: "Provides technical information about HTTP security headers." jazyk: "en-US" kanonicka: "https://owasp.github.io/www-project-secure-headers/response-headers/" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 22:14:05" znaku: 59504 slov: 6449 kodovani: "utf-8" sha256: "1f2fa38e498a149553041f3a21c0ec35f3b2832e83acfb81249e9841e9d551cf" --- # Response Headers 💡 The collection of HTTP response security headers mentioned in this section is applicable when the [user agent](https://developer.mozilla.org/en-US/docs/Glossary/User_agent) processing the HTTP response is a browser. The support for these headers by non-browser API clients (user agent), like for example an HTTP client in a programming language, **is not standardized**. So, it requires specific testing to identify if an HTTP response security header is supported or not by such HTTP client. 🚦 Header lifecycle flow: 📐 **Working draft** - Permissions-Policy ✅ **Active** - Strict-Transport-Security - X-Frame-Options - X-Content-Type-Options - Content-Security-Policy - X-Permitted-Cross-Domain-Policies - Referrer-Policy - Clear-Site-Data - Cross-Origin-Embedder-Policy - Cross-Origin-Opener-Policy - Cross-Origin-Resource-Policy - Cache-Control - X-DNS-Prefetch-Control - Integrity-Policy ⏰ **Almost deprecated** None ❌ **Deprecated** - Feature-Policy - Expect-CT - Public-Key-Pins - X-XSS-Protection - Pragma ## Strict-Transport-Security HTTP Strict Transport Security (also named *HSTS*) is a browser security policy mechanism which helps to protect websites against protocol downgrade attacks and cookie hijacking. It allows web servers to declare that web browsers (or other complying user agents) should only interact with it using secure HTTPS connections, and within a defined timespan (max-age) not via the clear text HTTP protocol. HSTS is an IETF standard track protocol and is specified in [RFC 6797](https://www.rfc-editor.org/rfc/rfc6797). A server implements an HSTS policy by supplying a header (`Strict-Transport-Security`) over an HTTPS connection (HSTS headers over HTTP are ignored). 📍 Important note about the behavior of the header over a **HTTP connection** (source [Mozilla MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security#description)): - The `Strict-Transport-Security` header **is ignored by the browser when your site has only been accessed using HTTP** . - Once your site is accessed over HTTPS **with no certificate errors** , the browser knows your site is HTTPS capable and will honor the `Strict-Transport-Security` header. 💡 More information about *Preloading Strict Transport Security* can be found [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Strict-Transport-Security#preloading_strict_transport_security). 💡 The `preload` directive is not part of the RFC and its support/evolution is managed at browsers level. We explicitly decided to keep this directive out of the configuration proposed to be aligned with the advice specified by the `hstspreload.org` team ([source](https://hstspreload.org/#opt-in)): ``` If you maintain a project that provides HTTPS configuration advice or provides an option to enable HSTS, do not include the preload directive by default. We get regular emails from site operators who tried out HSTS this way, only to find themselves on the preload list without realizing that some subdomains cannot support HTTPS. Removal tends to be slow and painful for those sites. ``` ### Values | Value | Description | | --- | --- | | `max-age=SECONDS` | The time, in seconds, that the browser should remember that this site is only to be accessed using HTTPS. | | `includeSubDomains` | If this optional parameter is specified, this rule applies to all of the site’s subdomains as well. | | `preload` | If this optional parameter is specified, it instructs the browser to always access the site using HTTPS because the site is included into `Strict-Transport-Security` [preload list](https://www.chromium.org/hsts/). | ### Example ``` Strict-Transport-Security: max-age=63072000 ``` ``` Strict-Transport-Security: max-age=63072000 ; includeSubDomains ``` ``` Strict-Transport-Security: max-age=63072000 ; includeSubDomains ; preload ``` ### References - [https://tools.ietf.org/html/rfc6797](https://tools.ietf.org/html/rfc6797) - [https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Strict_Transport_Security_Cheat_Sheet.html](https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Strict_Transport_Security_Cheat_Sheet.html) - [https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management_Testing/07-Test_HTTP_Strict_Transport_Security.html](https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management_Testing/07-Test_HTTP_Strict_Transport_Security.html) - [https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security) - [https://www.chromium.org/hsts](https://www.chromium.org/hsts) - [https://hstspreload.org/](https://hstspreload.org/) - [https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security](https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security) - [https://raymii.org/s/tutorials/HTTP_Strict_Transport_Security_for_Apache_NGINX_and_Lighttpd.html](https://raymii.org/s/tutorials/HTTP_Strict_Transport_Security_for_Apache_NGINX_and_Lighttpd.html) - [https://blogs.windows.com/msedgedev/2015/06/09/http-strict-transport-security-comes-to-internet-explorer-11-on-windows-8-1-and-windows-7/](https://blogs.windows.com/msedgedev/2015/06/09/http-strict-transport-security-comes-to-internet-explorer-11-on-windows-8-1-and-windows-7/) ## X-Frame-Options The `X-Frame-Options` response header (also named **XFO**) improves the protection of web applications against [clickjacking](https://portswigger.net/web-security/clickjacking). It instructs the browser whether the content can be displayed within frames. The Content-Security-Policy (CSP) [frame-ancestors](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors) directive obsoletes the X-Frame-Options header. If a resource has both policies, the CSP frame-ancestors policy will be enforced and the X-Frame-Options policy will be ignored. ### Values | Value | Description | | --- | --- | | `deny` | No rendering within a frame. | | `sameorigin` | No rendering if origin mismatch. | | `allow-from: DOMAIN` | Allows rendering if framed by frame loaded from *DOMAIN* (**not supported by modern browsers**). | ### Example ``` X-Frame-Options: deny ``` ### References - [https://tools.ietf.org/html/rfc7034](https://tools.ietf.org/html/rfc7034) - [https://tools.ietf.org/html/draft-ietf-websec-x-frame-options-01](https://tools.ietf.org/html/draft-ietf-websec-x-frame-options-01) - [https://tools.ietf.org/html/draft-ietf-websec-frame-options-00](https://tools.ietf.org/html/draft-ietf-websec-frame-options-00) - [https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options) - [https://portswigger.net/web-security/clickjacking](https://portswigger.net/web-security/clickjacking) - [https://blogs.msdn.microsoft.com/ieinternals/2010/03/30/combating-clickjacking-with-x-frame-options/](https://blogs.msdn.microsoft.com/ieinternals/2010/03/30/combating-clickjacking-with-x-frame-options/) - [https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors) ## X-Content-Type-Options Setting this header will prevent the browser from interpreting files as a different MIME type to what is specified in the `Content-Type` HTTP header (e.g. treating `text/plain` as `text/css`). ### Values | Value | Description | | --- | --- | | `nosniff` | Will prevent the browser from MIME-sniffing a response away from the declared content-type. | ### Example ``` X-Content-Type-Options: nosniff ``` ### References - [https://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx](https://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx) - [https://blogs.msdn.microsoft.com/ie/2008/09/02/ie8-security-part-vi-beta-2-update/](https://blogs.msdn.microsoft.com/ie/2008/09/02/ie8-security-part-vi-beta-2-update/) - [https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options) ## Content-Security-Policy A Content Security Policy (also named CSP) requires careful tuning and testing after definition of the policy. A content security policy can have a significant impact on the way browsers render pages (e.g., inline JavaScript or CSS can be disabled). A proper CSP can prevent a wide range of attacks, including cross-site scripting, other cross-site injections and clickjacking. ### Values 💡 Source used was [Mozilla MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy#directives). The values below are an overview of available directives, for an exhaustive list please consult the dedicated [Mozilla MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy#directives) section. | Directive | Description | | --- | --- | | `base-uri` | Define the base URI for relative URIs. | | `default-src` | Define loading policy for all resources type in case a resource type’s dedicated directive is not defined (fallback). | | `script-src` | Define which scripts the protected resource can execute. | | `object-src` | Define from where the protected resource can load plugins. | | `style-src` | Define which styles (CSS) can be applied to the protected resource. | | `img-src` | Define from where the protected resource can load images. | | `media-src` | Define from where the protected resource can load video and audio. | | `frame-src` | *(Deprecated and replaced by `child-src`)* Define from where the protected resource can embed frames. | | `child-src` | Define from where the protected resource can embed frames. | | `frame-ancestors` | Define from where the protected resource can be embedded in frames. Useful against [clickjacking](https://portswigger.net/web-security/clickjacking) | | `font-src` | Define from where the protected resource can load fonts. | | `connect-src` | Define which URIs the protected resource can load using script interfaces. | | `manifest-src` | Define from where the protected resource can load manifests. | | `form-action` | Define which URIs can be used as the action of HTML form elements. | | `sandbox` | Specifies an HTML sandbox policy that the user agent applies to the protected resource. | | `block-all-mixed-content` | *(Deprecated)* Prevent the user agent from loading mixed content. | | `upgrade-insecure-requests` | Instruct the user agent to use HTTPS when trying to download insecure HTTP resources. | | `referrer` | *(Deprecated)* Define information the user agent can send in the `Referer` header. | | `report-uri` | *(Deprecated and replaced by `report-to`)* Specifies a URI to which the user agent sends reports about policy violation. | | `report-to` | Specifies a group (defined in the `Report-To` header) to which the user agent sends reports about policy violation. | | `require-trusted-types-for` | Instructs user agents to control the data passed to [DOM XSS](https://portswigger.net/web-security/cross-site-scripting/dom-based) **sink** functions. | | `trusted-types` | Specify an allowlist of [Trusted Type policy names](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) that a website can create using `trustedTypes.createPolicy()`. | ### Example ``` Content-Security-Policy: script-src 'self' ``` ### Trusted Types feature [Trusted Types](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) is a security feature in the [Content-Security-Policy](https://developer.mozilla.org/en-US/docs/Web/Security/CSP) header that stops the browser from accepting plain strings in *dangerous functions* (called **sinks**) like `.innerHTML` or `eval()`. Instead, it forces usage of **Trusted Type** objects that have been vetted by a defined policy. Browsers support level ([source](https://caniuse.com/trusted-types)): - Supported by default in Chromium based browsers. - Supported by default in Safari. - Supported by Firefox in its *Nightly* version. Below is an example of definition of a **default Trusted Types policy** leveraging [DOMPurify](https://github.com/cure53/DOMPurify) for the sanitization processing: 📋 `Content-Security-Policy` policy specifying **Trusted Types** via `require-trusted-types-for` and `trusted-types` directives. ``` default-src 'self'; form-action 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; require-trusted-types-for 'script'; trusted-types default dompurify; ``` 🔒 Script defining the **Trusted Types policy** (file named `defineDefaultTrustedTypesPolicy.js`): ``` if (window.trustedTypes && window.trustedTypes.createPolicy) { // Create the default policy and leverage DOMPurify to sanitize any HTML content created trustedTypes.createPolicy("default", { createHTML: (unsafeValue) => { console.info("Default trusted types policy used."); return DOMPurify.sanitize(unsafeValue); } // Functions createScript() and createScriptURL() implementation are missing here as it is a simple example // See https://developer.mozilla.org/en-US/docs/Web/API/TrustedTypePolicyFactory/createPolicy }); } else { console.warn("Trusted types not supported!"); } ``` 🐞 Script defining the dangerous behavior (file named `dangerousCode.js`): ``` const input = document.getElementById("userInput"); const display = document.getElementById("display"); const button = document.getElementById("renderBtn"); button.addEventListener("click", () => { const rawValue = input.value; try { display.innerHTML = rawValue; } catch (e) { display.innerText = "Blocked by Trusted Types! Check the console."; console.error(e); } }); ``` 📜 Test HTML page using elements above: ``` Sample
``` 🔬 Execution into Chromium: Below is an example of definition of a **custom Trusted Types policy** leveraging [DOMPurify](https://github.com/cure53/DOMPurify) for the sanitization processing, both used in a function intended to centralize the loading of unsafe content from a remote location: 📋 `Content-Security-Policy` policy specifying **Trusted Types** via `require-trusted-types-for` and `trusted-types` directives. ``` default-src 'self'; form-action 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; require-trusted-types-for 'script'; trusted-types content_loader dompurify; ``` 🔒 Script defining the **Trusted Types policy** as well as the content loading function (file named `defineContentLoader.js`): ``` // Made the function globally available let loadContent = null; if (window.trustedTypes && window.trustedTypes.createPolicy) { // Create the policy and leverage DOMPurify to sanitize any HTML content created const contentLoaderTrustedPolicy = trustedTypes.createPolicy("content_loader", { createHTML: (unsafeValue) => { console.info("'content_loader' trusted types policy used."); return DOMPurify.sanitize(unsafeValue); } // createScript() and createScriptURL() functions implementation are missing here as it is a simple example // See https://developer.mozilla.org/en-US/docs/Web/API/TrustedTypePolicyFactory/createPolicy }); // Create the content loading function using the Trusted Types policy created loadContent = function (apiPath, uiComponent) { fetch(apiPath).then(response => response.text()).then(response => { uiComponent.innerHTML = contentLoaderTrustedPolicy.createHTML(response); }); }; } else { console.warn("Trusted types not supported!"); } ``` 🐞 Script defining the dangerous behavior (file named `dangerousCode.js`): ``` /* The content of the file "unsafe.txt" is: Hello Dominique! */ loadContent("/unsafe.txt", document.getElementById("display")); ``` 📜 Test HTML page using elements above: ``` TEST
``` 🔬 Execution into Chromium: ### References - [https://www.w3.org/TR/CSP/](https://www.w3.org/TR/CSP/) - [https://developer.mozilla.org/en-US/docs/Web/Security/CSP](https://developer.mozilla.org/en-US/docs/Web/Security/CSP) - [https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html](https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html) - [https://scotthelme.co.uk/content-security-policy-an-introduction/](https://scotthelme.co.uk/content-security-policy-an-introduction/) - [https://report-uri.io](https://report-uri.io) - [https://content-security-policy.com](https://content-security-policy.com) - [https://report-uri.com/home/generate](https://report-uri.com/home/generate) - [https://csp-evaluator.withgoogle.com/](https://csp-evaluator.withgoogle.com/) - [https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) - [https://www.w3.org/TR/trusted-types/](https://www.w3.org/TR/trusted-types/) - [https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/require-trusted-types-for](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/require-trusted-types-for) - [https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/trusted-types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/trusted-types) - [https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API#the_default_policy](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API#the_default_policy) - [https://eiv.dev/trusted-types/](https://eiv.dev/trusted-types/) - [https://caniuse.com/trusted-types](https://caniuse.com/trusted-types) - [https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API#injection_sink_interfaces](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API#injection_sink_interfaces) ## X-Permitted-Cross-Domain-Policies A cross-domain policy file is an XML document that grants a web client, such as Adobe Flash Player or Adobe Acrobat (though not necessarily limited to these), permission to handle data across domains. When clients request content hosted on a particular source domain and that content makes requests directed towards a domain other than its own, the remote domain needs to host a cross-domain policy file that grants access to the source domain, allowing the client to continue the transaction. Normally a meta-policy is declared in the master policy file, but for those who can’t write to the root directory, they can also declare a meta-policy using the `X-Permitted-Cross-Domain-Policies` HTTP response header. ### Values | Value | Description | | --- | --- | | `none` | No policy files are allowed anywhere on the target server, including this master policy file. | | `master-only` | Only this master policy file is allowed. | | `by-content-type` | [HTTP/HTTPS only] Only policy files served with Content-Type: text/x-cross-domain-policy are allowed. | | `by-ftp-filename` | [FTP only] Only policy files whose file names are crossdomain.xml (i.e. URLs ending in /crossdomain.xml) are allowed. | | `all` | All policy files on this target domain are allowed. | ### Example ``` X-Permitted-Cross-Domain-Policies: none ``` ### References - [https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/xdomain.html](https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/xdomain.html) ## Referrer-Policy The `Referrer-Policy` HTTP header governs which referrer information, sent in the `Referer` header, should be included with requests made. ### Values | Value | Description | | --- | --- | | `no-referrer` | The `Referer` header will be omitted entirely. No referrer information is sent along with requests. | | `no-referrer-when-downgrade` | This is the user agent’s default behavior if no policy is specified. The origin is sent as referrer to an a-priori as-secure destination (HTTPS → HTTPS), but isn’t sent to a less secure destination (HTTPS → HTTP). | | `origin` | Only send the origin of the document as the referrer in all cases. (e.g. the document `https://example.com/page.html` will send the referrer `https://example.com/`.) | | `origin-when-cross-origin` | Send a full URL when performing a same-origin request, but only send the origin of the document for other cases. | | `same-origin` | A referrer will be sent for same-site origins, but cross-origin requests will contain no referrer information. | | `strict-origin` | Only send the origin of the document as the referrer to an a-priori as-secure destination (HTTPS → HTTPS), but don’t send it to a less secure destination (HTTPS → HTTP). | | `strict-origin-when-cross-origin` | Send a full URL when performing a same-origin request, only send the origin of the document to an a-priori as-secure destination (HTTPS → HTTPS), and send no header to a less secure destination (HTTPS → HTTP). | | `unsafe-url` | Send a full URL (stripped from parameters) when performing a same-origin or cross-origin request. | ### Example ``` Referrer-Policy: no-referrer ``` ### References - [https://www.w3.org/TR/referrer-policy/](https://www.w3.org/TR/referrer-policy/) - [https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy) ## Clear-Site-Data The Clear-Site-Data header clears browsing data associated with the requesting website. It allows web developers to have more control over the data stored locally by a browser for their origins (source [Mozilla MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data)). This header is useful, for example, during a logout process, in order to ensure that all stored content on the client side like cookies, storage and cache are removed. ### Values | Value | Experimental? | Description | | --- | --- | --- | | `"cache"` | No | Indicates that the server wishes to remove locally cached data for the origin of the response URL. | | `"cookies"` | No | Indicates that the server wishes to remove all cookies for the origin of the response URL. HTTP authentication credentials are also cleared out. This affects the entire registered domain, including subdomains. | | `"storage"` | No | Indicates that the server wishes to remove all DOM storage for the origin of the response URL. | | `"executionContexts"` | Yes | Indicates that the server wishes to reload all browsing contexts for the origin of the response. | | `"prefetchCache"` | Yes | Indicates that the server wishes to remove all [speculation rules](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API) prefetches that are scoped to the referrer origin. | | `"prerenderCache"` | Yes | Indicates that the server wishes to remove all [speculation rules](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API) prerenders that are scoped to the referrer origin. | | `"clientHints"` | Yes | Indicates that the server wishes to remove all [client hints](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Client_hints) (requested via [Accept-CH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Accept-CH)) stored for the origin of the response URL. | | `"*"` | No | Indicates that the server wishes to clear all types of data for the origin of the response. | ### Example ``` Clear-Site-Data: "cache","cookies","storage" ``` ### References - [https://w3c.github.io/webappsec-clear-site-data/](https://w3c.github.io/webappsec-clear-site-data/) - [https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data) - [https://www.chromestatus.com/feature/4713262029471744](https://www.chromestatus.com/feature/4713262029471744) - [https://github.com/w3c/webappsec-clear-site-data](https://github.com/w3c/webappsec-clear-site-data) - [https://github.com/w3c/webappsec-clear-site-data/tree/master/demo](https://github.com/w3c/webappsec-clear-site-data/tree/master/demo) ## Cross-Origin-Resource-Policy This response header (also named CORP) allows one to define a policy that lets web sites and applications opt in to protection against certain requests from other origins (such as those issued with elements like `