sanitize javascript: urls for <object> tags - #29808
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
My open question is if we have preferred behavior of |
|
What does
The goal is to not accidentally load current page URL a second time for no good reason. |
|
Seems like you have some failing tests too. |
React 19 added sanitization for `javascript:` URLs for `href` properties on various tags. This PR also adds that sanitization for `<object>` tags as well that Firefox otherwise executes.
|
Tests pass now. Implemented removing the string removal to match general empty string behavior. I couldn't repro the behavior of re-requesting the page either with imgs or object tags, maybe I'm missing something or it doesn't show up in the network panel. Had a repro in this sandbox: https://codesandbox.io/p/sandbox/upbeat-hofstadter-dvmlwv?file=%2Findex.html%3A12%2C1 |
It seems like Chrome (and possibly other browsers?) are no longer trying to render an image with an empty |
Correct inaccurate claims: - React 19 sanitizes javascript: URLs in href, src, action, formAction, data and xlinkHref; 16.9-18 warn in development only (react/react#29808) - DOMPurify runs in Node.js with jsdom; sanitize-html offered as the no-jsdom alternative - Cite precacheFiberNode in ReactDOMComponentTree.js for fiber-tree access and the correct Princeton session-replay study; the React DevTools page did not support the claim - State that React sanitizes nothing on any path; ref writes and dangerouslySetInnerHTML carry identical risk - Replace the unimplementable "release values immediately" guidance with no long-lived credentials in client state and Web Worker isolation - Fix the URL validation helper, which rejected every relative URL; render the normalized href and fall back to plain text - Note that httpOnly protects cookie confidentiality only and does not stop XSS riding the session - Correct CR/LF response splitting: Node and the Headers API reject it; repoint to redirect validation - Await params in the Server Component example for Next.js 15 Remove duplication per rule 4: - Link the Next.js Security Cheat Sheet for Server Actions, routing-layer authorization, server-only and NEXT_PUBLIC_, per the scope split agreed with jharvieux - Link Session Management, Authorization, SSRF Prevention, Forgot Password and Unvalidated Redirects rather than restating their guidance - Drop the supply-chain section as not React-specific, per randomstuff Add and fix: - Content Security Policy section, including worker-src and development versus production policy differences - Citations in the Introduction and Authentication sections to meet the AGENTS.md per-H2 citation floor - SANITIZE_NAMED_PROPS for DOM clobbering; destructuring-first guidance for spread syntax with a per-component allow-list - Threat-model scoping statement in Sensitive Data Exposure - Wrap all snippets in components so they compile; remove em dashes and apply "spread syntax" terminology for textlint
sanitize javascript: urls for tags
React 19 added sanitization for
javascript:URLs forhrefproperties on various tags. This PR also adds that sanitization for<object>tags as well that Firefox otherwise executes.