All notes

Security Headers Are Capability Decisions

Choose transport, embedding and isolation policies from the site requirements, then test compatibility.

English edition, edited for length. Read the complete Chinese original.

“Copying a set of ‘perfect security headers’ has resulted in video embedding failing, third-party font loading errors, and a subdomain that can no longer be accessed via HTTP. Changes to security response headers affect browser capabilities and trust boundaries, and cannot be solely based on scores from scanning tools.”

This article uses a technology blog as an example, distinguishing between universally beneficial constraints and isolation capabilities that require business preparation. Browser support, platform configuration, and specific values should be verified against the current document, and examples should not be treated as the default policy for all websites.

Associate each strategy with website capabilities

A typical technical blog requires reading, searching, and external links, but does not necessarily need a camera or cross-origin isolation. First, identify the actual capabilities, then determine the corresponding strategies and compatibility testing. A scanning tool that identifies a missing header can trigger an evaluation, but cannot automatically determine the risk level. A dedicated header is important for applications that require advanced browser functionality, but may only add compatibility responsibilities for completely static articles.

The strategy list should at least specify the purpose, scope of action, dependencies, and recovery methods. Content sniffing should be limited to the correct type, and HSTS should rely on continuous HTTPS. Embedding should rely on the need for collaboration. Cross-origin isolation should rely on all resources and the preparation of the pop-up process. By saving these prerequisites, you can know in the future which strategies need to be reviewed when adding login or video. Security configurations should not be mysterious strings that no one dares to change.

First, block unnecessary content sniffing

X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin

nosniff requires that resources use the correct media type and cannot rely on the browser to guess the type of an invalid file as a script or stylesheet. Before deployment, it’s essential to verify the Content-Type of JavaScript, CSS, fonts, and downloaded files. Incorrect resource headers will be exposed under strict policies.

Referrer-Policy controls how much source information is passed along with redirects and resource requests. Cross-origin requests should only send the origin, which can reduce the risk of path and query leakage. However, sensitive parameters should never be included in public URLs. The Privacy header is an addition, not a justification for continuing to put tokens in the address bar.

nosniff does not correct incorrect MIME types to the correct values; instead, it makes certain errors more apparent. When a deployment platform reverts missing JavaScript paths to the homepage HTML, the browser may prevent execution, which typically reveals routing or resource publishing errors. It is not advisable to remove headers to conceal these issues. Checking the script, styles, fonts, and the actual response, a status code of 200 does not guarantee that the type is valid. Version releases and error pages also require media type contracts.

Referrer-Policy reduces cross-origin path exposure, but external link parameters can still be manually copied or saved in logs by users. The token prevents the public URL from being exposed, which is a form of protection. Internal redirects, cross-origin images, and HTTPS connections to insecure addresses can be observed by a controlled receiving end, without relying on guesswork to determine the exact amount being transferred. Browser and element-level policies can influence the results, and actual deployment and testing are necessary for reliable results.

Achieving HSTS requires time and careful planning.

HSTS (HTTP Strict Transport Security) instructs the browser to use HTTPS for a specified period. Initially, verify that the root domain is reliably available, then begin with a short, controlled period and gradually extend it. The includeSubDomains directive expands the restrictions to include subdomains. This requires reviewing email web entry points, legacy services, and third-party hosting names.

“Preload” represents a longer-term commitment. It involves separate processes for adding and removing, and should not be enabled arbitrarily for the sake of scoring. Considerations must be given to certificate renewals, domain transfers, and emergency recovery. Once the browser remembers the policy, the server-side removal of the header will not immediately cause the client to forget.

Once the browser has remembered the expiration date, the server will no longer send the policy, and HTTP access will not immediately resume. Reducing or clearing policies still requires the client to see the corresponding security response, and the pre-loaded list also has an update cycle. Before going live, confirm domain renewal, certificate renewal, and sub-domain ownership. A long-term commitment implies operational responsibility. A short-term trial run should first cover the main host, and then decide whether to expand all sub-domains, without directly entering the longest period.

The includeSubDomains directive operates at the host level, and third-party subdomains may also be affected. The key is to ensure continued HTTPS access, not just the current website’s homepage. Old test services, historical redirects, and outsourced control panels should also be checked. If a subdomain cannot be supported, adjust the architecture or temporarily scale it back, rather than letting users encounter accessibility issues before discovering the scope is too broad.

Preloading is intended for long-term deployment and should not be treated as a simple toggle switch. Meeting the joining criteria does not necessarily mean that the business is ready, and exiting does not guarantee that all older browsers will immediately update. Risk decisions should be made by the domain owner, and the purpose of configuration changes is to verify. For personal blogs, it is often more practical to first ensure stable HTTPS and limited HSTS.

Specific Capabilities of Cross-Source Isolation Services

COOP and COEP can establish cross-origin isolation, supporting certain advanced browser capabilities, while also changing the relationship between pop-ups and resource loading requirements. However, a standard static content website may not require these capabilities. Blindly enabling them, especially when relying on third-party embedding, login pop-ups, or images without properly configured resource headers, can disrupt the workflow.

First, determine the intended use, and then review each resource to ensure it meets the requirements. CORP, CORS, and COEP each have distinct functions and should not be treated as the same switch. Test login, payment, video, and image functionality, and do not limit the review to just the homepage control panel.

COOP affects the relationship between the top-level window and the opened window, and the login popup may rely on communication. COEP affects the cross-origin policies that embedded resources must satisfy. CORP and CORS express different resource access controls. Similar names do not imply interchangeability. When choosing a specific mode, consult the browser’s support and official documentation, and do not enable all values simultaneously.

If the application requires capabilities like SharedArrayBuffer, then treat isolation as a clear architectural requirement. Carefully review fonts, images, frameworks, workers, and external scripts. If third-party services cannot provide the necessary headers, alternative services or sandboxed resources within the same origin may be needed. It is not permissible to proxy all content without explicit authorization. Thoroughly test all user workflows, especially those that occur after clicking the login button or loading off-screen components.

When a standard static site doesn’t require cross-origin isolation, it’s possible to disable it and maintain other meaningful security boundaries. The number of headers is not a linear indicator of security strength. When future needs arise, redesign to avoid incurring actual compatibility losses due to hypothetical features. The goal of security engineering is to clearly define necessary permissions, not to minimize browser capabilities to the absolute minimum.

Embedding strategies must originate from product requirements.

The following restrictions apply:

  • Other websites are not allowed to embed this site. Use appropriate frame-ancestors policies.
  • When embedding from a collaborating website, clearly specify the source.
  • The X-Frame-Options setting must be consistent with the overall CSP policy to avoid conflicting results across different browsers.

Permissions-Policy can restrict capabilities like cameras and microphones, but the available instructions may differ from what browsers support. Blogs do not have these features, and restricting them may be reasonable. If recording tools are added in the future, the policies should be reviewed simultaneously when modifying the functionality, to avoid making security configurations an unexplainable and hidden obstacle.

Deploying Multi-Layer Header Configurations Requires a Central Source

Both the application and the worker, along with the hosting platform, may add or override headers. The final result is determined by the browser’s policy. Repeated CSPs can collectively restrict rather than one overriding the other, and some duplicate header values may be invalid. Verify the actual response and confirm the responsible layer to avoid modifying local configurations that are then overridden by edge rules. Different handlers may be used for the homepage, articles, error pages, and resources, so it’s not possible to derive a complete site-wide policy from a single response.

The header configuration is recorded in a versioned source or explicit operation log, preventing the need to manually revert to the old value after making changes in the console. The preview environment uses limited differences, and during testing, it clarifies which policies are the same as in production. Changes to the security header are reviewed together with changes in functional dependencies. When adding a new microphone feature, the Permissions-Policy should be adjusted simultaneously, rather than having the front-end team repeatedly guess why the permission prompt is not appearing.

The addition of new features such as video, login pop-ups, an online editor, file downloads, and recording functionality can potentially alter the applicability of the original security policy. The PR for these features should list the new sources and browser capabilities, and then confirm the necessary headers and existing tests. Instead of automatically relaxing restrictions, the decision should be based on whether the original boundaries can still be maintained. For example, if a third-party component requires inline execution from any source, a replacement component might be a better solution than expanding the overall permissions.

Policy rollbacks can also be categorized by their function. Modifications to the source can be updated with deployments, but HSTS long-term memory cannot be immediately reverted. Preloading has its own lifecycle. Documenting different recovery methods to avoid the situation where the only option is “delete all headers” during an incident. The last validated policy is a reasonable rollback to the baseline, allowing all capabilities to be in a non-emergency state. Recovery functionality and maintaining protection must be considered together.

Compatibility testing can be divided into categories based on page type: homepage, articles, search, error page, and tool pages with special capabilities. For regular articles, tool pages do not need to be granted full permissions. The deployment rules support using a limited range of strategies. The header not being the same on different pages is not an error; the key is that the reason and the test are clear. File downloads and client-side scripts also have different media type requirements, and the same header cannot be copied for all responses.

Browser support for different features requires honest communication. If a specific Permissions-Policy directive is ineffective in some browsers, it does not mean that all requests are equally restricted. The old X-Frame-Options and new CSP configurations can also produce different results. Choose a mainstream support range and perform real testing, and do not add unverified values to complete the list of directives. The specification and documentation clearly define the capabilities, and project testing confirms the current implementation.

The privacy policy should also check links and resources. The Referrer-Policy restricts the source of information, but does not prevent analysis scripts from reading the current address and uploading it. Permissions-Policy restricts certain browser capabilities, but does not prevent applications from sending existing data over allowed network connections. The protection of headers is limited, and minimizing input and third-party review remain independently necessary. The security instructions should avoid giving users the impression that “all privacy is guaranteed by headers.”

The launch report should concisely list the objectives and evidence for the strategy: successful type checking, HTTPS range verification, unauthorized embedding blocked, necessary pop-ups functioning correctly, and sensitive queries not leaking. The scan score is merely a supplementary observation. If a particular feature is not enabled, record the missing requirement or the reason for incompatibility, and set future review conditions. The ability to explain choices is a better indicator of engineering quality than the number of response headers.

Complete the Browser Capability Checklist for a New Feature

To prepare the site, add a component that allows users to play videos. This component should list the frameworks, scripts, images, target URLs, and pop-up behaviors that it loads, and then compare this against the current policy. The necessary capabilities should come from real-world tasks, not from a list of requirements imposed by a vendor. If standard links already meet the purpose of the article, a narrower policy can be maintained. If embedding is truly required, grant necessary sources on the appropriate pages, and verify that both authorized and unauthorized embedding still comply with the policy.

Another online editor requires advanced shared memory capabilities, and cross-source isolation becomes a practical architectural requirement. All resource and window relationships are involved in the design, not just the COOP and COEP lines. The login pop-up must verify whether it continues to function, whether the font and worker meet the loading conditions, and whether third-party resources can be legally adjusted. Regular articles can retain a separate set of limited policies, and the capabilities of the tool page do not need to expand the entire site.

The checklist should record the purpose, source, controller, applicable page, failure rollback and undo methods for each permission. When removing a feature, delete any unnecessary permissions and run negative samples. Adding new permissions without undoing existing ones will gradually erode the boundaries of the strategy. When deploying a strategy based on page-level permissions, the maintenance costs should also be considered. It is not possible to introduce a rule system with the finest granularity that no one can correctly update.

Verifying Multiple Configurations with a Single Real Response

The application uses CSP, the worker adds another one, and the platform adds an additional security template. The browser receives a combined result, not just one specific text from the repository. Examine the original header set and identify the responsible layer, especially where CSP rules might overlap. Verify whether the test resources are allowed under each policy, and do not assume that a later, more permissive configuration overrides earlier ones. The console may not display a warning if the policy is not actually applied along this path.

The homepage, details page, missing page, and static scripts may be returned by different processors, each sampled independently. When an incorrect script address is encountered during HTML parsing, nosniff prevents the execution of the wrong content type or routing, rather than simply removing the header. To ensure compliance with policy requirements, the actual response must be validated, checking for correct semantics in the 200, redirect, and error status codes. Policy configuration and media type contracts must be maintained together to determine what is actually being protected.

The difference records for preview and production are based on explicit rules, and do not automatically select a broader environment based on any request. Hot updates require an additional source and should not be introduced into production templates. The platform manually controls the synchronization of environment changes to the authoritative configuration or operation records. The next deployment will not silently revert to the old values. Testing should be based on the actual release entry, and the presence of a configuration file is just a starting point.

Long-Term HTTPS Commitment Requires a Host Asset Audit

To enable the root domain with includeSubDomains, first determine whether the old control panel, documentation, historical redirects, and outsourced services can continue to use HTTPS. While the email transport protocol is different from HTTP HSTS, the web hosting for email-related pages may still be affected. When evaluating, consider the actual purpose of each host and avoid drawing conclusions based on only a few DNS records. Old domain redirects also require valid certificates; the browser must first establish a connection before displaying the redirect.

Gradually verify the client range over a limited period, and record the observed ranges. Once the browser remembers HSTS, the server will not immediately forget the header; there are also pre-loading and removal cycles. The incident recovery plan must recognize these persistent effects and not treat “reverting configuration” as an immediate HTTP recovery. Domain renewal, certificate renewal, and transfer of ownership all involve long-term maintenance responsibilities. Scanning scores cannot replace this judgment.

If a subdomain cannot be supported, it’s not about forcing users to ignore certificate errors, but rather about adjusting the service or temporarily scaling back the strategy. The security commitment must be achievable. Choosing a narrower scope and explaining the reasons is more maintainable than frequently removing headers after deploying the broadest strategy. Subsequent changes to assets should trigger a review, and third-party managed relationships are not always stable.

Privacy Headers Do Not Restrict Data Already Owned by Scripts

Referrer-Policy can reduce automatic source information, but analysis scripts can still read the current URL and proactively upload it. Permissions-Policy restricts certain browser capabilities but does not prevent the transmission of existing data on established network connections. Privacy design starts with sensitive parameters, third-party fields, and data usage, and the response headers are just one layer of this. We cannot guarantee users that “once these headers are enabled, there will be no tracking.”

Using a controlled receiving endpoint to observe the actual source of requests (same-origin, cross-origin, and downgraded), the generated URL does not contain real tokens. Element-level policies may differ from the default response, verifying the actual page content rather than just the header name. Business credentials are not exposed publicly, and the expiration or different browser behavior of headers will not lead to credential exposure. Minimizing the source and browser policies complement each other and cannot be replaced by each other.

How to Conduct a Negative Capability Test Without Compromising Real Service

During the isolation preview, unauthorized embedding, error type scripts, and disallowed resources were confirmed to be blocked by the browser. Successful navigation, search, login pop-ups, and legitimate video playback were tested, and the actual task results were saved. The tests did not involve sensitive operations on production accounts, nor were they used to verify microphone restrictions for recording real private speech. The synthetic resources and controlled endpoints were sufficient to observe the policies, and no new anonymous diagnostic interfaces were required.

If a failure occurs, revert to the previous configuration using the mechanism. Standard embedded licenses can restore the previous configuration, but CSP hashes may require synchronization of the output. HSTS long-term memory cannot be immediately removed, and cross-origin isolation changes may require page reloads. Clearly state the limitations of each recovery, and avoid using “delete all headers” as the only emergency action. Necessary functionality recovery and protection should be checked simultaneously, without opening all sources to mask the root cause.

The collaborating party needs to verify the entire ancestry chain, not just a single embedded layer, when granting permission. When a collaborating page is nested from another source, the actual strategy should verify all ancestors according to browser and CSP rules. Replicate with two controlled framework layers, without inserting test accounts from real collaborating parties. The permission expression should represent the complete embedded relationship. The presence of a vendor address on a list does not imply that all nesting scenarios are authorized. To understand why a legitimate component fails on a specific host page, you need to examine the top-level and each layer’s source.

The acceptance report must clearly state the scope of testing.

List browser versions, page types, actual headers, positive and negative samples. Clearly indicate platforms not covered, and do not assume that compliance support is guaranteed for the project. The absence of a specific header may be justifiable, and the presence of a broad header may not provide actual protection. Scanning tools help identify configuration differences, and engineering conclusions are based on the boundaries of capabilities, compatibility, and evidence of recoverability, rather than the number of headers.

Acceptance based on skill verification, not on the number of heads

Establish the matrix: The script should be able to load, resource types should be correct, external link sources should match expectations, the website should not be embeddable without authorization, necessary pop-up processes should function correctly, and the subdomain HTTPS should be complete. Verify this in both major browsers and in a real deployment environment, as the development server may not send the same headers.

Record the responsible person, purpose, risks, and rollback method for each header. While scanning tools can identify missing headers, they cannot determine whether a particular strategy aligns with business requirements. A successful deployment should result in demonstrable boundaries and compatibility, not in increasingly long response headers.

After changing the strategy, it’s still important to monitor the caching paths. First, allow the browser and edge caches to retain the old content. Then, deploy the new headers and access both existing objects and the new page to verify the actual return policies. If the CDN continues to provide old responses, check for invalid and revalidation rules, rather than assuming that the source server configuration has been applied. Check whether caching is being used and the response version in the test records. The time of repository changes does not necessarily mean that all readers have received the new strategy.

References: HTTP Security Response Headers, HSTS, Cross-Origin Isolation.