Document Policy
- Category
- Security
- Type
- New or changed feature
- Status
- In development (Chrome In development)
- Intent stage
- Start prototyping
WPT details: [WPT coming with spec]
Summary
Document Policy is a mechanism to allow documents to configure the web platform on which they operate: restricting certain behaviors or APIs, configuring defaults, or enabling new platform features. It also includes a way for documents to require such restrictions on sub-documents embedded in iframes. (The actual capabilities are intentionally vague here; this is a framework for individual features to be defined in, rather than being a set of concrete features itself)
Motivation
Currently, it is not possible to restrict the surface area of the web platform on a per-document basis; Iframe sandboxing goes part of the way to help with this, but is difficult to extend, and has strict security-focused semantics. We would like to enable such ideas as: - Restricting the use of poorly-performing images - Disabling slow synchronous JS APIs - Configuring frame, image or script loading styles - Restricting overall document sizes or network usage - Restricting patterns which cause slow page re-layout among other things. These restrictions should be opt-in by developers, and do not necessarily need to extend to a frame's embedded content or popups. Feature policy has been proposed a number of times as a mechanism for accomplishing this, but the existing feature policy spec is not particularly well suited to it, as it has focused strongly on the "delegating powerful features to third parties" model. In particular, the syntax is designed around boolean feature states, and the processing model expects that frames cannot ever be configured independently of their embedders. Previous attempts to graft these ideas on to feature policy have resulted in a spec which is much harder to reason about, and more complex to implement and use, than having two distinct mechanisms. (see, for example, https://github.com/w3c/webappsec-feature-policy/issues/163, and https://github.com/w3c/webappsec-feature-policy/issues/252)
Standards & signals
- Specification: https://wicg.github.io/document-policy/
- Firefox: No signal — Mozilla has been involved in many of the discussions that have led to this proposal; see https://github.com/w3c/webappsec-feature-policy/issues/282#issuecomment-486267212 for instance, and has been generally supportive of the idea. This is not a public stance on a particular spec yet, though.
- Safari: No signal
- Web developers: No signals
- Tracking bug: https://bugs.chromium.org/p/chromium/issues/detail?id=993790
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=document-policy
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Document%20Policy
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Document%20Policy
- Baseline status: https://webstatus.dev/?q=Document%20Policy
Explainers: https://github.com/w3c/webappsec-feature-policy/blob/master/document-policy-explainer.md