Assert: abs(dst - src) >= ptrdiff_t(nelem) or crash in JSString::flatten
Originally disclosed on Mozilla
- Fixed in 14 days
- Paid in 2.6 years
- Disclosed after 14 days
The attached testcase (tested on TM trunk, soon to land in mc) demonstrates a serious memory corruption. In debug shell, the testcase either triggers the assertion
Assertion failure: abs(dst - src) >= ptrdiff_t(nelem), at jsutil.h:362
or crashes. An optimized build crashes straight away, the backtrace shows that this is due to a memcpy:
Program received signal SIGSEGV, Segmentation fault. 0x00007ffff6f4001b in memcpy () from /lib/libc.so.6 (gdb) bt #0 0x00007ffff6f4001b in memcpy () from /lib/libc.so.6 #1 0x00000000004fa4ae in JSString::flatten(JSContext*) () #2 0x0000000000419c28 in js::RegExp::executeInternal(JSContext*, js::RegExpStatics*, JSString*, unsigned long*, bool, js::Value*) () #3 0x00000000004fbcc3 in DoMatch(JSContext*, js::RegExpStatics*, js::Value*, JSString*, RegExpPair const&, bool ()(JSContext, js::RegExpStatics*, unsigned long, void*), void*, MatchControlFlags) () #4 0x0000000000505e4a in js::str_replace(JSContext*, unsigned int, js::Value*) () #5 0x000000000060ec83 in js::Interpret(JSContext*, JSStackFrame*, unsigned int, JSInterpMode) () #6 0x0000000000478d54 in js::Execute(JSContext*, JSObject*, JSScript*, JSStackFrame*, unsigned int, js::Value*) () #7 0x0000000000412106 in JS_ExecuteScript () #8 0x000000000040788b in Process(JSContext*, JSObject*, char*, int) () #9 0x0000000000408643 in Shell(JSContext*, int, char**, char**) () #10 0x0000000000408948 in main ()
The crash originates from this change in trunk:
The first bad revision is: changeset: 58610:1d1fe1d1e626 user: Luke Wagner <[address removed]> date: Mon Dec 06 10:26:58 2010 -0800 summary: Bug 609440, part 4 - make JSString::chars() fallible (r=waldo,dvander,igor,dwitte,njn)
Flagged as security bug because this bug is highly likely to be exploitable.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A doS bug in JavaScript Engine. Mozilla made it public on 7 January 2011.
About DoS
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
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.