Repository navigation
Description
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
npm install react@19.3.1 react-dom@19.3.1- Save the code below as
repro.jsand runnode repro.js. - Repeat with
react@19.2.4andreact-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 passfalseto silence this warning, or passtrueif you used an empty string in earlier versions of React to indicate this attribute is true.
Activity
Allen5288 commentedon Nov 21, 2026
Hi, I reproduced this on 19.3.1 —
credentialless=""is silently dropped, whileinert=""logs the empty-string boolean warning. Before I code it up, is mirroring theinertwarning the fix you'd want here? My plan would be to givecredentiallessits own case with the same warning insetPropanddiffHydratedGenericElementinReactDOMComponent.jsand inpushAttributeinReactFizzConfigDOM.js, plus tests mirroring the existinginertones — dev warning only, no change to the rendered output. Happy to go a different way if you'd prefer.mccabe-ant commentedon Nov 21, 2026
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.)
Allen5288 commentedon Nov 21, 2026
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 passingtrueto silence it orfalseto remove it. I've implemented that insetProp,diffHydratedGenericElementandpushAttribute, with tests mirroring theinertones, and the relevant test suites pass. I'll open a PR shortly — happy to change direction if a maintainer prefers a different approach.pawannyadav05 commentedon Nov 21, 2026
Fixes #38330
Problem
In React 19,
credentiallesson<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=""). Becausecredentiallessprovides 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
inertDiagnostic: Addedcredentiallessto the boolean empty-string warning cases alongsideinert.setPropinReactDOMComponent.js)diffHydratedGenericElementinReactDOMComponent.js)pushAttributeinReactFizzConfigDOM.js)Changes
packages/react-dom-bindings/src/client/ReactDOMComponent.js: Addedcredentiallesswarning branch insetPropanddiffHydratedGenericElement.packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js: Addedcredentiallesswarning branch inpushAttribute.PR opened in #38336.
Allen5288 commentedon Nov 21, 2026
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, insetProp,diffHydratedGenericElementandpushAttribute, with tests mirroring theinertones. @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.