Lets remove all the usages of dangerouslySetInnerHTML
Categories
(DevTools :: Debugger, defect, P2)
Tracking
(firefox-esr115 wontfix, firefox-esr140 wontfix, firefox150 wontfix, firefox151 wontfix, firefox152 fixed)
People
(Reporter: bomsy, Assigned: nchevobbe)
References
Details
(Keywords: sec-audit, Whiteboard: [adv-main152-])
Attachments
(2 external files)
We have a couple of usages of the dangerouslySetInnerHTML in the debugger . See here https://searchfox.org/firefox-main/search?q=dangerouslySetInnerHTML&path=devtools%2Fclient%2Fdebugger&case=false®exp=false.
Comment 1•7 months ago
|
||
Probably not a good idea to point so directly to a security issue.
Updated•7 months ago
|
Updated•6 months ago
|
Comment 2•6 months ago
•
|
||
We quickly reviewed the two remaining call sites for dangerouslySetInnerHTML
- Breakpoint.js
dangerouslySetInnerHTML: this.highlightText(breakpointText, editor),
This is setting html based on a breakpoint text, which we don't control completely. It's not clear if this text has been properly sanitized. We render the breakpoint text with highlighting via CodeMirror 6 and retrieve the innerHTML of the CodeMirror instance. I think it is unlikely to break but we should fix it.
- DOMMutationBreakpoints.js
const text = L10N.getFormatStr(
"noDomMutationBreakpoints",
`<a>${L10N.getStr("inspectorTool")}</a>`
);
...
dangerouslySetInnerHTML: {
__html: text,
},
This one is simply setting a localized string, not harmful.
| Assignee | ||
Comment 3•6 months ago
|
||
Updated•6 months ago
|
| Assignee | ||
Comment 4•6 months ago
|
||
(In reply to Julian Descottes [:jdescottes] from comment #2)
- DOMMutationBreakpoints.js
const text = L10N.getFormatStr( "noDomMutationBreakpoints", `<a>${L10N.getStr("inspectorTool")}</a>` ); ... dangerouslySetInnerHTML: { __html: text, },This one is simply setting a localized string, not harmful.
What's done is a bit odd:
- wrap the "Inspector" word inside an href-less link
- set the
onClickevent listener on the parent div
I would expect us to only have the click event on the "Inspector" word then
Or make the noDomMutationBreakpoints label to include the "Inspector" word, and have a button below with a "Open inspector" localized string.
Also, this doesn't seem to be covered by a test, would be nice to have one I guess
Comment 5•6 months ago
|
||
Is there some sort of lint we could use to disallow dangerouslySetInnerHTML?
| Assignee | ||
Comment 6•6 months ago
|
||
(In reply to Tom Schuster (Limited availability until May 5) from comment #5)
Is there some sort of lint we could use to disallow
dangerouslySetInnerHTML?
there's already some, we're disabling it here https://searchfox.org/firefox-main/rev/410a52656dd13aa2360a3e96788e41bf48e80c0f/devtools/client/debugger/src/components/SecondaryPanes/DOMMutationBreakpoints.js#112-113,123,125-128
/* eslint-disable react/no-danger */
renderEmpty() {
...
div({
...
dangerouslySetInnerHTML: {
__html: text,
},
})
| Assignee | ||
Comment 7•6 months ago
|
||
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #6)
(In reply to Tom Schuster (Limited availability until May 5) from comment #5)
Is there some sort of lint we could use to disallow
dangerouslySetInnerHTML?there's already some, we're disabling it here https://searchfox.org/firefox-main/rev/410a52656dd13aa2360a3e96788e41bf48e80c0f/devtools/client/debugger/src/components/SecondaryPanes/DOMMutationBreakpoints.js#112-113,123,125-128
/* eslint-disable react/no-danger */ renderEmpty() { ... div({ ... dangerouslySetInnerHTML: { __html: text, }, })
mh not sure actually, if I remove the comment mach lint doesn't complain
Comment 8•6 months ago
|
||
Oh ... I was actually gone ask why there is no annotation on the use in Breakpoint.js.
| Assignee | ||
Comment 9•6 months ago
|
||
Comment 10•6 months ago
|
||
Nicolas, would you mind filing a follow-up security bug to make sure this lint (and maybe others?) are working.
| Assignee | ||
Comment 11•6 months ago
|
||
(In reply to Tom Schuster (Limited availability until May 5) from comment #8)
Oh ... I was actually gone ask why there is no annotation on the use in
Breakpoint.js.
I asked in #Lint And Formatting to see what's going on, I may end up filing a bug
| Assignee | ||
Comment 12•6 months ago
|
||
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #11)
(In reply to Tom Schuster (Limited availability until May 5) from comment #8)
Oh ... I was actually gone ask why there is no annotation on the use in
Breakpoint.js.I asked in
#Lint And Formattingto see what's going on, I may end up filing a bug
I investigated a bit and it looks like the rule only handles JSX, that we're not using anymore (we're using those React DOM factories, which rely on React.createElement)
I'll report upstream and will file a bug to see if we can do something about it in the meantime
| Assignee | ||
Comment 13•6 months ago
|
||
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #11)
I asked in
#Lint And Formattingto see what's going on, I may end up filing a bug
Filed Bug 2036699
Comment 14•6 months ago
|
||
Comment 15•6 months ago
|
||
https://hg-edge.mozilla.org/mozilla-central/rev/4b49342bc824
https://hg-edge.mozilla.org/mozilla-central/rev/26d6e8e3880b
Updated•5 months ago
|
Updated•5 months ago
|
Updated•1 month ago
|
Description
•