Skip to content

useIframeSandbox (JavaScript)

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

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.

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