GHSL-2020-098: Potential mXSS in ZeptoJS
Zepto.JS contains a port of jQuery's htmlPrefilter function, which can mutate sanitised HTML into dangerous HTML. An attacker could exploit this to achieve cross-site scripting (mXSS) if an application sanitises untrusted HTML and then passes it to Zepto's fragment function.
Originally disclosed on GitHub Security Lab
Latest vulnerable version: 1.2.0 (master, b5ed8d607f67724788ec9ff492be297f64d47dfc)
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
Likely the htmlPrefilter function uses a regular expression to expand self-closing tags, which can alter the structure of sanitised HTML and reintroduce executable code.
Impact
This issue may lead to a Cross-Site Scripting vulnerability (mXSS).
What the attacker needed
Application sanitises untrusted HTML; sanitised HTML passed to Zepto fragment
How it was found
- Include the Zepto.js library in a web page.
- Call the $.zepto.fragment function with a crafted HTML string that contains a self-closing tag and an event handler.
- Observe that the HTML mutates and the event handler executes, showing an alert.
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.
Some websites clean user-supplied HTML to remove dangerous code before displaying it. Zepto.JS, a JavaScript library, has a function that can accidentally turn that cleaned HTML back into dangerous HTML. This means an attacker could inject a script that runs in a victim's browser, a type of attack called cross-site scripting (XSS).
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.