Skip to content

useIframeSandbox (HTML)

biome.json
{
"linter": {
"rules": {
"nursery": {
"useIframeSandbox": "error"
}
}
}
}

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.

<iframe src="https://example.com"></iframe>
code-block.html:1:1 lint/nursery/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.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<iframe src="https://example.com" sandbox="allow-popups"></iframe>