Permissions-Policy
Permissions-Policy 是什么?
Permissions-PolicyAn HTTP response header (formerly Feature-Policy) that lets a site declare which browser features — camera, microphone, geolocation, payment, USB, sensors — its own document and any embedded iframes are allowed to use.
Permissions-Policy is the successor to the Feature-Policy header, standardized to a structured-headers syntax and supported by all major browsers. It lets a document express, per powerful feature, who is allowed to use it: the document itself (`self`), specific origins, or no one. A header like `Permissions-Policy: geolocation=(), camera=(self), payment=(self "https://checkout.example")` denies geolocation everywhere, lets the main document use the camera, and lets the document plus checkout.example use the Payment Request API. Permissions-Policy is enforced both for the top-level document and recursively for nested browsing contexts, with the parent able to restrict children further (but never expand their privileges). It is the simplest defense against third-party scripts or iframes silently probing for camera, microphone, geolocation, sensors, fullscreen, autoplay, USB, serial, HID, payment, and many other capabilities; modern hardening guides recommend setting it explicitly alongside CSP and HSTS.
● 示例
- 01
A SaaS dashboard sets `Permissions-Policy: geolocation=(), microphone=(), camera=()` to deny location and media APIs to itself and every embedded widget.
- 02
An embed-host site grants Payment Request only to a known payments iframe by using `payment=(self "https://pay.example.com")`.
● 常见问题
Permissions-Policy 是什么?
An HTTP response header (formerly Feature-Policy) that lets a site declare which browser features — camera, microphone, geolocation, payment, USB, sensors — its own document and any embedded iframes are allowed to use. 它属于网络安全的 应用安全 分类。
Permissions-Policy 是什么意思?
An HTTP response header (formerly Feature-Policy) that lets a site declare which browser features — camera, microphone, geolocation, payment, USB, sensors — its own document and any embedded iframes are allowed to use.
Permissions-Policy 是如何工作的?
Permissions-Policy is the successor to the Feature-Policy header, standardized to a structured-headers syntax and supported by all major browsers. It lets a document express, per powerful feature, who is allowed to use it: the document itself (`self`), specific origins, or no one. A header like `Permissions-Policy: geolocation=(), camera=(self), payment=(self "https://checkout.example")` denies geolocation everywhere, lets the main document use the camera, and lets the document plus checkout.example use the Payment Request API. Permissions-Policy is enforced both for the top-level document and recursively for nested browsing contexts, with the parent able to restrict children further (but never expand their privileges). It is the simplest defense against third-party scripts or iframes silently probing for camera, microphone, geolocation, sensors, fullscreen, autoplay, USB, serial, HID, payment, and many other capabilities; modern hardening guides recommend setting it explicitly alongside CSP and HSTS.
如何防御 Permissions-Policy?
针对 Permissions-Policy 的防御通常结合技术控制与运营实践,详见上方完整定义。
Permissions-Policy 还有哪些其他名称?
常见的别称包括: Feature-Policy (legacy), Permission policy。
● 相关术语
- appsec№ 237
内容安全策略 (CSP)
一种 HTTP 响应头,告诉浏览器允许加载哪些来源的脚本、样式、框架等内容,从而限制 XSS 与数据注入攻击的影响。
- appsec№ 552
HTTP 安全响应头
指示浏览器执行强制 HTTPS、限制嵌入、内容策略和引用来源等防御行为的响应头集合。
- appsec№ 263
Cross-Origin Opener Policy (COOP)
An HTTP response header that lets a document opt into a process-isolated browsing context group, preventing cross-origin windows from inspecting or manipulating it via `window.opener` and friends.
- appsec№ 262
Cross-Origin Embedder Policy (COEP)
An HTTP response header that forces every cross-origin subresource a document loads to explicitly opt in via CORS or CORP, completing the cross-origin isolation prerequisites alongside COOP.
- appsec№ 574
iframe sandbox 属性
HTML 属性,为 iframe 内容施加额外限制,默认禁用脚本、表单、导航与同源访问,除非显式重新启用。
- appsec№ 1302
Trusted Types
浏览器 API 与 CSP 指令,要求危险的 DOM 接收器只能接受经策略审查的类型化值,从而防止基于 DOM 的 XSS。