Skip to content
Info disclosure Disclosed report Advanced CVE-2021-29982

Differential Testing: Different output during TypeError

A JavaScript test case produces different results depending on whether the IonMonkey JIT compiler is enabled: with Ion disabled, two exceptions are thrown and a counter remains 0; with Ion enabled, the second call may or may not throw, leaving the counter at 0 or 1. The reporter suspects a security-relevant differential execution bug.

lukas.bernhard Follow

Originally disclosed on Mozilla

  • Fixed in 7 days
  • Paid in 28 days
  • Disclosed after 7 days
Text
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0

Steps to reproduce:

The following testcase produces different results on mozilla-central git commit 0e97d943bc746e4fd92902b21d3d5bebfef885a1 depending on whether ion is enabled or disabled.
'''
function main() {
    let v1 = 0;
    function v18() {
        for (let v35 = 0; v35 < 100; v35++) {}

        try {
            async function* v37() {}
            class V47 extends v37 {}; 
            v1 += 1;
        }   
        catch (e) {
            print("caught: " + e); 
        }   
    };  
    v18();
    v18();  // second call may or may not reach catch handler, approx 50/50
    print(v1); // either 0 or 1
}
main();
'''


Actual results:

Running the sample with ion disabled (obj-x86_64-pc-linux-gnu/dist/bin/js --no-threads --cpu-count=1 --baseline-warmup-threshold=10 --fuzzing-safe --differential-testing --no-ion diff.js) causes two exceptions to be thrown, v1 is 0 at the end of main().

If ion is enabled (obj-x86_64-pc-linux-gnu/dist/bin/js --no-threads --cpu-count=1 --ion-offthread-compile=off --baseline-warmup-threshold=10 --ion-warmup-threshold=100 --ion-check-range-analysis --ion-extra-checks --fuzzing-safe --differential-testing diff.js), the second execution of v18() may or may not (approx. 50/50) throw an exception. v1 is either 0 or 1 at the end of main().

Marking as security as a few differential execution bugs were flagged in the past.

The original report as published on Mozilla's Bugzilla, by lukas.bernhard. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 an inconsistency in how the JIT compiler handles exceptions thrown during class inheritance from an async generator, leading to different control flow.

Impact

The inconsistency could potentially be exploited to cause unexpected behaviour in the JavaScript engine, but the report does not demonstrate a concrete security impact.

What the attacker needed

Ability to run the JavaScript engine with specific flags; Ion JIT compiler enabled or disabled

How it was found

  1. Run the provided JavaScript test case with Ion disabled using the given command-line flags.
  2. Observe that two exceptions are thrown and the counter v1 is 0.
  3. Run the same test case with Ion enabled using the given command-line flags.
  4. Observe that the second call may or may not throw, and v1 is either 0 or 1.

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.

This is a bug report for the JavaScript engine in Firefox. The same small program gives different results depending on whether a performance feature (the JIT compiler) is turned on. That inconsistency could be a security problem because attackers might exploit such differences.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by lukas.bernhard

View all

16 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.