oxc-project/oxc · error · OxcDiagnostic

An iframe element defines a sandbox attribute with invalid v

Error message

An iframe element defines a sandbox attribute with invalid value: {value}

What it means

Raised by react/iframe_missing_sandbox when an iframe's `sandbox` attribute has a string value containing tokens that are not valid sandbox directives. At the throw site the declared restrictions are not in effect as intended — unknown tokens are ignored by browsers, so the iframe may be more permissive than the author assumed. validate_sandbox_value tokenizes the attribute value and calls invalid_sandbox_prop with the offending value string.

Source

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

use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{
    AstNode,
    ast_util::is_method_call,
    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",

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Correct the token to a valid sandbox value (allow-forms, allow-scripts, allow-same-origin, etc.).
  2. Remove unrecognized tokens from the sandbox attribute.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/react/iframe_missing_sandbox.rs:27 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/9fa55905aabad1da. Report an issue: GitHub.