[WASM] JIT Optimization Triggered Assertion failure: !values_.has(def) (Discarding a definition still in the set)
A crafted WebAssembly module triggers an assertion failure in the JIT value-numbering pass during tier-2 compilation, crashing the JavaScript engine. The text only shows a debug-build assertion, not a demonstrated memory-safety impact.
Originally disclosed on Mozilla
- Fixed in 13 hours
- Paid in 6 days
- Disclosed after 13 hours
Created attachment 9492912
asan_log.txt
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Steps to reproduce:
My env:
Ubuntu 22.04 TLS
8b52ebe3cddf0e63bb42e8b51618bc3ab8dcb12d
Build args:
../configure --disable-jemalloc --enable-fuzzing --enable-gczeal --enable-debug --enable-optimize --disable-shared-js --enable-address-sanitizer
Execution:
./dist/bin/js poc.js
Actual results:
Assertion failure: !values_.has(def) (Discarding a definition still in the set), at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:326
backstrace:
'''
(gdb) bt
#0 0x0000555558929cff in MOZ_CrashSequence (aAddress=0x0, aLine=326) at /data/workspace/gecko-dev/js/src/wasmfuzz/dist/include/mozilla/Assertions.h:248
bt
#1 js::jit::ValueNumberer::discardDef (this=this@entry=0x7ffff6dd3da0, def=def@entry=0x7ffff00232a8, allowEffectful=js::jit::ValueNumberer::AllowEffectful::No)
at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:326
#2 0x00005555589294a4 in js::jit::ValueNumberer::processDeadDefs (this=0x7ffff6dd3da0) at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:386
#3 js::jit::ValueNumberer::discardDefsRecursively (this=this@entry=0x7ffff6dd3da0, def=def@entry=0x7ffff00233c8, allowEffectful=<optimized out>)
at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:257
#4 0x000055555892ccef in js::jit::ValueNumberer::visitDefinition (this=0x7ffff6dd3da0, def=0x7ffff00233c8) at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:809
#5 0x000055555892f315 in js::jit::ValueNumberer::visitBlock (this=0x7ffff6dd3da0, block=block@entry=0x7ffff0022cd0) at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:1027
#6 0x000055555892f791 in js::jit::ValueNumberer::visitDominatorTree (this=this@entry=0x7ffff6dd3da0, dominatorRoot=dominatorRoot@entry=0x7ffff0022cd0)
at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:1081
#7 0x000055555892fe8b in js::jit::ValueNumberer::visitGraph (this=this@entry=0x7ffff6dd3da0) at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:1120
#8 0x0000555558931a23 in js::jit::ValueNumberer::run (this=0x7ffff6dd3da0, updateAliasAnalysis=<optimized out>) at /data/workspace/gecko-dev/js/src/jit/ValueNumbering.cpp:1288
#9 0x0000555558f0f194 in js::jit::OptimizeMIR (mir=mir@entry=0x7ffff6dd56f8) at /data/workspace/gecko-dev/js/src/jit/Ion.cpp:1201
#10 0x00005555593f9eb4 in js::wasm::IonCompileFunctions (codeMeta=..., codeTailMeta=0x55555a3975c0, compilerEnv=..., lifo=..., inputs=..., code=code@entry=0x7ffff001f628, error=0x7ffff6dd8b00)
at /data/workspace/gecko-dev/js/src/wasm/WasmIonCompile.cpp:10780
#11 0x00005555593afd9a in ExecuteCompileTask (task=0x7ffff001f260, error=0x7ffff6dd8b00) at /data/workspace/gecko-dev/js/src/wasm/WasmGenerator.cpp:613
#12 0x00005555593b2b9a in js::wasm::ModuleGenerator::locallyCompileCurrentTask (this=0x7ffff6dd6ce8) at /data/workspace/gecko-dev/js/src/wasm/WasmGenerator.cpp:712
#13 js::wasm::ModuleGenerator::finishFuncDefs (this=0x7ffff6dd6ce8) at /data/workspace/gecko-dev/js/src/wasm/WasmGenerator.cpp:849
#14 0x000055555935bb6a in js::wasm::CompilePartialTier2 (code=..., funcIndex=2, error=error@entry=0x7ffff6dd8b00, warnings=warnings@entry=0x7ffff6dd8b10, cancelled=cancelled@entry=0x55555a5200c4)
at /data/workspace/gecko-dev/js/src/wasm/WasmCompile.cpp:1103
#15 0x0000555559375840 in js::wasm::Module::PartialTier2CompileTaskImpl::runHelperThreadTask (this=0x55555a5200b0, locked=...) at /data/workspace/gecko-dev/js/src/wasm/WasmCode.cpp:648
#16 0x000055555758f1ea in js::GlobalHelperThreadState::runTaskLocked (this=0x55555a39acb0, task=0x55555a5200b0, locked=...) at /data/workspace/gecko-dev/js/src/vm/HelperThreads.cpp:668
#17 0x000055555758f041 in js::GlobalHelperThreadState::runOneTask (this=0x7ffff7ae0a60 <_IO_stdfile_2_lock>, task=0x0, lock=...) at /data/workspace/gecko-dev/js/src/vm/HelperThreads.cpp:624
#18 0x00005555575e071c in js::HelperThread::threadLoop (this=this@entry=0x55555a39c480, pool=pool@entry=0x55555a39c3e0) at /data/workspace/gecko-dev/js/src/vm/InternalThreadPool.cpp:324
#19 0x00005555575e020d in js::HelperThread::ThreadMain (pool=0x55555a39c3e0, helper=0x55555a39c480) at /data/workspace/gecko-dev/js/src/vm/InternalThreadPool.cpp:251
#20 0x00005555575fff06 in js::detail::ThreadTrampoline<void (&)(js::InternalThreadPool*, js::HelperThread*), js::InternalThreadPool*&, js::HelperThread*>::callMain<0ul, 1ul> (this=0x55555a39c4f0)
at /data/workspace/gecko-dev/js/src/threading/Thread.h:228
#21 js::detail::ThreadTrampoline<void (&)(js::InternalThreadPool*, js::HelperThread*), js::InternalThreadPool*&, js::HelperThread*>::Start (aPack=0x55555a39c4f0)
at /data/workspace/gecko-dev/js/src/threading/Thread.h:217
#22 0x00007ffff7958ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
--Type <RET> for more, q to quit, c to continue without paging--bt
'''
Expected results:
exit normally
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 the value-numbering pass discards a definition that is still tracked in its set, so a later dead-definition cleanup trips the invariant.
Impact
A crafted WebAssembly module could crash the engine in a debug build; the text does not show whether release builds are affected or whether memory corruption is possible.
What the attacker needed
Debug build with assertions; attacker-supplied wasm module
How it was found
- Build the engine with the listed debug and sanitiser options.
- Run the supplied proof-of-concept script with the built shell.
- Observe the assertion failure during WebAssembly tier-2 compilation.
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.
WebAssembly lets programs run near-native code in the browser, and the engine compiles it with an optimiser called the JIT. Here a specially crafted module confused the optimiser's bookkeeping, so a debug check fired and the engine aborted. The report only shows a crash in a debug build, not proof that an attacker could run their own code.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.