Open Bug 519418 Opened 17 years ago Updated 5 years ago

<body> event listeners not deactivated after removeAttribute("onevent")

Categories

(Core :: DOM: Events, defect, P5)

defect

Tracking

()

People

(Reporter: reed, Unassigned)

References

()

Details

(Keywords: html5, testcase, Whiteboard: marginal xss hazard?)

Attachments

(5 files)

Hallvord R. M. Steen of Opera's core QA team reported the following issue to security@ on Tue, 29 Sep 2009 10:44:27 +0000: -------------------------------------------------------- Hi, Ian asked me to let you know about this issue: http://www.w3.org/Bugs/Public/show_bug.cgi?id=7626 I am a bit confused because in my initial testing it seemed Firefox did deactivate the event listeners. Ian claims his testing showed the opposite. (I tested with P mouseover, he with BODY onload/onclick, might be an inconsistency there). Please refer to the HTML5 spec bug for further details.
Flags: blocking1.9.2?
Whiteboard: [sg:investigate]
So what is the XSS issue here?
(In reply to comment #1) > So what is the XSS issue here? http://www.w3.org/Bugs/Public/show_bug.cgi?id=7626#c5 talks about some problems. I can ask Hallvord for a better testcase if you need it.
Note, we don't add event listener if onfoo attribute is in a data document (which for example DOMParser creates).
We deactivate listeners on nodes. We don't deactivate the ones that map to Window (the ones on <body>). The XSS things described in the w3.org bug is irrelevant to us per comment 3, especially because that procedure can't possibly create a <body> that maps its event listeners to the Window during parsing. So I think this bug is invalid (as in, no XSS issue) and should be opened up.
Testcase links from the w3.org bug for convenience http://software.hixie.ch/utilities/js/live-dom-viewer/saved/245 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/247 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/248 (Does this bug need to remain hidden? It's our version of the public w3 bug, even if there is a valid XSS issue.)
I don't think it does.
I'm dubious that a body event listener continuing to work after you've removed it is much of an XSS issue[*], but it seems buggy and inconsistent to treat body event listeners differently than node event listeners. Let's just make this an HTML5 correctness issue. Does this need [HTML5] in the summary, or is that only for the HTML 5 parser issues? [*] to be an XSS issue we're supposing a page that is broken enough to allow an injected <body> element event listener but smart enough to know it might be broken and going through and removing those attributes from the DOM (rather than, say, filtering the generated HTML before shipping it off to clients). And doing so in a way that can't be defeated by an injection that knows that's what the page does.
Group: core-security
Keywords: html5
Summary: Potential XSS issue when keeping event listeners alive after removeAttribute("onevent") → <body> event listeners not deactivated after removeAttribute("onevent")
Whiteboard: [sg:investigate] → marginal xss hazard?
Not blocking on this issue.
Flags: wanted1.9.2+
Flags: wanted-next+
Flags: blocking1.9.2?
Flags: blocking1.9.2-
Oops, I dropped the ball on updating this bug with what Hallvord replied. This is from Hallvord's reply to me. I'll attach his testcases shortly. ========================= > Also, one of our engineers says the following: "Note, we don't add > event listener if onfoo attribute is in a data document (which for > example DOMParser creates)." Aha, that probably explains why the author hit a potential XSS vector in Opera but not in Gecko. You might want to consider this bug just an align-with-HTML5 bug rather than a security issue, then. (Also note that Boris points out in the bug report that the BODY events Ian tested are somewhat special in Gecko..) I think the problem might still arise if a script author does something like this: var user_supplied_text='<p onmouseover="alert(\'FAIL\')">move mouse here</p>'; var div=document.createElement('div'); div.innerHTML=user_supplied_text; // code to remove potentially dangerous elements and attributes here, // including this: div.firstChild.removeAttribute('onmouseover'); document.body.appendChild(div); But I have no evidence that such code is used for input sanitation and if Boris is right that the problem is only about the magic BODY events the above would in fact be safe in Gecko. Please test and prioritize the bug as you wish :)
Attached file testcase #1 —
Attached file testcase #2 —
Attached file testcase #3 —
Attached file testcase #4 —
Attached file testcase #5 —
Keywords: testcase

Bulk-downgrade of unassigned, 4 years untouched DOM/Storage bugs' priority.

If you have reason to believe this is wrong (especially for the severity), please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: