How to turn off camera and location capabilities by default in the response header for web pages that do not need them?
Web pages do not need camera, microphone, and location capabilities, which can be turned off by default in the Permissions-Policy response header. Its mechanism is to set an allowed list for each instruction, and the document itself as well as each frame nested within the document judge whether they can use the corresponding feature according to this list. Tightening the default list of the site to 'no one' is the most direct way to reduce the exposure of the browser's capabilities.
The default list only has three values
According to the document, each instruction has a default allowed list, which is always one of the three: an asterisk indicates that any source is allowed, self indicates only the same origin, and none indicates that no one is given by default. That is to say, the essence of writing this header is not to 'turn off a feature', but to narrow down the default list of each instruction.
The following table separates common instructions according to whether the page is needed or not, making it easy to judge which level to give to each item:
| Ability Category | Typical Instructions | Common Lists on Content Sites |
|---|---|---|
| Hardware Collection | Camera, Microphone | An empty list is given when there is no related function |
| Location Information | Positioning | Origin is required for pages of type Store positioning |
| Screen capture | Screen sharing | Generally provide an empty list |
| Full screen and autoplay | Full screen, autoplay | Origin required as needed for video pages |
| Cross-site request | Wildcard subdomain related instructions | Provide an empty list when not in use |
Why would a nested frame be blocked by the parent page?
There is a frequently ignored premise in the document: in order to enable a certain feature, the allowed source of the frame must also appear in the parent page's allowed list. This means that the parent page list is the upper limit, and the child frame cannot obtain authorization beyond the limit.
Content station's third-party components are taking this path: embedded captcha components, map components, and players are all embedded in the framework. If the parent page is set to empty to tighten the list, these components will directly fail. The sequence in practice should be to first determine the widest acceptable range of the entire site and write it into the response header, and then use the allow attribute to specify the subset it needs on a narrower framework.
The allow attribute can only narrow, not broaden.
This is the second boundary: the allow attribute on the framework is used to further narrow the range allowed in the parent page, rather than to add permissions to the child page. No authorization given by the parent page will not appear, no matter how many properties are written.
This is the most likely to be misjudged when troubleshooting. The component reports 'The browser rejected this capability', and the first thing to look at is the list in the parent page's response headers, not the parameter writing in the component documentation.
This does not overlap with the existing protection within the site.
AnQiCMS such systems have protection on the input side, sensitive word filtering and filtering logic for SQL injection and XSS are for content-level issues; Permissions-Policy handles the permissions of browser function calls, which belongs to the level of 'whether the page can access the device capabilities'. Both do not exceed boundaries: tightening the list of capabilities cannot replace content purification, and content filtering will not cause the framework call to fail due to exceeding the authority.
Form sites that have integrated the captcha component should pay attention. The verification order after tightening the list should be: first, confirm that the component can still load and submit normally in a clean browser instance, and then confirm that the backend still performs validation on the submission. Whether the human verification component is available on the page belongs to the browser side, and the server still needs to independently judge whether this submission is legal, and cannot be automatically approved just because there is a component on the page.
Common questions
Question: What if no instructions are written?Answer: Instructions run according to their default allowed lists, and the default settings of different instructions are not consistent. Writing down each item explicitly makes behavior explicit and avoids reliance on the default settings of various features.
Ask: Isn't it safer to only allow same-origin?Answer: Same-origin is just one of the three levels, suitable for situations where only the site's scripts will call this capability. If there is indeed no scenario that uses it, the empty list is narrower than same-origin.
Ask: Why are some pages still prompting for permissions after changing the header?Answer: The page is allowed in the list, or the response header did not cover this path. It is more stable to check each path than to add one at the main site.