oxc-project/oxc · error · OxcDiagnostic

An `iframe` element defines a sandbox attribute with both al

Error message

An `iframe` element defines a sandbox attribute with both allow-scripts and allow-same-origin which is invalid

What it means

Raised by react/iframe_missing_sandbox when an iframe's `sandbox` attribute contains both `allow-scripts` and `allow-same-origin`. At the throw site the combination lets the framed content remove its own sandbox attribute (same-origin access plus script execution), making the sandbox effectively useless as a security boundary. validate_sandbox_value checks the token set and reports the attribute via invalid_sandbox_combination_prop.

Source

Thrown at crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs:33

    context::LintContext,
    rule::Rule,
    utils::{get_prop_value, has_jsx_prop_ignore_case, is_create_element_call},
};

fn missing_sandbox_prop(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("An iframe element is missing a sandbox attribute")
        .with_help("Add a `sandbox` attribute to the `iframe` element.")
        .with_label(span)
}

fn invalid_sandbox_prop(span: Span, value: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("An iframe element defines a sandbox attribute with invalid value: {value}"))
        .with_help("Check this link for the valid values of `sandbox` attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox.")
        .with_label(span)
}

fn invalid_sandbox_combination_prop(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("An `iframe` element defines a sandbox attribute with both allow-scripts and allow-same-origin which is invalid")
        .with_help("Remove `allow-scripts` or `allow-same-origin`.")
        .with_label(span)
}

const ALLOWED_VALUES: [&str; 14] = [
    "downloads-without-user-activation",
    "downloads",
    "forms",
    "modals",
    "orientation-lock",
    "pointer-lock",
    "popups",
    "popups-to-escape-sandbox",
    "presentation",
    "same-origin",
    "scripts",
    "storage-access-by-user-activation",
    "top-navigation",

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove either allow-scripts or allow-same-origin from the sandbox attribute.
  2. Serve the embedded content from a different origin if both flags are genuinely needed.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs:33 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/947479f347d5876d. Report an issue: GitHub.