MOZ_CRASH in [@ js::gc::detail::AssertCellIsNotGray] after pre-barrier verifier snapshot OOM leaves gray bits flagged valid
Categories
(Core :: JavaScript: GC, defect, P3)
Tracking
()
People
(Reporter: bugmon, Assigned: jonco)
References
(Blocks 1 open bug)
Details
(Keywords: crash, testcase)
Attachments
(5 files, 1 external file, 4 obsolete files)
Found by a scan of commit 91d11128a6b5489e4ef1077242187278b3cbf510. The scan that produced this finding was directed at the changes landed by that commit, which may or may not be its actual cause. Please judge independently whether they are really connected.
GCRuntime::startVerifyPreBarriers() (js/src/gc/Verifier.cpp) calls ClearMarkBits<AllZonesIter>() before it allocates and fills the fixed 64 MB verifier snapshot, but its oom label — taken when the snapshot buffer or node map overflows — only resets incrementalState and deletes the tracer without calling setGrayBitsInvalid(), so the gray mark bits have been wiped while GCRuntime::grayBitsValid stays true (only the normal endVerifyPreBarriers() completion invalidates them). A script that overflows the snapshot with verifyprebarriers() and then runs an atoms-only GC can hand a gray Symbol back to JS, where CanCheckGrayBits() still trusts grayBitsValid and js::gc::detail::AssertCellIsNotGray hits MOZ_CRASH("AssertCellIsNotGray: Found gray JS Symbol") at js/src/gc/GC.cpp:6101 (JS_GC_ZEAL builds only, i.e. debug by default).
Exploit Chain
- Allocate ~2,000,000 objects so the pre-barrier verifier's 64 MB snapshot buffer overflows.
- grayRoot().a = Symbol(); gc(); — full GC marks the gray root object and the Symbol gray; grayBitsValid is true.
- verifyprebarriers() — startVerifyPreBarriers clears all mark bits, then hits the oom label because the snapshot overflows; grayBitsValid remains true and no barriers are enabled.
- schedulezone("abc"); startgc(); — atoms-zone-only GC re-marks the Symbol gray via gray roots while the main-zone root object stays white.
- String(grayRoot().a) — reading the property yields the gray Symbol; JS::CallArgs::create calls AssertValueIsNotGray, CanCheckGrayBits returns true, and MOZ_CRASH fires at js/src/gc/GC.cpp:6101.
Affected Code
- js/src/gc/Verifier.cpp, line 226-287
- js/src/gc/Verifier.cpp, line 420-423
- js/src/gc/GC.cpp, line 6021-6023
- js/src/gc/GC.cpp, line 6072-6101
Steps to Reproduce
- Build the SpiderMonkey debug shell with /app/mozconfigs/mozconfig.js.linux.debug from an unmodified tree.
- Save the testcase as testcase.js:
var a = [];
for (var i = 0; i < 2000000; i++) {
a.push({});
}
grayRoot().a = Symbol();
gc();
verifyprebarriers();
schedulezone("abc");
startgc();
String(grayRoot().a); - Run via js_shell_evaluator (js --fuzzing-safe testcase.js). No extra flags, prefs, or patches.
- Observe: Hit MOZ_CRASH(AssertCellIsNotGray: Found gray JS Symbol ...) at js/src/gc/GC.cpp:6101.
- Control: with 2000 objects instead of 2000000, or with the verifyprebarriers() line removed, the script prints Symbol() and exits normally.
Security Impact
- Severity: Low
- Attacker capability: Trigger a GC invariant violation (a gray cell reaching JavaScript while the runtime believes gray bits are valid), observed as a MOZ_CRASH in the debug shell. No memory corruption was demonstrated.
- Preconditions: Requires a build with JS_GC_ZEAL (default only for debug builds per js/moz.configure:451-456) and the ability to invoke the pre-barrier verifier (verifyprebarriers shell function or GC zeal mode) on a heap large enough to overflow the 64 MB verifier snapshot. Not reachable in shipping release builds.
The full analysis report is attached (analysis.md).
| Reporter | ||
Comment 1•2 months ago
|
||
| Reporter | ||
Comment 2•2 months ago
|
||
| Reporter | ||
Comment 3•2 months ago
|
||
| Reporter | ||
Comment 4•2 months ago
|
||
| Reporter | ||
Comment 5•2 months ago
|
||
| Reporter | ||
Comment 6•2 months ago
|
||
| Reporter | ||
Comment 7•2 months ago
|
||
| Reporter | ||
Comment 8•2 months ago
|
||
| Reporter | ||
Comment 9•2 months ago
|
||
Comment 10•2 months ago
|
||
This bug was filed automatically by an AI-powered security testing tool. The analysis, testcase, and any suggested patches were generated by an AI model and have NOT been verified by a human.
Please review all details carefully before triaging. The issue was confirmed by an independent verifier, but for non-ASAN issues, the verifier has been made less strict. Additionally, the root cause analysis and suggested fix may contain errors.
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Comment 11•2 months ago
|
||
Requires a gc-zeal build.
| Assignee | ||
Comment 12•2 months ago
|
||
The testcase demonstrates how we can get into an invalid gray marking state
after pre-barrier verification has cleared all mark bits. Update the verifier
to set gray marking state to invalid at the start rather than at the end.
This also does a drive-by change to make the verifier to use UniquePtr for the
tracer rather than new/delete.
Updated•2 months ago
|
Comment 13•2 months ago
|
||
Comment 14•2 months ago
|
||
| bugherder | ||
Updated•2 months ago
|
Description
•