Skip to content
XSS Write-up Advanced

Fontleak

A researcher built a custom font whose ligature substitutions give each character a distinct width, so that CSS alone can measure and leak text from a page. An attacker who can inject CSS could read paragraphs and secrets held in inline scripts, bypassing DOMPurify because style tags are allowed by default.

adragos.ro

Published on adragos.ro

Fontleak is a new technique for quickly exfiltrating text from web pages using only CSS and a carefully crafted font. The threat model is any attacker that can inject arbitrary CSS into a web page.

Dragos Albastroiu, on adragos.ro

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 application allows attacker-controlled CSS (for example style tags surviving DOMPurify) while sensitive data sits in the same document, and font ligatures let CSS turn character content into measurable widths.

Impact

An attacker able to inject CSS could leak paragraph text and secrets from inline scripts, though a strong CSP that blocks outside stylesheets, data fonts, inline styles and outside images would stop it.

What the attacker needed

Attacker can inject CSS into the page; sensitive text in the same document

The fix

Developers should apply a strict CSP, forbid style tags in DOMPurify, and sandbox reflected input in an iframe.

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.

A font can contain rules that swap a sequence of characters for a different symbol, and each symbol can have its own width. By loading a specially made font and measuring how wide a piece of text becomes, a page can work out which characters are present. If an attacker can add their own styling to a page, they can use this to read text they should not see.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.