├── .github └── workflows │ └── auto-publish.yml ├── .gitignore ├── .pr-preview.json ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── document-policy.redirect.html ├── features.md ├── index.bs ├── integration.md ├── permissions-policy-client-hints.md ├── permissions-policy-explainer.md ├── policies ├── README.md ├── animations.md ├── decoding-image-default-sync.md ├── document-write.md ├── focus-without-user-activation.md ├── font-display-late-swap.md ├── loading-frame-default-eager.md ├── loading-image-default-eager.md ├── optimized-images.md ├── resources │ ├── image-compression-disabled.png │ ├── image-compression-enabled.png │ ├── legacy-image-formats-disabled.png │ ├── legacy-image-formats-enabled.png │ ├── max-ds-img-disabled0.png │ ├── max-ds-img-disabled1.png │ ├── max-ds-img-disabled2.png │ ├── max-ds-img-enabled0.png │ ├── max-ds-img-enabled1.png │ ├── max-ds-img-enabled2.png │ ├── unoptimized-disabled.png │ ├── unoptimized-enabled.png │ ├── unsized-media-disabled1.png │ ├── unsized-media-disabled2.png │ ├── unsized-media-enabled1.png │ ├── unsized-media-enabled2.png │ └── unsized-media-example0.png ├── unsized-media.md └── vertical_scroll.md ├── reporting.md ├── sandbox.md ├── security-privacy-questionnaire-document-policies.md ├── security-privacy-questionnaire-introspection.md ├── security-privacy-questionnaire-reporting.md ├── security-privacy-questionnaire-sandbox.md ├── security-privacy-questionnaire.md ├── tidyconfig.txt └── w3c.json /.github/workflows/auto-publish.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | pull_request: {} 4 | push: 5 | branches: [main] 6 | jobs: 7 | main: 8 | name: Build, Validate and Deploy 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | - uses: w3c/spec-prod@v2 13 | with: 14 | GH_PAGES_BRANCH: gh-pages 15 | W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN }} 16 | W3C_WG_DECISION_URL: https://lists.w3.org/Archives/Public/public-webappsec/2015Mar/0170.html 17 | W3C_BUILD_OVERRIDE: | 18 | Status: WD 19 | shortname: permissions-policy 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | index.html 2 | deploy_key 3 | -------------------------------------------------------------------------------- /.pr-preview.json: -------------------------------------------------------------------------------- 1 | { 2 | "src_file": "index.bs", 3 | "type": "bikeshed" 4 | } 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Web Platform Incubator Community Group 2 | 3 | This repository is being used for work in the Web Platform Incubator Community Group, governed by the [W3C Community License 4 | Agreement (CLA)](http://www.w3.org/community/about/agreements/cla/). To contribute, you must join 5 | the CG. 6 | 7 | If you are not the sole contributor to a contribution (pull request), please identify all 8 | contributors in the pull request's body or in subsequent comments. 9 | 10 | To add a contributor (other than yourself, that's automatic), mark them one per line as follows: 11 | 12 | ``` 13 | +@github_username 14 | ``` 15 | 16 | If you added a contributor by mistake, you can remove them in a comment with: 17 | 18 | ``` 19 | -@github_username 20 | ``` 21 | 22 | If you are making a pull request on behalf of someone else but you had no part in designing the 23 | feature, you can remove yourself with the above syntax. 24 | 25 | # Tests 26 | 27 | For normative changes, a corresponding 28 | [web-platform-tests](https://github.com/web-platform-tests/wpt) PR is highly appreciated. Typically, 29 | both PRs will be merged at the same time. Note that a test change that contradicts the spec should 30 | not be merged before the corresponding spec change. If testing is not practical, please explain why 31 | and if appropriate [file a web-platform-tests issue](https://github.com/web-platform-tests/wpt/issues/new) 32 | to follow up later. Add the `type:untestable` or `type:missing-coverage` label as appropriate. 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | All Reports in this Repository are licensed by Contributors under the 2 | [W3C Software and Document 3 | License](http://www.w3.org/Consortium/Legal/2015/copyright-software-and-document). Contributions to 4 | Specifications are made under the [W3C CLA](https://www.w3.org/community/about/agreements/cla/). 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Permissions Policy (previously named Feature Policy) 2 | 3 | A web platform API which gives a website the ability to allow and deny the use of browser features in its own frame, and in iframes that it embeds. Examples of [features](https://github.com/w3c/webappsec-permissions-policy/blob/master/features.md) that could be controlled by permissions policy include: 4 | 5 | - getUserMedia (Camera, Microphone, and Speaker-selection) 6 | - Fullscreen 7 | - Geolocation 8 | - MIDI 9 | - Payments 10 | - Synchronous XHR 11 | - ... 12 | 13 | See also: [how to integrate a web platform feature with permissions policy](https://github.com/w3c/webappsec-permissions-policy/blob/master/integration.md). 14 | 15 | The Permissions Policy spec is hosted on this repo, at https://w3c.github.io/webappsec-permissions-policy/ 16 | 17 | For more explanation, use cases, examples, etc., please refer to [the explainer document](https://github.com/w3c/webappsec-permissions-policy/blob/master/permissions-policy-explainer.md). 18 | 19 | ## Where is Document Policy? 20 | 21 | Document Policy, which was previously hosted here, has been moved to WICG; it can be found at https://github.com/WICG/document-policy/. 22 | 23 | 24 | Questions, suggestions? Please open an issue or send a pull request! 25 | -------------------------------------------------------------------------------- /document-policy.redirect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
The Document Policy spec, previously hosted at this URL, has moved to WICG. 5 | It can now be found at https://wicg.github.io/document-policy/. 6 | The repository is here 7 | 8 |
This page will automatically redirect to the new location in a few seconds. 9 | -------------------------------------------------------------------------------- /features.md: -------------------------------------------------------------------------------- 1 | # Policy Controlled Features 2 | 3 | This document lists policy-controlled features being implemented in browsers. It 4 | is broken into sections based on the standardization state of each feature. The 5 | names used here should be consistent between browsers implementing a particular 6 | feature, but there is no requirement that all browsers implement any single 7 | feature. 8 | 9 | The exact definition of the behaviour controlled by each feature belongs in the 10 | spec which defines the feature. Those are linked where available. 11 | 12 | ## Standardized Features 13 | 14 | These features have been declared in a published version of the respective 15 | specification. 16 | 17 | | Feature name | Spec link(s) | Browser Support | 18 | | ------------ | ------------ | --------------- | 19 | | `accelerometer` | [Generic Sensor API][generic-sensor] | [Chrome 66](https://www.chromestatus.com/feature/5758486868656128) | 20 | | `ambient-light-sensor` | [Generic Sensor API][generic-sensor] | Behind a flag in Chrome[7](#fn7) | 21 | | `attribution-reporting` | [Attribution Reporting API][attribution-reporting] | [Chrome 115](https://chromestatus.com/feature/6412002824028160) | 22 | | `autoplay` | [HTML][html] | [Chrome 64](https://www.chromestatus.com/feature/5100524789563392) | 23 | | `battery` | [Battery Status API][battery-status] | Status "[Open](https://bugs.chromium.org/p/chromium/issues/detail?id=1007264)" in Chrome | 24 | | `bluetooth` | [Web Bluetooth][bluetooth] | [Chrome 104](https://chromestatus.com/feature/6439287120723968) | 25 | | `camera` | [Media Capture][media-capture] | [Chrome 64](https://www.chromestatus.com/feature/5023919287304192) | 26 | | `ch-ua` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 27 | | `ch-ua-arch` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 28 | | `ch-ua-bitness` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 29 | | `ch-ua-full-version` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 30 | | `ch-ua-full-version-list` | [User-Agent Client Hints][client-hints] | Behind a flag in Chrome[8](#fn8) | 31 | | `ch-ua-high-entropy-values` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 32 | | `ch-ua-mobile` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 33 | | `ch-ua-model` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 34 | | `ch-ua-platform` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 35 | | `ch-ua-platform-version` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 36 | | `ch-ua-wow64` | [User-Agent Client Hints][client-hints] | [Chrome 89](https://chromestatus.com/feature/5995832180473856) | 37 | | `compute-pressure` | [Compute Pressure API][compute-pressure] | [Chrome 125](https://chromestatus.com/feature/5597608644968448) | 38 | | `cross-origin-isolated` | [HTML][html] | Experimental in Chrome 85 | 39 | | `direct-sockets` | [Direct Sockets API][direct-sockets] | | Status "[Started](https://chromestatus.com/feature/6398297361088512)" in Chrome | 40 | | `display-capture` | [Media Capture: Screen Share][media-capture-screen-share] | [Chrome 94](https://chromestatus.com/feature/5144822362931200) | 41 | | `encrypted-media` | [Encrypted Media Extensions][encrypted-media] | [Chrome 64](https://www.chromestatus.com/feature/5023919287304192) | 42 | | `execution-while-not-rendered` | [Page Lifecycle][page-lifecycle] | Behind a flag in Chrome[1](#fn1) | 43 | | `execution-while-out-of-viewport` | [Page Lifecycle][page-lifecycle] | Behind a flag in Chrome[1](#fn1) | 44 | | `fullscreen` | [Fullscreen API][fullscreen] | [Chrome 62](https://www.chromestatus.com/feature/5094837900541952) | 45 | | `geolocation` | [Geolocation API][geolocation] | [Chrome 64](https://www.chromestatus.com/feature/5023919287304192) | 46 | | `gyroscope` |[Generic Sensor API][generic-sensor] | [Chrome 66](https://www.chromestatus.com/feature/5758486868656128) | 47 | | `hid` | [WebHID API][webhid] | [Chrome 89](https://chromestatus.com/feature/5172464636133376) | 48 | | `identity-credentials-get` | [Federated Credential Management API][fedcm] | [Chrome 110](https://chromestatus.com/feature/5162418615877632) | 49 | | `idle-detection` | [Idle Detection API][idle-detection] | [Chrome 94](https://chromestatus.com/feature/4590256452009984) | 50 | | `keyboard-map` | [Keyboard API][keyboard] | [Chrome 97](https://www.chromestatus.com/feature/5657965899022336) | 51 | | `magnetometer` |[Generic Sensor API][generic-sensor] | [Chrome 66](https://www.chromestatus.com/feature/5758486868656128) | 52 | | `mediasession` | [Media Session API][mediasession] | | 53 | | `microphone` |[Media Capture][media-capture] | [Chrome 64](https://www.chromestatus.com/feature/5023919287304192) | 54 | | `midi` | [Web MIDI][web-midi] | [Chrome 64](https://www.chromestatus.com/feature/5023919287304192) | 55 | | `navigation-override` | [CSS Spatial Navigation][navigation-override] | | 56 | | `otp-credentials` | [WebOTP API][otp-credentials] | [Chrome 84](https://chromestatus.com/feature/5873577578463232) | 57 | | `payment` | [Payment Request API][payment-request] | Chrome 60 | 58 | | `picture-in-picture` | [Picture-in-Picture][pip] | [Chrome 71](https://chromestatus.com/feature/5729206566649856) | 59 | | `publickey-credentials-get` | [Web Authentication API][publickey-credentials-get] | [Chrome 84](https://bugs.chromium.org/p/chromium/issues/detail?id=993007) | 60 | | `screen-wake-lock` | [Wake Lock API][wake-lock] | [Chrome 84](https://www.chromestatus.com/feature/4636879949398016) | 61 | | `serial` | [Web Serial API][web-serial] | [Chrome 89](https://chromestatus.com/feature/6577673212002304) | 62 | | `sync-xhr` | [XMLHttpRequest][xhr] | [Chrome 65](https://www.chromestatus.com/feature/5154875084111872) | 63 | | `storage-access` | [Storage Access][storage-access] | [Chrome 115](https://chromestatus.com/feature/5612590694662144) | 64 | | `usb` | [WebUSB][webusb] | Chrome 60 | 65 | | `web-share` | [Web Share API][web-share] | Chrome 86 | 66 | | `window-management`[5](#fn5) | [Window Management API][window-management] | [Chrome 111](https://chromestatus.com/feature/5146352391028736) | 67 | | `xr-spatial-tracking`[2](#fn2) | [WebXR Device API][xr] | [Available as a Chrome Origin Trial](https://developers.chrome.com/origintrials/#/trials/active) | 68 | 69 | ## Proposed Features 70 | 71 | These features have been proposed, but the definitions have not yet been 72 | integrated into their respective specs. 73 | 74 | | Feature name | Spec/PR link(s) | Browser Support | 75 | | ------------ | --------------- | --------------- | 76 | | `clipboard-read` | https://github.com/w3c/clipboard-apis/pull/120 | Chrome 86 | 77 | | `clipboard-write` | https://github.com/w3c/clipboard-apis/pull/120 | Chrome 86 | 78 | | `deferred-fetch` |https://github.com/whatwg/fetch/pull/1647 | | 79 | | `gamepad` | https://github.com/w3c/gamepad/pull/112 | | 80 | | `shared-autofill` | https://github.com/schwering/shared-autofill | | 81 | | `speaker-selection` | https://github.com/w3c/mediacapture-output/pull/96 | | 82 | 83 | ## Experimental Features 84 | 85 | These features generally have an explainer only, but may be available for 86 | experimentation by web developers. 87 | 88 | | Feature name | Link(s) | Browser Support | 89 | | ------------ | ------- | --------------- | 90 | | `all-screens-capture` | [Capture all screens API](https://screen-share.github.io/capture-all-screens/#feature-policy-integration) | In [Origin Trial](https://chromestatus.com/feature/6284029979525120) | 91 | | `browsing-topics` | [Explainer](https://github.com/jkarlin/topics/) | Status "[Started](https://bugs.chromium.org/p/chromium/issues/detail?id=1294456)" in Chrome | 92 | | `captured-surface-control` | [Captured Surface Control API][capture-surface-control] | In [Origin Trial](https://chromestatus.com/feature/5092615678066688) | 93 | | `conversion-measurement ` | [Explainer](https://github.com/WICG/conversion-measurement-api#publisher-controls-for-impression-declaration) | Experimental in Chrome[3](#fn3) | 94 | | `digital-credentials-get` | [Explainer](https://wicg.github.io/digital-credentials/) | Behind a flag in Chrome[6](#fn6) 95 | | `focus-without-user-activation` | [focus-without-user-activation.md](policies/focus-without-user-activation.md) | Status "[Open](https://bugs.chromium.org/p/chromium/issues/detail?id=965495)" in Chrome | 96 | | `join-ad-interest-group` | [Protected Audience (formerly FLEDGE)][protected-audience] | Behind a flag in Chrome[4](#fn4) | 97 | | `local-fonts` | [Local Font Access API][local-fonts] and [Explainer](https://github.com/WICG/local-font-access/blob/main/README.md) | [Experimental in Chrome](https://chromestatus.com/feature/6234451761692672) | 98 | | `run-ad-auction` | [Protected Audience (formerly FLEDGE)][protected-audience] | Behind a flag in Chrome[4](#fn4) | 99 | | `smart-card` | [Draft Spec](https://wicg.github.io/web-smart-card/#permissions-policy) and [Explainer](https://github.com/WICG/web-smart-card#readme) | [Prototyping in Chrome](https://chromestatus.com/feature/6411735804674048) | 100 | | `sync-script` | | Behind a flag in Chrome[1](#fn1) | 101 | | `trust-token-redemption` | [Explainer](https://github.com/WICG/trust-token-api) | In [Origin Trial](https://developers.chrome.com/origintrials/#/view_trial/2479231594867458049) in Chrome 84-87 | 102 | | `unload` | [Explainer](https://github.com/fergald/docs/blob/master/explainers/permissions-policy-unload.md) | Status "[Started](https://crbug.com/1324111) in Chrome | 103 | | `vertical-scroll` | [vertical\_scroll.md](policies/vertical_scroll.md) | Behind a flag in Chrome[1](#fn1) | 104 | 105 | ## Retired Features 106 | 107 | These features were once standardized or proposed, but their specification 108 | and/or implementations have been removed. 109 | 110 | | Feature name | Spec link(s) | Browser Support | 111 | | ------------ | ------------ | --------------- | 112 | | `document-domain` | [HTML][html] | Formerly in Chrome, behind a flag | 113 | | `window-placement` | [Window Management API][window-management] | Formerly in Chrome, changed to `window-management`[5](#fn5) | 114 | 115 | ## Notes 116 | 117 | [1]: To enable these, use the Chrome command line flag 118 | `--enable-blink-features=ExperimentalProductivityFeatures`. 119 | 120 | [2]: Implemented in Chrome as `vr` prior to Chrome 79. 121 | 122 | [3]: To enable this, use the Chrome command line flag 123 | `--enable-blink-features=ConversionMeasurement`. 124 | 125 | [4]: To enable this, use the Chrome command line flag 126 | `--enable-features=AdInterestGroupAPI,InterestGroupStorage,Fledge`. 127 | 128 | [5]: Implemented in [Chrome 100](https://chromestatus.com/feature/5252960583942144) as `window-placement`; 129 | changed in [Chrome 111](https://chromestatus.com/feature/5146352391028736) to `window-management`. 130 | 131 | [6]: To enable this, use the Chrome command line flag 132 | `--enable-features=WebIdentityDigitalCredentials`. 133 | 134 | [7]: To enable this, use the Chrome command line flag 135 | `--enable-features=SensorExtraClasses`. 136 | 137 | [8]: To enable this, user the Chrome command line flag 138 | `--enable-features=ClientHintUAHighEntropyValuesPermissionPolicy`. 139 | 140 | [attribution-reporting]: https://wicg.github.io/attribution-reporting-api/#permission-policy-integration 141 | [battery-status]: https://w3c.github.io/battery/#permissions-policy-integration 142 | [bluetooth]: https://webbluetoothcg.github.io/web-bluetooth/#permissions-policy 143 | [capture-surface-control]: https://screen-share.github.io/captured-surface-control 144 | [compute-pressure]: https://www.w3.org/TR/compute-pressure/#policy-control 145 | [client-hints]: https://wicg.github.io/ua-client-hints/ 146 | [direct-sockets]: https://wicg.github.io/direct-sockets/#permissions-policy 147 | [encrypted-media]: https://w3c.github.io/encrypted-media/#permissions-policy-integration 148 | [protected-audience]: https://wicg.github.io/turtledove/#permissions-policy-integration 149 | [fedcm]: https://fedidcg.github.io/FedCM/#permissions-policy-integration 150 | [fullscreen]: https://fullscreen.spec.whatwg.org/#permissions-policy-integration 151 | [generic-sensor]: https://www.w3.org/TR/generic-sensor/#feature-policy 152 | [geolocation]: https://w3c.github.io/geolocation-api/#permissions-policy 153 | [html]: https://html.spec.whatwg.org/multipage/infrastructure.html#policy-controlled-features 154 | [idle-detection]: https://wicg.github.io/idle-detection/#api-permissions-policy 155 | [keyboard]: https://wicg.github.io/keyboard-map/#permissions-policy 156 | [local-fonts]: https://wicg.github.io/local-font-access/#permissions-policy 157 | [media-capture]: https://w3c.github.io/mediacapture-main/#permissions-policy-integration 158 | [media-capture-screen-share]: https://w3c.github.io/mediacapture-screen-share/#permissions-policy-integration 159 | [mediasession]: https://w3c.github.io/mediasession/#permissions-policy 160 | [navigation-override]: https://drafts.csswg.org/css-nav-1/#policy-feature 161 | [otp-credentials]: https://wicg.github.io/web-otp/#otp-credentials-feature 162 | [page-lifecycle]: https://wicg.github.io/page-lifecycle/#feature-policies 163 | [payment-request]: https://www.w3.org/TR/payment-request/#permissions-policy 164 | [pip]: https://wicg.github.io/picture-in-picture/#feature-policy 165 | [publickey-credentials-get]: https://w3c.github.io/webauthn/#sctn-permissions-policy 166 | [storage-access]: https://privacycg.github.io/storage-access/#permissions-policy-integration 167 | [wake-lock]: https://w3c.github.io/screen-wake-lock/#policy-control 168 | [web-midi]: https://webaudio.github.io/web-midi-api/#permissions-policy-integration 169 | [web-serial]: https://wicg.github.io/serial/#permissions-policy 170 | [web-share]: https://w3c.github.io/web-share/#permissions-policy 171 | [webhid]: https://wicg.github.io/webhid/#permissions-policy 172 | [webusb]: https://wicg.github.io/webusb/#permissions-policy 173 | [window-management]: https://w3c.github.io/window-management/#api-permission-policy-integration 174 | [xhr]: https://xhr.spec.whatwg.org/#feature-policy-integration 175 | [xr]: https://immersive-web.github.io/webxr/#permissions-policy 176 | -------------------------------------------------------------------------------- /integration.md: -------------------------------------------------------------------------------- 1 | # Defining Policy-Controlled Features 2 | 3 | This guide is for authors of other standards who want to use Permissions Policy 4 | as a mechanism for enabling and disabling their features. It's a collection of 5 | principles and guidelines (more than actual rules) for coming up with sensible 6 | defaults, whether the feature in question is a long standing feature on the 7 | web, or something brand new. 8 | 9 | ## Referencing the Permissions Policy spec 10 | 11 | There is no central registry for policy-controlled features. Feature authors who 12 | wish to allow Permissions Policy to control their features on the web can do so 13 | by referencing the Permissions Policy specification. 14 | 15 | The following example shows how a feature could be declared as a 16 | policy-controlled feature: 17 | 18 | > Example: 19 | > 20 | >### Section N: Permissions Policy Integration 21 | > The Sample API defines a [*policy-controlled feature*](https://w3c.github.io/webappsec-permissions-policy/#policy-controlled-feature) 22 | > identified by the string "`sample`". Its [default allowlist](https://w3c.github.io/webappsec-permissions-policy/#default-allowlist) 23 | > is `'self'` \[[PERMISSIONS-POLICY](https://w3c.github.io/webappsec-permissions-policy/)\]. 24 | 25 | The specification can then refer to this feature, and test whether it is enabled 26 | or not in a specific document, with text similar to this: 27 | 28 | > Example: 29 | > 30 | > If [this](https://webidl.spec.whatwg.org/#this)'s [relevant global object](https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-global)'s [associated Document](https://html.spec.whatwg.org/multipage/window-object.html#concept-document-window) 31 | > is not [allowed to use](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#allowed-to-use) 32 | > the `sample` feature, then throw a `SecurityError` 33 | > [DOMException](https://heycam.github.io/webidl/#dfn-DOMException) and abort these steps. 34 | 35 | (This is an example only. The actual behavior of any algorithm when a 36 | policy-controlled feature is disabled is left up to the specification which 37 | defines that feature.) 38 | 39 | ## Choosing a default allowlist 40 | 41 | As described in the 42 | [spec](https://w3c.github.io/webappsec-permissions-policy/#default-allowlists), the default 43 | allowlist chosen affects how the feature behaves when there are no declared 44 | policies present. As a rough guide: 45 | 46 | * Features which have already been widely available on the web platform, but 47 | which Permissions Policy can now disable selectively, should use `*`. This 48 | ensures that the majority of documents on the web, as well as documents which 49 | are framed without their knowledge, will continue to behave as expected by 50 | their original authors. 51 | * New powerful features are often specified such that they are available in 52 | top-level browsing contexts only, and are not available in cross-origin child 53 | frames, for security. These kinds of features should use a default allowlist of 54 | `'self'` to provide this behaviour. In this case, Permissions Policy also grants 55 | site authors the ability to selectively enable the feature in other origins, 56 | but the default behaviour is to disable it. 57 | 58 | ## Considerations for behavior when disallowed 59 | 60 | It is important for feature authors to carefully consider the mechanism by 61 | which their feature is disabled when disallowed in a document, for ease of 62 | developer feature detection, as well as for compatibility with existing web 63 | content. 64 | 65 | Existing web platform features which already have some mechanism for reporting 66 | errors, or signalling that the user chose not to grant permission, should use 67 | those existing mechanisms when disabled. 68 | 69 | New features should attempt to fail in a way which allows authors to detect 70 | that the feature is disabled. 71 | 72 | > Example: 73 | > 74 | > The fullscreen API has existed on the web for some time, and is being 75 | > implemented as a policy-controlled feature. Developers have always had to 76 | > contend with the fact that fullscreen may not be allowed, and the API has a 77 | > method of signalling that. 78 | > 79 | > As a policy-controlled feature, the fullscreen API can specify that when 80 | > disabled, `document.fullscreenEnabled` must return `false`, and 81 | > `Element.requestFullscreen()` must fire a `fullscreenerror` event, and return 82 | > a promise which rejects with a `TypeError` exception. 83 | 84 | If an existing feature has no mechanism for reporting failure, or has never been 85 | allowed to fail in the past, then it may be dangerous to turn it into a 86 | policy-controlled feature, where it may start to fail on pages that were always 87 | able to assume that it would not. 88 | 89 | In this case, features may be better defined using [Document Policy](https://wicg.github.io/document-policy/), 90 | as that mechanism requires an explicit opt-in by any embedded document for which 91 | that policy is required. 92 | 93 | > Example: 94 | > 95 | > The `document.write` API has existed on the web since roughly the dawn of 96 | > JavaScript, and has no failure modes. 97 | > 98 | > One means of disallowing this feature via Permissions Policy would be to declare that 99 | > any calls to `document.write()` will silently fail. However, this would mean that 100 | > if a page contained a script like this: 101 | > 102 | > 103 | >
104 | > 105 | > ... 106 | > 107 | > then an attacker could embed that page in a frame with the `document.write` 108 | > feature disabled, and bypass the critical security script. 109 | > 110 | > To avoid this, a better way to disable it would be to define the availability of 111 | > `document.write()` as a configuration point using document policy. Then the use of 112 | > `document.write()` in a document which disables it can fire a `SecurityError` 113 | > exception on the `document` object. If a document which is to be embedded in a frame 114 | > which requires the policy does not conform to that required policy, it is simply not 115 | > loaded. (See the document policy explainer and spec for details). 116 | -------------------------------------------------------------------------------- /permissions-policy-client-hints.md: -------------------------------------------------------------------------------- 1 | # Permissions Policy and Client Hints 2 | 3 | ## Background 4 | 5 | [Client Hints](https://wicg.github.io/client-hints-infrastructure/) are a 6 | mechanism for the browser to provide information to an origin server about the 7 | browser's configuration and capabilities, to allow the server to select 8 | appropriate responses based on that configuration. See 9 | [here](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/client-hints) 10 | for more information and background on Client Hints specifically. 11 | 12 | Client Hints do represent an opportunity for increased fingerprinting surface, 13 | as they expose information about the user's browser, language preferences, 14 | network conditions, and other potentially identifying information. As such, it 15 | is important that the information not be simply made available to all documents 16 | and resources. 17 | 18 | [Permissions Policy](https://w3c.github.io/webappsec-permissions-policy/) is a 19 | way to control what features are available in documents, providing a method of 20 | delegation of powerful features to subframes. 21 | 22 | ## Relationship between Permissions Policy and Client Hints 23 | 24 | Every client hint is represented in Permissions Policy as a policy-controlled 25 | feature. The feature, which is always enabled for top-level documents, 26 | represents the ability to receive the hint in a subframe. 27 | 28 | There are two broad classes of hints defined: High-entropy and Low-entropy. High 29 | entropy hints contain a greater amount of potententially identifying information 30 | about the user, and are not intended for automatic distribution to cross-origin 31 | resources. Low entropy hints contain information about the browser which is 32 | expected to be consistent across large groups of users (browser name, or major 33 | version, for instance) and is much less useful for identifying individual users. 34 | 35 | High-entropy hints are backed by features with a default allowlist of `self`. 36 | Low-entropy hints are backed by features with a default allowlist of `*`. 37 | 38 | Example high-entropy hints (and their corresponding features): 39 | * DPR (`ch-dpr`) 40 | * UA-Arch (`ch-ua-arch`) 41 | 42 | Example low-entropy hints (and their corresponding features): 43 | * Save-Data (`ch-save-data`) 44 | * UA (`ch-ua`) 45 | 46 | ## How delegation works 47 | 48 | In top-level documents, hints are requested with the Accept-CH HTTP response 49 | header 50 | ([reference](https://tools.ietf.org/html/draft-ietf-httpbis-client-hints-15)). 51 | 52 | Permissions Policy cannot be used to change the hints received by the top-level 53 | document, as the `Permissions-Policy` response header cannot be sent before the 54 | hints (which are request headers) are received. However, it can be used to 55 | control where those hints are sent after that. 56 | 57 | ### Delegation to embedded documents 58 | 59 | Any document which receives hints may choose to delegate those hints to other 60 | documents which it embeds inside of an `