useIframeSandbox (HTML)
Summary
Section titled “Summary”- Rule available since:
v2.4.12 - Diagnostic Category:
lint/security/useIframeSandbox - This rule isn’t recommended, so you need to enable it.
- This rule doesn’t have a fix.
- The default severity of this rule is error.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "security": { "useIframeSandbox": "error" } } }}Description
Section titled “Description”Require the sandbox attribute on <iframe> elements.
An iframe can run content from another document. The sandbox attribute restricts
capabilities such as scripts, forms, navigation, and popups. An empty sandbox applies all
restrictions; individual allow-* tokens restore only the capabilities the frame needs.
See MDN’s iframe sandbox reference.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<iframe src="https://example.com"></iframe>code-block.html:1:1 lint/security/useIframeSandbox ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Iframe doesn't have the sandbox attribute.
> 1 │ <iframe src="https://example.com"></iframe>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ The sandbox attribute enables an extra set of restrictions for the content in the iframe, protecting against malicious scripts and other security threats.
ℹ Provide a sandbox attribute when using iframe elements.
<iframe src="https://example.com" sandbox="allow-popups"></iframe>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.