Skip to content

useIframeSandbox (JavaScript)

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

Enforce the ‘sandbox’ attribute for ‘iframe’ elements.

The sandbox attribute enables an extra set of restrictions for the content in the iframe. Using the sandbox attribute is considered a good security practice.

See the Mozilla docs for details.

function MyComponent() {
return <iframe src="https://example.com" />;
}
code-block.jsx:2:10 lint/security/useIframeSandbox ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✖ Iframe doesn't have the sandbox attribute.

1 │ function MyComponent() {
> 2 │ return <iframe src="https://example.com" />;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 │ }
4 │

ℹ 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.

function MyComponent() {
return <iframe src="https://example.com" sandbox="allow-popups" />;
}