Skip to content

useIframeSandbox (HTML)

  • 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.
biome.json
{
"linter": {
"rules": {
"security": {
"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/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>