You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XSS (or parse error) in react-error-overlay with specific coding style #2789
changed the title [-]XSS in `react-error-overlay` with specific coding style[/-][+]XSS (or parse error) in `react-error-overlay` with specific coding style[/+]on Jul 14, 2017
Seems the source code is escaped by codeFrame() at line 44 of lib/components/code.js, then assigns it to variable ansiHighlight, then passes it to generateAnsiHtml() (react-dev-utils/ansiHTML)
This is the sourceCode.join('\n') that passed to codeFrame() and the parsed result ansiHighlight of the third section (no alert dialog):
It shows that the 4th line doesn't fully parsed by codeFrame() (thought seems that all the content of section is not fully parsed), and codeFrame is imported from babel-code-frame. So it's probably a bug of babel-code-frame...?
Looks like the sourceCode is not fully parsed by codeFrame is because the sourceCode doesn't include the begin back-tick (`) of template literals, so it treats the latter tokens (begins from `.trim()) as a string. You can see that the screenshot of Expected Behavior parses the source code as JSX, while Actual Behavior is as string.
It maybe hard for babel-code-frame to fix this, because the source code is not complete, and the fragment of source code miss some important lexical items. At least we can fix the bug of parsing HTML tags in source code, simply replace the angle brackets in react-dev-utils/ansiHTML.
Activity
[-]XSS in `react-error-overlay` with specific coding style[/-][+]XSS (or parse error) in `react-error-overlay` with specific coding style[/+]gaearon commentedon Jul 14, 2017
That's great, thanks for reporting.
I expect this to be solved by the React rewrite (haven't reviewed it yet) but happy to take a fix for current code.
ccloli commentedon Jul 15, 2017
Seems the source code is escaped by
codeFrame()at line 44 oflib/components/code.js, then assigns it to variableansiHighlight, then passes it togenerateAnsiHtml()(react-dev-utils/ansiHTML)This is the
sourceCode.join('\n')that passed tocodeFrame()and the parsed resultansiHighlightof the third section (no alert dialog):And this is the first section (shows
/XSS/alert dialog):It shows that the 4th line doesn't fully parsed by
codeFrame()(thought seems that all the content of section is not fully parsed), andcodeFrameis imported frombabel-code-frame. So it's probably a bug ofbabel-code-frame...?ccloli commentedon Jul 15, 2017
Looks like the
sourceCodeis not fully parsed bycodeFrameis because thesourceCodedoesn't include the begin back-tick (`) of template literals, so it treats the latter tokens (begins from`.trim()) as a string. You can see that the screenshot of Expected Behavior parses the source code as JSX, while Actual Behavior is as string.It maybe hard for
babel-code-frameto fix this, because the source code is not complete, and the fragment of source code miss some important lexical items. At least we can fix the bug of parsing HTML tags in source code, simply replace the angle brackets inreact-dev-utils/ansiHTML.