How to Choose Security Response Headers and Verify Them After Deployment
Security response headers are HTTP response metadata through which a web server tells a browser which security rules to apply to a response. HSTS makes a browser remember to use HTTPS, `nosniff` prevents MIME-type guessing, and `Referrer-Policy` and `Permissions-Policy` limit, respectively, information sent to other sites and browser features available to documents. There is no universal header list to copy onto every site: choose policies for the service’s features and domain structure, then verify the responses users actually receive.
Each header addresses a different problem
Headers are sent with server responses and are applied when a browser displays that response or handles its subresources. The values below are starting examples, not a set to copy blindly. CSP and frame embedding need their own rollout plans, so this guide only clarifies their place in the wider set.
| Header | Rule communicated to the browser | Starting point and caution |
|---|---|---|
Strict-Transport-Security (HSTS) | The browser remembers to connect to the host only over HTTPS. | Start with a short max-age; increase it after checking HTTPS and certificate operations. Add includeSubDomains only when every subdomain supports HTTPS. |
X-Content-Type-Options | Do not guess or change the MIME type declared for a response. | Set nosniff and send the right Content-Type for every resource. A script or stylesheet served with the wrong type may be blocked. |
Referrer-Policy | Decide how much information to send in Referer when navigating or requesting a subresource. | A common starting point is strict-origin-when-cross-origin. Same-origin requests can include path and query; cross-origin requests generally include only the origin. Avoid putting sensitive values in URLs regardless. |
Permissions-Policy |
These headers provide different protections. HSTS enforces HTTPS but does not authenticate users or check application permissions. nosniff helps control MIME handling but does not correct an incorrect Content-Type. Referrer-Policy does not block a request, and Permissions-Policy does not replace a user’s browser permission prompt. OWASP’s HTTP header guidance explains these headers as separate controls with separate caveats. OWASP HTTP Headers Cheat Sheet
Expand HSTS only after HTTPS is stable
When a browser receives Strict-Transport-Security in a valid HTTPS response, it remembers that host as HTTPS-only for the max-age period. If a user later enters an http:// address, the browser upgrades it to HTTPS under the stored policy. Browsers ignore an HSTS header delivered over HTTP, so TLS with a valid certificate must work first. RFC 6797, MDN guidance on HSTS configuration
Before deployment, check HTTPS on subdomains and older services, including mail and administration portals. If you immediately set a long max-age and includeSubDomains, a subdomain that still depends on HTTP may become unreachable. HSTS is stored by browsers, so reverting the server setting does not immediately erase a policy already stored by a visitor. Begin with a short duration, observe the result, and increase it only after confirming all subdomains and recovery plans. preload is a separate operational decision to request inclusion in browser preload lists; merely adding that word to a header does not instantly register every browser.
Match privacy and feature restrictions to the service
Referrer-Policy: strict-origin-when-cross-origin can send path and query on same-origin requests, but normally sends only the scheme, host and port (the origin) to another origin. It omits the referrer when an HTTPS page leads to HTTP. This does not make it safe to put login tokens or personal identifiers in URLs. Review what navigation, image and analytics requests, and external payment flows need; choose a policy that sends less information. MDN Referrer-Policy
Permissions-Policy sets an allowlist per browser feature. For embedded frames, the header and the iframe’s allow attribute can both affect the final permission. If an app does not use location, camera or microphone, the following is one possible restriction:
Permissions-Policy: geolocation=(), camera=(), microphone=()This is an example, not a default for every site. Do not disable a feature that a store locator, identity check or other page needs. Inventory which pages and frames use each feature, allow only the necessary origins, and test both successful use and intended blocking in a browser. The header defines an upper bound on origins that may use a feature; site permissions, user consent and iframe allow settings also contribute to the outcome. W3C Permissions Policy, MDN Permissions Policy
Is it enough to attach the same headers to every response?
Response headers are browser policies. Other HTTP clients are not guaranteed to support the same behavior, and headers do not replace API authentication, server-side authorization, SQL parameter binding or output encoding. Error pages, redirects, static files and CDN cache responses may be generated by different layers. Adding a line to a configuration file does not prove that visitors receive it. OWASP Secure Headers Project
Do not add legacy browser filters such as X-XSS-Protection as a new default. OWASP advises leaving it unset or explicitly disabling it, while using modern CSP and safe output handling. Headers such as COOP, COEP and CORP can affect cross-origin isolation or resource loading; they are not universal defaults. Review actual popup, iframe, third-party script and image dependencies before using them.
Deploy safely and inspect real responses
The following process is for service owners using an approved test environment and endpoints they are authorized to check. Group one policy change with its verification; enabling many restrictions at once makes it harder to identify which one broke a feature.
**List response paths.** Identify the homepage, important HTML pages such as login and checkout, error responses, redirects, static files and responses generated by a CDN.
**Record current responses and features.** Use the browser Network panel or an approved request tool to capture response headers for each URL. List normal features such as frames, camera, location and external resources.
**Choose only needed policies.** Record the protection and failure impact of each header. Review broad settings such as HSTS for subdomains and Permissions-Policy for frames with service owners.
**Deploy in small steps.** Decide whether the application, proxy or CDN attaches the final header; check that duplicate headers do not set conflicting values. Start HSTS with a short duration and do not rush to include subdomains.
**Inspect the actual HTTPS response.** For example, `curl -sS -D - -o /dev/null https://example.com/` prints response headers. `example.com` is a placeholder. Check redirects, the final page and important error paths separately.
**Check browser behavior and regressions.** Use the Console and Network panels to review blocking notices, MIME types, framing, referrers on navigation, and location or camera behavior. If a valid flow is blocked, identify the specific origin or path it needs instead of broadly weakening the policy.
**Record rollback and expiration effects.** Many policies can be reverted through configuration, but a browser may retain HSTS until its stored `max-age` expires. Record the impact that remains after removing a setting and how it will be reapplied.
OWASP’s Web Security Testing Guide recommends checking each actual response for the presence and current value of browser security headers, including empty or overly permissive values. Record the URL, status code, actual header value and observed browser behavior, rather than merely counting header names. OWASP WSTG: Additional Browser Security Controls