Skip to content
Memory corruption Disclosed report Advanced

Differential Testing: Different output message involving RegExp and --fast-warmup

A JavaScript engine's string split with a regular expression produced different output depending on whether the --fast-warmup JIT flag was enabled, indicating a correctness bug in the JIT compiler. An attacker could potentially rely on this miscompilation to cause incorrect program behaviour, though the report does not demonstrate a security impact.

Gary Kwong Follow

Originally disclosed on Mozilla

  • Fixed in 12 hours
  • Paid in 6 days
  • Disclosed after 12 hours
Text
'''
"x".split(RegExp())
"x".split(RegExp())
"x".split(RegExp())
"x".split(RegExp("[^]"))
"x".split(RegExp())
"x".split(RegExp())
"x".split(RegExp())
"x".split(RegExp())
print("\ue531\ue531\ue5310n".split(RegExp("\\d[^]")))
'''

stdout: (also happens when you pass it in as a testcase)

'''
$ ./js-dbg-64-linux-x86_64-89aa2c8696b7 --fuzzing-safe --differential-testing --no-threads
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp("[^]"))
["", ""]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> print("\ue531\ue531\ue5310n".split(RegExp("\\d[^]")))
111,
js> 

$ ./js-dbg-64-linux-x86_64-89aa2c8696b7 --fuzzing-safe --differential-testing --no-threads --fast-warmup
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp("[^]"))
["", ""]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> "x".split(RegExp())
["x"]
js> print("\ue531\ue531\ue5310n".split(RegExp("\\d[^]")))
,
js> 
'''

'''
The first bad revision is:
changeset:   https://hg.mozilla.org/mozilla-central/rev/962e589d9931
user:        Tooru Fujisawa
date:        Tue Jan 11 17:40:22 2022 +0000
summary:     Bug 1745664 - Part 2: Add length-3 static string for 100-255 range. r=nbp
'''

Compile with `AR=ar sh ./configure --enable-debug --with-ccache --enable-gczeal --enable-debug-symbols --disable-bootstrap --disable-tests`, tested on m-c rev 89aa2c8696b7.

Setting s-s to be safe as a start as this involves a JIT flag (`--fast-warmup`) that is present in `fuzz-flags.txt`.

The original report as published on Mozilla's Bugzilla, by Gary Kwong. 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 a JIT compiler miscompilation introduced by a change adding a static string for a certain character range, causing different results with --fast-warmup.

What the attacker needed

Debug build of the JS shell; run with --differential-testing; run with --fast-warmup

How it was found

  1. Run the debug shell with differential testing and no threads, and execute the split expressions to see the baseline output.
  2. Run the same shell again with the --fast-warmup flag added.
  3. Compare the outputs of the final print statement between the two runs.

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.

A JavaScript engine runs code either by interpreting it or by compiling it to faster machine code (a JIT compiler). This report shows that turning on a compiler warm-up option changed the result of a simple string split, meaning the compiled version behaved differently from the interpreted one. That kind of mismatch is a bug because programs can get wrong answers depending on how they are run.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Gary Kwong

View all

42 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.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.