Closed
Bug 615657
(CVE-2011-0054)
Opened 14 years ago
Closed 14 years ago
Buffer overflow/Memory corruption: cg->upvarList.count <= cg->upvarMap.length
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: decoder, Assigned: brendan)
Details
(Keywords: reporter-external, verified1.9.1, verified1.9.2, Whiteboard: [sg:critical] fixed-in-tracemonkey)
Attachments
(9 files)
740 bytes,
application/javascript
|
Details | |
12.01 KB,
text/plain
|
Details | |
4.72 KB,
text/plain
|
Details | |
3.47 KB,
text/plain
|
Details | |
7.59 KB,
text/plain
|
Details | |
843 bytes,
text/html
|
Details | |
1.61 KB,
patch
|
dmandelin
:
review+
|
Details | Diff | Splinter Review |
1.21 KB,
patch
|
dveditz
:
approval1.9.1.17+
|
Details | Diff | Splinter Review |
1.22 KB,
patch
|
dveditz
:
approval1.9.2.14+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.10 (maverick) Firefox/3.6.12
Build Identifier:
The following problem affects all Spidermonkey versions I tested (1.9.2 and 2.0) and hence Firefox 3.5.x and Firefox 4. Under test were mozilla-2.0-297086a0fb61 and mozilla-1-9-2-053f07027a38:
There is a serious problem with the code that copies upvarMap.vector in jsscript.cpp. Using a combination of inner/outer functions with eval, we were able to trigger the following assertion (mozilla-2.0-297086a0fb61):
Assertion failure: cg->upvarList.count <= cg->upvarMap.length, at jsscript.cpp:1224
The respective code looks as follows:
if (cg->upvarList.count != 0) {
JS_ASSERT(cg->upvarList.count <= cg->upvarMap.length);
memcpy(script->upvars()->vector, cg->upvarMap.vector,
cg->upvarList.count * sizeof(uint32));
cg->upvarList.clear();
cx->free(cg->upvarMap.vector);
cg->upvarMap.vector = NULL;
}
In an optimized non-debug build, the memcpy simply either overruns the available space in script->upvars()->vector, or reads beyond cg->upvarMap.vector or both.
The attacker can control cg->upvarList.count arbitrarily here. We suspect the issue to be exploitable although it shouldn't be too easy (the attacker can hardly control what is actually written, only the amount).
I'll attach test.js to reproduce the problem and some valgrind logs showing different behavior depending on how large the upvar list gets. Using 24 additional upvars in the script triggers the assertion, using 32 crashes straight away without even asserting (I suspect two different problems here).
Reproducible: Always
Steps to Reproduce:
1. Run test.js
2. Observe crash/assertion
Actual Results:
Crash/Assertion
Expected Results:
Normal run.
Reporter | ||
Comment 1•14 years ago
|
||
This script demonstrates the crash.
Reporter | ||
Comment 2•14 years ago
|
||
Valgrind log for 32bit with 24 upVars on 1.9.2
Reporter | ||
Comment 3•14 years ago
|
||
Valgrind log for 32bit with 32 upVars on 1.9.2
Reporter | ||
Comment 4•14 years ago
|
||
Valgrind log for 32bit with 32 upVars on 2.0
Reporter | ||
Comment 5•14 years ago
|
||
Valgrind log for 64bit with 32 upVars on 2.0
Reporter | ||
Updated•14 years ago
|
Component: General → JavaScript Engine
Reporter | ||
Updated•14 years ago
|
blocking1.9.2: --- → ?
blocking2.0: --- → ?
Comment 6•14 years ago
|
||
Brendan, this looks like upvar code, so handing to you to start with. Sounds like a critical bug to me, but please let me know if you disagree.
Assignee: nobody → brendan
Updated•14 years ago
|
status1.9.1:
--- → ?
status1.9.2:
--- → wanted
Updated•14 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [sg:critical]
Updated•14 years ago
|
blocking1.9.2: ? → needed
Comment 9•14 years ago
|
||
Incorporated the PoC script into a loadable page, and increased the upvars to ensure a crash. For some reason I hit the unresponsive script dialog twice just executing the loop 1000 times, which is odd because it doesn't do much except grow some strings. I've seen PoC's using tons more memory and loops that don't hit that warning.
I think the following crash happened when I closed the page after running the testcase, not directly when I clicked it.
bp-104c40b5-7653-4d6e-ac52-ff31e2101208
Updated•14 years ago
|
Attachment #494093 -
Attachment mime type: text/x-log → text/plain
Updated•14 years ago
|
Attachment #494092 -
Attachment mime type: text/x-log → text/plain
Updated•14 years ago
|
Attachment #494090 -
Attachment mime type: text/x-log → text/plain
Updated•14 years ago
|
Attachment #494089 -
Attachment mime type: text/x-log → text/plain
Assignee | ||
Comment 11•14 years ago
|
||
I hate MakeUpvarForEval... (which means I hate SunSpider, which wants it -- but you knew that).
/be
Attachment #496287 -
Flags: review?(dmandelin)
Comment 12•14 years ago
|
||
Comment on attachment 496287 [details] [diff] [review]
fix
It's cool how the assert basically documents what the other part of the patch is for. Made it super-easy to review.
Attachment #496287 -
Flags: review?(dmandelin) → review+
Updated•14 years ago
|
blocking2.0: ? → beta9+
Assignee | ||
Comment 13•14 years ago
|
||
blocking2.0: beta9+ → ?
Whiteboard: [sg:critical] → [sg:critical] fixed-in-tracemonkey
Updated•14 years ago
|
blocking2.0: ? → betaN+
Comment 14•14 years ago
|
||
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Comment 15•14 years ago
|
||
Does this bug affect FF3.5 or did upvars come in with 1.9.2?
blocking1.9.2: needed → .14+
Assignee | ||
Comment 16•14 years ago
|
||
This affects 3.5 too.
/be
Updated•14 years ago
|
blocking1.9.1: --- → .17+
Assignee | ||
Comment 17•14 years ago
|
||
I don't know how to prove this can't be exploited. With enough work, it probably could be, although it is not as easy to exploit as sg:criticals involving free memory reads during virtual call instruction sequences.
/be
Comment 18•14 years ago
|
||
Pedestrian port to 191, nothing difficult to need re-review.
Attachment #505586 -
Flags: approval1.9.1.17?
Comment 20•14 years ago
|
||
Comment on attachment 505586 [details] [diff] [review]
191 patch
Approved for 1.9.2.14 and 1.9.1.17, a=dveditz for release-drivers
Attachment #505586 -
Flags: approval1.9.1.17? → approval1.9.1.17+
Updated•14 years ago
|
Attachment #505588 -
Flags: approval1.9.2.14? → approval1.9.2.14+
Comment 21•14 years ago
|
||
Comment 22•14 years ago
|
||
(In reply to comment #9)
> Created attachment 496209 [details]
> testcase (click to crash)
>
> Incorporated the PoC script into a loadable page, and increased the upvars to
> ensure a crash. For some reason I hit the unresponsive script dialog twice
> just executing the loop 1000 times, which is odd because it doesn't do much
> except grow some strings. I've seen PoC's using tons more memory and loops that
> don't hit that warning.
Verified for 1.9.2 using this testcase. Crashes in 1.9.2.13 and verified fixed in 1.9.14 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.14) Gecko/20110121 Firefox/3.6.14 ( .NET CLR 3.5.30729)).
Same with 1.9.1.16 and verified fixed in 1.9.17 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.17) Gecko/20110121 Firefox/3.5.17 ( .NET CLR 3.5.30729)).
Keywords: verified1.9.1,
verified1.9.2
Updated•14 years ago
|
Alias: CVE-2011-0054
Updated•14 years ago
|
Group: core-security
Updated•12 years ago
|
Flags: sec-bounty+
Updated•9 months ago
|
Keywords: reporter-external
You need to log in
before you can comment on or make changes to this bug.
Description
•