Lion Cipher Lab

Restrict browser features with a Permissions-Policy header

Why it matters

Modern browsers expose powerful features to web pages: your location, your camera and microphone, payment sheets, fullscreen, the clipboard. Two things decide whether a page may even ask for them. One is you, the user, clicking Allow on a prompt. The other is the site's own policy, and most sites never set one. That matters because a typical page is not only your code. It embeds third-party widgets in iframes, often with a copy-pasted allow attribute that hands over far more than the widget needs, and it runs third-party scripts in your own document. If any of that code turns hostile, or an…

What you'll learn

Steps in this lab

  1. The vocabulary: powerful features, policy, prompts and origins
  2. Why this header, and not frame-ancestors or the rest of CSP
  3. Set up: save the two-origin lab server
  4. Measure BEFORE: what the embedded widget is allowed to use
  5. Find the real culprit: the allow attribute you pasted
  6. Automate the check: a header validator in stdlib Python
  7. Add the header and measure AFTER (allow attribute left generous)
  8. Delegate exactly one feature, the way a pro does it
  9. Break it on purpose: the old Feature-Policy syntax
  10. Judgment: where the header stops
  11. What you did, and the reflex to keep

Open the full interactive lab →