OWASP Secure Headers
OWASP Secure Headers Project
The OWASP Secure Headers Project describes HTTP response headers that your application can use to increase the security of your application. Once set, these HTTP response headers can restrict modern browsers from running into easily preventable vulnerabilities. The OWASP Secure Headers Project intends to raise awareness and use of these headers.
HTTP headers are well known and also despised. Seeking the balance between usability and security developers implement functionality through the headers that can make your more versatile or secure application. But in practice how the headers are being implemented? What sites follow the best implementation practices? Big companies, small, all or none?
We aim to publish reports on header usage stats, developments and changes. Code libraries that make these headers easily accessible to developers on a range of platforms. Data sets concerning the general usage of these headers.
OWASP Secure Headers is free to use. It is licensed under the Apache 2.0 License.
Put whatever you like here: news, screenshots, features, supporters, or remove this file and don’t use tabs at all.
- HTTP Strict Transport Security (HSTS)
- Public Key Pinning Extension for HTTP (HPKP)
HTTP Strict Transport Security (HSTS)
HTTP Strict Transport Security (HSTS) is a web 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 never via the insecure HTTP protocol. HSTS is an IETF standards track protocol and is specified in RFC 6797. A server implements an HSTS policy by supplying a header (Strict-Transport-Security) over an HTTPS connection (HSTS headers over HTTP are ignored).
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. Example Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Public Key Pinning Extension for HTTP (HPKP)
HTTP Public Key Pinning (HPKP) is a security mechanism which allows HTTPS websites to resist impersonation by attackers using mis-issued or otherwise fraudulent certificates. (For example, sometimes attackers can compromise certificate authorities, and then can mis-issue certificates for a web origin.).
The HTTPS web server serves a list of public key hashes, and on subsequent connections clients expect that server to use one or more of those public keys in its certificate chain. Deploying HPKP safely will require operational and organizational maturity due to the risk that hosts may make themselves unavailable by pinning to a set of public key hashes that becomes invalid. With care, host operators can greatly reduce the risk of man-in-the-middle (MITM) attacks and other false authentication problems for their users without incurring undue risk.
Before implement HPKP please read this https://www.chromestatus.com/feature/5903385005916160.
X-Frame-Options response header improve the protection of web applications against Clickjacking. It declares a policy communicated from a host to the client browser on whether the browser must not display the transmitted content in frames of other web pages.
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. Example X-Frame-Options: deny
This header enables the Cross-site scripting (XSS) filter in your browser.
Values Value Description 0 Filter disabled. 1 Filter enabled. If a cross-site scripting attack is detected, in order to stop the attack, the browser will sanitize the page. 1; mode=block Filter enabled. Rather than sanitize the page, when a XSS attack is detected, the browser will prevent rendering of the page. 1; report=http://[YOURDOMAIN]/your_report_URI Filter enabled. The browser will sanitize the page and report the violation. This is a Chromium function utilizing CSP violation reports to send details to a URI of your choice. Example X-XSS-Protection: 1; mode=block
Setting this header will prevent the browser from interpreting files as something else than declared by the content type in the HTTP headers.
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
Values Directive Description base-uri Define the base uri for relative uri. default-src Define loading policy for all resources type in case of a resource type 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) the user applies 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. 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 manifest. 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. script-nonce Define script execution by requiring the presence of the specified nonce on script elements. plugin-types Define the set of plugins that can be invoked by the protected resource by limiting the types of resources that can be embedded. reflected-xss Instructs a user agent to activate or deactivate any heuristics used to filter or block reflected cross-site scripting attacks, equivalent to the effects of the non-standard X-XSS-Protection header. block-all-mixed-content Prevent user agent from loading mixed content. upgrade-insecure-requests Instructs user agent to download insecure resources using HTTPS. referrer Define information user agent must send in Referer header. report-uri Specifies a URI to which the user agent sends reports about policy violation. report-to Specifies a group (defined in Report-To header) to which the user agent sends reports about policy violation. Example Content-Security-Policy: script-src ‘self’
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 make 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
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 a-priori as-much-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. 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 a-priori as-much-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 a-priori as-much-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 a same-origin or cross-origin request. Example Referrer-Policy: no-referrer
The Expect-CT header is used by a server to indicate that browsers should evaluate connections to the host emitting the header for Certificate Transparency compliance.
Values Value Description report-uri The optional report-uri directive indicates the URL to which the browser should report Expect-CT failures. enforce The optional enforce directive is a valueless directive that, if present, signals to the browser that compliance to the CT Policy should be enforced (rather than report-only) and that the browser should refuse future connections that violate its CT Policy. When both the enforce directive and report-uri directive are present, the configuration is referred to as an “enforce-and-report” configuration, signalling to the browser both that compliance to the CT Policy should be enforced and that violations should be reported. max-age The max-age directive specifies the number of seconds after the reception of the Expect-CT header field during which the browser should regard the host from whom the message was received as a Known Expect-CT Host. Example Expect-CT: max-age=86400, enforce, report-uri=”https://foo.example/report”
The Feature-Policy header allows developers to selectively enable and disable use of various browser features and APIs..
Values Value Description accelerometer Controls access to accelerometer sensors on the device. ambient-light-sensor Controls access to ambient light sensors on the device. autoplay Controls access to autoplay through play() and autoplay. camera Controls access to video input devices. encrypted-media Controls whether requestMediaKeySystemAccess() is allowed. fullscreen Controls whether requestFullscreen() is allowed. geolocation Controls access to Geolocation interface. gyroscope Controls access to gyroscope sensors on the device. magnetometer Controls access to magnetometer sensors on the device. microphone Controls access to audio input devices. midi Controls access to requestMIDIAccess() method. payment Controls access to PaymentRequest interface. picture-in-picture Controls access to Picture in Picture. speaker Controls access to audio output devices. usb Controls access to USB devices. vibrate Controls access to vibrate() method. vr Controls access to VR displays. Example Feature-Policy: vibrate ‘none’; geolocation ‘none’