Able to escape HTML comments by using a comment within a comment
A parser differential in HTML comment handling allowed an attacker to escape a comment and inject markup that executes in Firefox but not in Chrome or Safari. This could lead to cross-site scripting if user-controlled content is placed inside an HTML comment.
Originally disclosed on Mozilla
- Fixed in 5 months
- Paid in 5 months
- Disclosed after 5 months
I just used the following trick to fool a parser and got an XSS on a Bug Bounty-target. Firefox parsing differ from Chrome and Safari.
POC: https://playground.zulln.se/poc/firefox/commentwithincomment.html
Source code of POC:
'''
Visible in all browsers. <!-- <br>Not visible in any browser <!--k-> <br>Visible in Firefox. --> <br> Visible in all browsers.
'''
The letter k within the comment in the middle of the poc can be any character.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the HTML parser in Firefox incorrectly handles nested comment-like sequences, allowing a comment to be closed early and subsequent markup to be interpreted as active content.
Impact
An attacker could execute arbitrary JavaScript in the context of a vulnerable site when a victim uses Firefox, potentially leading to data theft or account compromise.
What the attacker needed
Victim uses Firefox; attacker can inject content into an HTML comment
How it was found
- Create an HTML page with a comment containing a nested comment-like sequence.
- Load the page in Firefox and observe that content after the nested comment is rendered.
- Load the same page in Chrome or Safari and observe that the content remains hidden.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
HTML comments are meant to hide content from the browser, but different browsers can disagree on where a comment ends. Here, a comment inside a comment confused Firefox, letting hidden code become active and run as a script. This is dangerous because an attacker could inject such code to steal data or perform actions as the victim.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.