noUnsafeIframeSandbox (JavaScript)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noUnsafeIframeSandbox - This rule doesn’t have a fix.
- The default severity of this rule is error.
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noUnsafeIframeSandbox": "error" } } }}Description
Section titled “Description”Disallow an unsafe combination of the sandbox attribute.
This rule reports cases where the attribute may contain allow-scripts and allow-same-origin at the same time,
as this combination allows the embedded document to remove the sandbox attribute and bypass the restrictions.
See Play safely in sandboxed IFrames or this Stack Overflow answer for more details.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”function MyComponent() { return <iframe src="https://example.com" sandbox="allow-scripts allow-same-origin" />;}code-block.jsx:2:44 lint/nursery/noUnsafeIframeSandbox ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Unsafe combination of allow-scripts and allow-same-origin in the sandbox attribute.
1 │ function MyComponent() {
> 2 │ return <iframe src="https://example.com" sandbox="allow-scripts allow-same-origin" />;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 │ }
4 │
ℹ This lets the embedded document run scripts in the origin of the embedding page, so it can remove its own sandbox attribute and escape the restrictions.
ℹ Remove allow-scripts or allow-same-origin from the sandbox attribute.
ℹ See Play safely in sandboxed IFrames or this Stack Overflow answer for more details.
ℹ 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" />;}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.