Bug 574059 (CVE-2010-2752)

nsCSSValue::Array index integer overflow (can lead to remote code execution via CSS font-face) (ZDI-CAN-831)

RESOLVED FIXED in mozilla2.0b1

Status

()

Core
CSS Parsing and Computation
P1
critical
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: reed, Assigned: dbaron)

Tracking

({verified1.9.1, verified1.9.2})

unspecified
mozilla2.0b1
verified1.9.1, verified1.9.2
Points:
---

Firefox Tracking Flags

(blocking2.0 final+, status1.9.2 .7-fixed, status1.9.1 .11-fixed)

Details

(Whiteboard: [sg:critical?])

Attachments

(3 attachments)

(Reporter)

Description

7 years ago
Created attachment 453442 [details]
PoC generator (python-based)

ZDI-CAN-831: Mozilla Firefox CSS font-face Remote Code Execution Vulnerability

-- ABSTRACT ------------------------------------------------------------

TippingPoint has identified a vulnerability affecting the following 
products:

    Mozilla Firefox 3.6.x

-- VULNERABILITY DETAILS -----------------------------------------------

This vulnerability allows remote attackers to execute arbitrary code on
vulnerable installations of Mozilla Firefox. User interaction is
required to exploit this vulnerability in that the target must visit a
malicious page or open a malicious file.

The specific flaw exists within handling of references to external font
resources. A value is used as a 16 bit integer in an array allocation
and later as 32 bit when iterating over and then populating these
fields. By creating enough references, a remote attacker can exploit
this vulnerability to execute arbitrary code under the context of the
browser.


Version(s)  tested: 
00400000 004e0000   firefox    (deferred)             
    Image path: C:\Program Files\Mozilla Firefox\firefox.exe
    Image name: firefox.exe
    Timestamp:        Thu Apr 01 10:38:42 2010 (4BB4BE02)
    CheckSum:         000EA924
    ImageSize:        000E0000
    File version:     1.9.2.3743
    Product version:  3.6.3.0


Platform(s) tested:
Windows XP SP3 x86

http://mxr.mozilla.org/mozilla1.9.2/source/layout/style/nsCSSParser.cpp#7893
// alloc:
7892   nsRefPtr<nsCSSValue::Array> srcVals
7893     = nsCSSValue::Array::Create(values.Length());
 
// overflow: 
7899   PRUint32 i;
7900   for (i = 0; i < values.Length(); i++)
7901     srcVals->Item(i) = values[i];
  

-- CREDIT --------------------------------------------------------------

This vulnerability was discovered by:
    * J23 (http://twitter.com/HansJ23)
Component: Layout → Style System (CSS)
QA Contact: layout → style-system
(Reporter)

Comment 1

7 years ago
bp-ba8f7c42-2b7b-4389-8e5d-2cb772100623

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.3a6pre) Gecko/20100623 Minefield/3.7a6pre
(Assignee)

Comment 2

7 years ago
We should probably just change nsCSSValue::Array to PRUint32.  It was originally intended for only fixed-size things, but now it's being used for three things of author-controlled size:  'src' and 'unicode-range' inside @font-face, and min()/max() inside -moz-calc().
(Assignee)

Updated

7 years ago
Assignee: nobody → dbaron
(Assignee)

Comment 3

7 years ago
Created attachment 453462 [details] [diff] [review]
patch

This switches to size_t, which I think is the right thing to use for things like this (and we should tend to switch).  It might be larger than PRUint32, but it shouldn't be smaller on any platforms we support, and I think a mismatch that way around is ok.
Attachment #453462 - Flags: review?(bzbarsky)
Comment on attachment 453462 [details] [diff] [review]
patch

Why does size_t make sense for the refcount?
(Assignee)

Comment 5

7 years ago
The size of the address space limits the number of objects that could own a reference to something.
Comment on attachment 453462 [details] [diff] [review]
patch

OK, I buy that.  We should consider using size_t for refcounts in general, then, and use the macros here.  Separate bug?
Attachment #453462 - Flags: review?(bzbarsky) → review+

Updated

7 years ago
Summary: CSS font-face Remote Code Execution Vulnerability (ZDI-CAN-831) → nsCSSValue::Array refcnt overflow (can lead to remote code execution via CSS font-face) (ZDI-CAN-831)
(Assignee)

Updated

7 years ago
Summary: nsCSSValue::Array refcnt overflow (can lead to remote code execution via CSS font-face) (ZDI-CAN-831) → nsCSSValue::Array index integer overflow (can lead to remote code execution via CSS font-face) (ZDI-CAN-831)
(Assignee)

Comment 7

7 years ago
http://hg.mozilla.org/mozilla-central/pushloghtml
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Priority: -- → P1
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a6
(Assignee)

Updated

7 years ago
Attachment #453462 - Flags: approval1.9.2.6?
status1.9.1: ? → wanted
status1.9.2: ? → wanted
(Reporter)

Comment 8

7 years ago
(In reply to comment #7)
> http://hg.mozilla.org/mozilla-central/pushloghtml

http://hg.mozilla.org/mozilla-central/rev/800ef4b6087f, actually.

Does this also affect 1.9.1?
(Assignee)

Comment 9

7 years ago
Created attachment 453897 [details] [diff] [review]
1.9.2 patch

With one chunk (the calc()-related one) removed, since calc() isn't on 1.9.2, plus some trivial merging.
Attachment #453897 - Flags: approval1.9.2.6?
(Assignee)

Comment 10

7 years ago
Created attachment 453898 [details] [diff] [review]
1.9.1 patch

Just the 1.9.2 patch with some trivial (i.e., context) merging.
(Assignee)

Updated

7 years ago
Attachment #453462 - Flags: approval1.9.2.6?
(Assignee)

Updated

7 years ago
Attachment #453898 - Flags: approval1.9.1.11?

Updated

7 years ago
Attachment #453897 - Flags: approval1.9.2.6? → approval1.9.2.6+

Updated

7 years ago
Attachment #453898 - Flags: approval1.9.1.11? → approval1.9.1.11+

Comment 11

7 years ago
a=LegNeato for 1.9.2.6 and 1.9.1.11. Please land this on mozilla-1.9.2 default and mozilla-1.9.1 default (*not* any relbranches).

The code freeze for both releases is this Friday (tomorrow) @ 11:59 PST.
(Assignee)

Comment 12

7 years ago
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/0a8009ec6714
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/2c38a62daa0a
blocking2.0: ? → final+
status1.9.1: wanted → .11-fixed
status1.9.2: wanted → .6-fixed
(Assignee)

Updated

7 years ago
status2.0: ? → ---

Updated

7 years ago
blocking1.9.1: ? → ---
blocking1.9.2: ? → ---
Blocks: 574750
Alias: CVE-2010-2752
Verified for 1.9.2.7 using PoC with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.7) Gecko/20100713 Firefox/3.6.7 (.NET CLR 3.5.30729). Verified crash with 1.9.2.6.

Verified for 1.9.1.11 with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 Firefox/3.5.11 (.NET CLR 3.5.30729) as well. Crashes in 1.9.1.10.
Keywords: verified1.9.1, verified1.9.2
Group: core-security
You need to log in before you can comment on or make changes to this bug.