GHSL-2021-1034: HTML sanitizer bypass leading to XSS in esdoc-publish-html-plugin - CVE-2021-32858
The HTML sanitizer in esdoc-publish-html-plugin misparses HTML comments, allowing an attacker to bypass sanitisation and inject arbitrary HTML, including script tags, leading to cross-site scripting (XSS).
Originally disclosed on GitHub Security Lab
The esdoc-publish-html-plugin HTML sanitizer can be bypassed which may lead to cross-site scripting (XSS) issues.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
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
The sanitizer's regular expression for comments only matches '<!-- ... -->' and does not account for alternative comment endings like '--!>', so it fails to escape content that browsers treat as a comment.
Impact
This issue may lead to cross-site scripting, allowing an attacker to execute arbitrary JavaScript in the context of a victim's browser when they view generated documentation.
What the attacker needed
Attacker can control markdown input; victim views generated HTML
How it was found
- Install the required packages marked and escape-html.
- Run the provided JavaScript code that replicates the sanitizer logic.
- Observe that the output contains an unescaped script tag inside a comment-like structure.
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.
A sanitizer is a tool that removes dangerous parts from HTML to prevent attacks. Here, the sanitizer thought a comment ended only with '-->', but browsers also accept '--!>', so an attacker could hide malicious code inside a comment that the sanitizer let through. When a victim views the generated documentation, the hidden script runs in their browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.