Closed Bug 1904644 (CVE-2024-7521) Opened 1 year ago Closed 1 year ago

Assertion failure: iter->done(), at js/src/jit/JitFrames.cpp:695

Categories

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

defect

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox-esr115 129+ fixed
firefox-esr128 129+ fixed
firefox127 --- wontfix
firefox128 --- wontfix
firefox129 + fixed
firefox130 + fixed

People

(Reporter: sm-bugs, Assigned: jandem)

References

(Blocks 2 open bugs)

Details

(4 keywords, Whiteboard: [adv-main129+][adv-ESR115.14+][adv-ESR128.1+])

Attachments

(5 files)

Attached file bug.js

Steps to reproduce:

Checkout commit 9fcc11127fbfbdc88cbf37489dac90542e141c77 and invoke the js shell as follows:

js --fuzzing-safe <test-case>

Actual results:

Assertion failure: iter->done(), at js/src/jit/JitFrames.cpp:695
Blocks: 1903968
Group: firefox-core-security → core-security
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Version: Firefox 127 → Trunk
Group: core-security → javascript-core-security

We have a Wasm => JS JIT call and the JS code throws an exception. The Wasm code catches the exception but it looks like the exception handler code then doesn't expect that to happen (it's not just the assertion, the trampoline code calling the exception handler also seems incomplete). A bit surprising because I'd have expected tests, fuzzers, or websites to have hit this by now.

var throwExc = false;
var e = {m: {foreign() {
    if (throwExc) {
        throw new TypeError("hi");
    }
}}};
var bin = wasmTextToBinary(`(module(import "m" "foreign" (func $foreign))(func (export "f") try(call $foreign)end))`);
var mod = new WebAssembly.Module(bin);
var inst = new WebAssembly.Instance(mod, e);
for (var i = 0; i < 20; i++) {
    inst.exports.f();
}
throwExc = true;
inst.exports.f();
Component: JavaScript Engine → JavaScript: WebAssembly
Flags: needinfo?(jdemooij)
Assignee: nobody → jdemooij
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(jdemooij)

I'm not able to view that Phabricator link, so maybe the permissions are off somehow.

How bad of a security issue is this? I can't tell from the comments in this bug so far. Thanks.

Flags: needinfo?(jdemooij)

I am able to view the Phabricator link now. It looks like phab-bot just updated it.

(In reply to Andrew McCreight [:mccr8] from comment #3)

How bad of a security issue is this? I can't tell from the comments in this bug so far. Thanks.

I'll say sec-high because we jump to a Wasm catch handler with garbage in the instance register. A local non-debug build crashes like this:

   0x852ac69d101:       mov    0x48(%r14),%rcx
=> 0x852ac69d105:       testl  $0x1,(%rcx)

(rr) p/x $rcx
$1 = 0xe5e5e5e5e5e5e5e5
Flags: needinfo?(jdemooij)
Keywords: sec-high
Blocks: sm-security
Severity: -- → S2
Priority: -- → P1
Flags: sec-bounty?

Comment on attachment 9409677 [details]
Bug 1904644 - Share more exception handling code. r?rhunt!

Security Approval Request

  • How easily could an exploit be constructed based on the patch?: It's not super easy but probably also not very difficult.
  • Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: No
  • Which branches (beta, release, and/or ESR) are affected by this flaw, and do the release status flags reflect this affected/unaffected state correctly?: All
  • If not all supported branches, which bug introduced the flaw?: None
  • Do you have backports for the affected branches?: Yes
  • If not, how different, hard to create, and risky will they be?: Should apply or be easy to backport.
  • How likely is this patch to cause regressions; how much testing does it need?: Not very likely, but exception handling is complicated.
  • Is the patch ready to land after security approval is given?: Yes
  • Is Android affected?: Yes
Attachment #9409677 - Flags: sec-approval?

It's too late to get this into Fx128, and it's a bad candidate to be a "ride-along" in the mid-cycle point release because we don't schedule a mid-cycle release for the ESR branch(es). We should wait until after the release to land this.

Has STR: --- → yes
Keywords: testcase
Whiteboard: [reminder-secapprove 2024-07-14][reminder-test 2024-09-09]

Comment on attachment 9409677 [details]
Bug 1904644 - Share more exception handling code. r?rhunt!

sec-approval+ = dveditz
please request beta uplift, and esr after we get some nightly/beta confidence

Attachment #9409677 - Flags: sec-approval? → sec-approval+
Whiteboard: [reminder-secapprove 2024-07-14][reminder-test 2024-09-09] → [reminder-test 2024-09-09]
Flags: needinfo?(jdemooij)
Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/821842bd3d34 Share more exception handling code. r=rhunt
Group: javascript-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch

:jandem could you add beta, ESR115, and ESR128 uplift requests on this when ready?

Comment on attachment 9409677 [details]
Bug 1904644 - Share more exception handling code. r?rhunt!

Beta/Release Uplift Approval Request

  • User impact if declined: Security bugs, crashes.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Complicated code but changes are fairly straight-forward. The problematic case that's being fixed isn't used much in the wild at this point.
  • String changes made/needed: N/A
  • Is Android affected?: Yes
Flags: needinfo?(jdemooij)
Attachment #9409677 - Flags: approval-mozilla-esr128?
Attachment #9409677 - Flags: approval-mozilla-esr115?
Attachment #9409677 - Flags: approval-mozilla-beta?

I added the approval requests. This might not apply cleanly to the older branches - I can upload separate patches for these if it's an issue.

It'll need a bit of rebasing for ESR115. The other branches graft cleanly.

Flags: needinfo?(jdemooij)

Comment on attachment 9409677 [details]
Bug 1904644 - Share more exception handling code. r?rhunt!

Approved for 129.0b7

Attachment #9409677 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9409677 - Flags: approval-mozilla-esr115?
QA Whiteboard: [post-critsmash-triage]
Flags: qe-verify-
Flags: needinfo?(jdemooij)
Attachment #9414107 - Flags: approval-mozilla-esr115?

(In reply to Ryan VanderMeulen [:RyanVM] from comment #16)

It'll need a bit of rebasing for ESR115. The other branches graft cleanly.

I posted a patch for ESR115. Fortunately it was just a single minor conflict. I also verified the tests fail on ESR115 and are fixed by this patch.

Comment on attachment 9409677 [details]
Bug 1904644 - Share more exception handling code. r?rhunt!

Approved for 128.1esr.

Attachment #9409677 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+

Comment on attachment 9414107 [details]
Bug 1904644 - Share more exception handling code. r=rhunt!, a=dmeehan (ESR115)

Approved for 115.14esr

Attachment #9414107 - Flags: approval-mozilla-esr115? → approval-mozilla-esr115+
Flags: sec-bounty? → sec-bounty+
Whiteboard: [reminder-test 2024-09-09] → [reminder-test 2024-09-09][adv-main129+]
Whiteboard: [reminder-test 2024-09-09][adv-main129+] → [reminder-test 2024-09-09][adv-main129+][adv-ESR115.14+]
Whiteboard: [reminder-test 2024-09-09][adv-main129+][adv-ESR115.14+] → [reminder-test 2024-09-09][adv-main129+][adv-ESR115.14+][adv-ESR128.1+]
Attached file advisory.txt
Alias: CVE-2024-7521

2 months ago, dveditz placed a reminder on the bug using the whiteboard tag [reminder-test 2024-09-09] .

jandem, please refer to the original comment to better understand the reason for the reminder.

Flags: needinfo?(jdemooij)
Whiteboard: [reminder-test 2024-09-09][adv-main129+][adv-ESR115.14+][adv-ESR128.1+] → [adv-main129+][adv-ESR115.14+][adv-ESR128.1+]
Flags: needinfo?(jdemooij)
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: