Closed Bug 2030774 Opened 7 months ago Closed 7 months ago

[JSPI] Potential stale WasmArrayData pointer on suspended JSPI stack across minor GC in optimizing wasm tier

Categories

(Core :: JavaScript: WebAssembly, defect)

defect

Tracking

()

RESOLVED DUPLICATE of bug 2008358

People

(Reporter: gaddofpwn, Unassigned)

References

Details

(Keywords: reporter-external, unsupported-config, Whiteboard: [client-bounty-form])

Attachments

(1 file)

The issue appears to be that suspended wasm stacks are traced during GC, but their WasmArrayData/WasmStructData stack slots are not updated by the moving-GC patch-up path. As a result, after resuming from a suspended stack, wasm code can continue using stale data pointers.

On my local Linux x86_64 build, this reproduces as a corrupted array read in optimized wasm code after a suspend/resume cycle that triggers minor GC. The final result becomes a poisoned-looking value instead of the expected integer sum.

Environment

  • Platform: Linux x86_64
  • Reproduced with SpiderMonkey shell at:
    /home/user/firefox/obj-x86_64-pc-linux-gnu/dist/bin/js
    Configuration
    This currently reproduces with:
  • pref: javascript.options.wasm_js_promise_integration=true
  • shell arg: --wasm-compiler=optimizing

Steps to Reproduce
obj-x86_64-pc-linux-gnu/dist/bin/js
--setpref=wasm_js_promise_integration=true
--wasm-compiler=optimizing
scratch/jspi-suspended-array-standalone.js

Flags: sec-bounty?
Group: firefox-core-security → javascript-core-security
Component: Security → JavaScript: WebAssembly
Product: Firefox → Core

Actual Security Impact

This looks like a stale pointer / use-after-move condition on suspended wasm stacks in the optimizing tier. The immediate symptom is
an incorrect read from wasm GC array storage after resume. I have not developed a full exploit, but the bug appears to violate memory
safety and seems potentially exploitable.

Root Cause Analysis

The relevant paths appear to be:

  • Active wasm activations get moving-GC stack-slot patch-up via UpdateJitActivationsForMinorGC / UpdateJitActivationsForCompactingGC
    and Instance::updateFrameForMovingGC.
  • Suspended JSPI stacks are traced separately via TraceSuspendableStack during GC.
  • That trace path calls Instance::traceFrame, which traces AnyRef values but does not patch WasmArrayDataPointer / StructDataPointer
    stack-map entries.
  • Optimizing wasm safepoints explicitly record ArrayDataPointer / StructDataPointer in stack maps.
  • The wasm optimizer also assumes array data pointers are rewritten by GC across calls.

In other words, suspended stacks seem to go through “trace” but not “moving-GC pointer rewrite”, which leaves stale wasm data
pointers live across suspend/resume.

Blocks: wasm-jspi
Summary: Potential stale WasmArrayData pointer on suspended JSPI stack across minor GC in optimizing wasm tier → [JSPI] Potential stale WasmArrayData pointer on suspended JSPI stack across minor GC in optimizing wasm tier

Thanks for the report! This is a duplicate of bug 2008358.

Status: UNCONFIRMED → RESOLVED
Closed: 7 months ago
Duplicate of bug: 2008358
Resolution: --- → DUPLICATE
Flags: sec-bounty? → sec-bounty-
Group: javascript-core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: