Skip to content

Bug: credentialless="" is dropped #38330

Open

Description

@mccabe-ant

Bug: <iframe credentialless=""> drops the attribute with no warning in 19.3.1

React version: 19.3.1 (19.2.4 renders the attribute)

Steps To Reproduce

  1. npm install react@19.3.1 react-dom@19.3.1
  2. Save the code below as repro.js and run node repro.js.
  3. Repeat with react@19.2.4 and react-dom@19.2.4.

Code example:

const React = require('react');
const {renderToStaticMarkup} = require('react-dom/server');

for (const value of ['', true, 'credentialless']) {
  const html = renderToStaticMarkup(
    React.createElement('iframe', {credentialless: value}),
  );
  console.log(JSON.stringify(value), '->', html);
}

The current behavior

credentialless is now a boolean attribute (#36148), so an empty string counts as false and the attribute is left out. Nothing is logged in development.

credentialless prop 19.2.4 19.3.1
"" <iframe credentialless=""> <iframe>, no warning
true <iframe>, warns about a non-boolean attribute <iframe credentialless="">
"credentialless" <iframe credentialless="credentialless"> <iframe credentialless="">

Production builds give the same HTML, and so does createRoot in Chrome 157.

In 19.2.4, true was dropped, so code turned the attribute on with a string such as "". Code that passes "" loses it on upgrade. The attribute keeps an embedded frame from the user's cookies and storage, so losing it silently weakens isolation.

The expected behavior

credentialless="" logs the same development warning that inert="" does:

Received an empty string for a boolean attribute inert. This will treat the attribute as if it were false. Either pass false to silence this warning, or pass true if you used an empty string in earlier versions of React to indicate this attribute is true.

Activity

  1. added
    Status: Unconfirmed
    on Nov 20, 2026
  2. Allen5288 commented on Nov 21, 2026

    @Allen5288

    Hi, I reproduced this on 19.3.1 — credentialless="" is silently dropped, while inert="" logs the empty-string boolean warning. Before I code it up, is mirroring the inert warning the fix you'd want here? My plan would be to give credentialless its own case with the same warning in setProp and diffHydratedGenericElement in ReactDOMComponent.js and in pushAttribute in ReactFizzConfigDOM.js, plus tests mirroring the existing inert ones — dev warning only, no change to the rendered output. Happy to go a different way if you'd prefer.

  3. mccabe-ant commented on Nov 21, 2026

    @mccabe-ant
    Author

    I don't know all the considerations at play, I would just note that dropping it can cause a security problem where an iframe runs with more privileges than were intended. I would therefore think that this should fail loudly, by not running or building. If that's not possible in a patch release, perhaps the best compromise would be to warn and treat "" as true, since that is less likely to result in a security issue than treating it as false/absent. (Inserting the attribute where it was not intended also grants a privilege, namely COEP exemption, so it's not fail-safe to treat "" as true, just less likely to cause a problem.)

  4. Allen5288 commented on Nov 21, 2026

    @Allen5288

    Thanks for the note — good point about the security angle. I've revised my plan: warn and treat "" as true, rather than warning only while treating it as false. The warning will say it treats the attribute as if it were true, and suggest passing true to silence it or false to remove it. I've implemented that in setProp, diffHydratedGenericElement and pushAttribute, with tests mirroring the inert ones, and the relevant test suites pass. I'll open a PR shortly — happy to change direction if a maintainer prefers a different approach.

  5. pawannyadav05 commented on Nov 21, 2026

    @pawannyadav05

    Fixes #38330

    Problem

    In React 19, credentialless on <iframe> was converted to a boolean attribute (#36148). Consequently, passing an empty string (credentialless="") treats the value as false and silently drops the attribute from the DOM output without logging a diagnostic in development mode.

    Prior to React 19, boolean attributes were frequently activated using empty strings (credentialless=""). Because credentialless provides origin isolation by preventing embedded frames from accessing the user's cookies and storage, silently omitting it upon upgrading weakens security boundaries without warning developers.

    Solution

    • Mirror inert Diagnostic: Added credentialless to the boolean empty-string warning cases alongside inert.
    • Comprehensive Coverage: Applied the check across:
      • Client DOM prop mutations (setProp in ReactDOMComponent.js)
      • Client SSR hydration verification (diffHydratedGenericElement in ReactDOMComponent.js)
      • Server-side rendering attribute emission (pushAttribute in ReactFizzConfigDOM.js)

    Changes

    • packages/react-dom-bindings/src/client/ReactDOMComponent.js: Added credentialless warning branch in setProp and diffHydratedGenericElement.
    • packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js: Added credentialless warning branch in pushAttribute.

    PR opened in #38336.

  6. Allen5288 commented on Nov 21, 2026

    @Allen5288

    Just a note for anyone following this — I already opened a PR for this issue earlier today: #38332 (#38332). It warns in dev and treats credentialless="" as true, in setProp, diffHydratedGenericElement and pushAttribute, with tests mirroring the inert ones. @pawannyadav05 — your PR #38336 came after this one, so I wanted to flag the earlier PR here for the maintainers; happy to compare approaches, the main difference is mine also renders the attribute rather than only warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Unconfirmed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy