-
Notifications
You must be signed in to change notification settings - Fork 51k
Bug: SVG executes contents of script tags. #25522
Copy link
Copy link
Closed as not planned
Labels
Resolution: StaleAutomatically closed due to inactivityAutomatically closed due to inactivityStatus: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
Script tags within SVG execute their contents when rendered with React. This is surprising, and creates opportunities for XSS attacks when rendering user generated content.
React version: 17.02, 18.2.0
Steps To Reproduce
- Create an
<svg>element with a<script>tag in it - Render that element
- The children of that script tag will parse and execute as JavaScript
Link to code example:
https://codesandbox.io/s/modest-voice-kywwwu
The current behavior
In this example, you'll see that the script tag within HTML does not execute, however the script tag within SVG does.
The expected behavior
I would have expected the script's contents to be ignored in SVG, as it does in HTML.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Resolution: StaleAutomatically closed due to inactivityAutomatically closed due to inactivityStatus: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug