Skip to content

Lesson 6 of 9 · 20m

Permissions-Policy, Referrer-Policy, and the Small Headers That Matter

Shrink browser capability surface, control referrer leakage, stop clickjacking consistently, and avoid copy-pasted legacy header cargo cults.

Security headers have a cargo-cult problem: people paste nine lines into nginx, half obsolete, and feel done. The useful small headers are capability decisions. What may this document ask the browser to do, what information may it leak, and who is allowed to frame it?

Permissions-Policy is least privilege for browser features

Permissions-Policy: camera=(), microphone=(), geolocation=(self), payment=(self), usb=(), browsing-topics=()

The syntax is feature-specific and easy to misread. geolocation=(self) permits your origin; camera=() denies it for everyone, including you. An iframe can receive a narrower grant through its allow attribute:

<iframe src="https://video.vendor.example/embed/123"
        allow="encrypted-media; fullscreen"
        allowfullscreen></iframe>

The document policy is the ceiling. An iframe allow attribute cannot widen beyond what the embedding document permits. Use this to stop third-party widgets from quietly acquiring powerful capabilities.

Referrer-Policy is data minimization

Referrer-Policy: strict-origin-when-cross-origin

That modern default-ish posture sends the full URL same-origin, but only the origin cross-origin, and nothing when downgrading from HTTPS to HTTP. URL paths routinely contain tokens, user names, search terms, and object IDs. Once a third-party analytics request fires, your carefully avoided server logs are irrelevant — the path already leaked.

If specific partner integrations need a full referrer, use a per-link or per-request referrerpolicy decision rather than weakening the site globally.

The clickjacking pair

Content-Security-Policy: frame-ancestors 'self'
X-Frame-Options: SAMEORIGIN

frame-ancestors is the modern control. X-Frame-Options remains as a compatibility fallback for older browsers. They do not use identical syntax or matching rules; test your actual framing requirements rather than assuming they are interchangeable. If your app must be embedded by a partner, enumerate that partner in CSP.

Headers that mostly became noise

X-XSS-Protection is obsolete and can create vulnerabilities in old implementations; omit it. X-Content-Type-Options: nosniff is still worthwhile because MIME confusion attacks are real:

X-Content-Type-Options: nosniff

Expect-CT is dead. Public-key pinning is dead for good operational reasons. Do not resurrect either because a scanner template from 2017 says they are missing.

Field notes

  • Feature names change. Verify Permissions-Policy syntax in current browser documentation before copying examples.
  • A feature disabled by policy can still appear enabled in JavaScript feature detection; permission state and capability are separate questions.
  • Referrer reduction can break anti-CSRF heuristics or partner attribution that secretly depended on full URLs. Prefer explicit state and signed parameters.
  • nosniff can expose bad server configuration: JavaScript served as text/plain will stop executing, which is the correct failure but still an outage.

Was this lesson helpful?

Sign in to rate