no-missing-iframe-sandbox
Enforces an explicit 'sandbox' attribute for 'iframe' elements.
Full Name in eslint-plugin-react-dom
react-dom/no-missing-iframe-sandboxFull Name in @eslint-react/eslint-plugin
@eslint-react/dom-no-missing-iframe-sandboxFeatures
🔧
Presets
strict
strict-typescript
strict-type-checked
Rule Details
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.
Examples
Rendering an <iframe> without a sandbox attribute
An iframe without sandbox allows the embedded content unrestricted capabilities, which is a security risk.
// Problem: missing sandbox attribute leaves the iframe unrestricted.
function MyComponent() {
return <iframe src="https://eslint-react.xyz" />;
// ^^^ Missing 'sandbox' attribute on iframe component.
}// Recommended: add a sandbox attribute to restrict the iframe's capabilities.
function MyComponent() {
return <iframe src="https://eslint-react.xyz" sandbox="allow-popups" />;
}Versions
Resources
Further Reading
See Also
react-dom/no-missing-button-type
Enforces an explicittypeattribute forbuttonelements.react-dom/no-unsafe-iframe-sandbox
Enforces that thesandboxattribute foriframeelements is not set to unsafe combinations.