Closed Bug 2040120 Opened 6 months ago Closed 5 months ago

Wasm Baseline inline memory.copy omits source-side bounds checks for custom page sizes, causing source OOB reads without trap

Categories

(Core :: JavaScript: WebAssembly, defect, P2)

Firefox 152
defect

Tracking

()

RESOLVED DUPLICATE of bug 2026383
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox151 --- disabled
firefox152 --- disabled
firefox153 --- disabled

People

(Reporter: github, Unassigned)

References

(Blocks 2 open bugs)

Details

(4 keywords)

Attachments

(1 file)

Attached file poc.js —

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36

Steps to reproduce:

  1. Build Firefox with ENABLE_WASM_CUSTOM_PAGE_SIZES enabled (Nightly aarch64 x86_64 defaults include this).
  2. Run SpiderMonkey shell with Baseline compiler path (default) using the attached wasm testcase.
  3. Execute memory.copy with crafted parameters that cause source range to cross custom-page memory boundary: src=5 dst=0 len=12 or src=6 dst=0 len=11 where the first source chunk is in-bounds but later chunks
    exceed memory bounds.

Actual results:

The Baseline inline memory.copy path reused omitted bounds-check state after the first source load. For custom page sizes where offset guard limit is zero, later source loads proceeded without trap even when
crossing memory boundary. Observed output:

VULNERABLE: source OOB src=5 dst=0 len=12: no trap dst[0..3]=70,71,72,73
VULNERABLE: source OOB src=6 dst=0 len=11: no trap dst[0..3]=71,72,73,74

Regression test failed with:
Error: assertion failed: expected exception RuntimeError, no exception thrown

Control tests with FX0003_WASM_COMPILER=optimizing or FX0003_WASM_COMPILER=ion passed, isolating the issue to Baseline inline path.

Expected results:

memory.copy must trap with RuntimeError: index out of bounds when source range crosses wasm memory bounds, regardless of page size configuration. Each source load in the inline copy loop should be bounds-checked
for custom page sizes where offset guard is zero.

Group: core-security → javascript-core-security

This is currently disabled in 153.

Blocks: sm-security
Severity: -- → S3
Priority: -- → P2

The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.

Status: UNCONFIRMED → NEW
Ever confirmed: true

Increasing severity to S2 since this is now a sec-high bug.

Severity: S3 → S2
Duplicate of this bug: 2042761

This is in fact also a duplicate of 2026383.

Status: NEW → RESOLVED
Closed: 5 months ago
Duplicate of bug: 2026383
Resolution: --- → DUPLICATE
No longer duplicate of this bug: 2042761
Group: javascript-core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: