Exploiting XSS via Markdown on Xiaomi
The Xiaomi Forum comment section allowed users to post Markdown that was converted to HTML without proper sanitisation. An attacker could inject an event handler attribute into an image tag, leading to stored cross-site scripting when a victim hovered over the image.
Bahasa Indonesia | English
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 write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the Markdown-to-HTML converter did not sanitise user-supplied attributes, allowing event handlers to be injected.
Impact
An attacker could execute arbitrary JavaScript in the context of the forum when a victim hovers over a crafted image, potentially leading to actions such as redirection or data theft.
What the attacker needed
Ability to post comments on Xiaomi Forum; victim hovers over the image
How it was found
- Post an image using Markdown image syntax in a comment.
- Observe the server converts it to an HTML image tag.
- Try adding a double quote after the image URL to break out of the attribute.
- Notice the server encodes the double quote to %22.
- Use mixed case in the event handler name to bypass filtering.
- Craft a payload that sets an onmouseover event to redirect to another site.
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 write-up has not been written yet. The Original tab links to the source.
Markdown is a simple way to format text that gets turned into web page code. The forum let people post Markdown, but it did not clean up the resulting HTML properly. This meant someone could sneak in a small piece of JavaScript that runs when another user interacts with the post, which is 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.