HTML Injection to Data Exfiltration: Weaponizing CSS
A page allowed HTML input that was sanitised with DOMPurify but still permitted style tags, so an attacker could inject CSS that loads remote fonts per character. When an admin viewed the injected content, the browser fetched those fonts for the hidden secret value, leaking it character by character to the attacker's server.
medium.com
Published on medium.com
Assume there are 2 roles in web application which is vulnerable to HTML Injection — guest, admin.
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 sanitiser's allow-list included the style tag, so attacker-supplied CSS could define custom fonts whose URLs leak which characters are rendered.
Impact
An attacker could disclose sensitive data visible only to an admin, leading to vertical privilege escalation; the leaked characters arrive in parallel and in undefined order, so the value must be reassembled.
What the attacker needed
Ability to submit HTML that an admin views; sanitiser allows style tags; browser loads remote fonts
The fix
The sanitiser should not allow style tags or attacker-controlled CSS, or a strict Content Security Policy should block font loads to external origins.
How it was found
- A guest submits HTML containing a style block with per-character font rules.
- The application sanitises the input but keeps the style tag and stores it.
- An admin loads the page and the injected CSS is rendered.
- The CSS forces the hidden secret element to display using the leak font.
- The browser requests the matching font URL for each character, sending it to the attacker.
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.
Some websites let users submit HTML, and a sanitiser removes dangerous parts like scripts. Here the sanitiser still allowed style rules, so an attacker could add CSS that makes the browser download a different font file for each character of a secret value. Each download goes to the attacker's server, revealing which characters were on the page.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.