Bug 413741 (CVE-2007-6429_MITSHM)

Summary: CVE-2007-6429 xorg / xfree86: integer overflow in MIT-SHM extension
Product: [Other] Security Response Reporter: Tomas Hoger <thoger>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: airlied, ajax, kreilly, security-response-team, tyan, xgl-maint
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 1.3.0.0-39.fc8 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-01-22 15:31:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 419451, 419461, 419481, 419501, 419521, 419531, 429125, 429126, 429127    
Bug Blocks:    

Description Tomas Hoger 2007-12-06 11:10:22 UTC
iDefense reported a vulnerability discovered by regenrecht affecting Xorg X server:

DESCRIPTION

Local exploitation of an integer overflow vulnerability in the X.Org X
server, as included in various vendors' operating system distributions,
could allow an attacker to execute arbitrary code with the privileges of
the X server, typically root.

The vulnerability exists within the code responsible for creating a
pixmap in shared memory. When allocating the pixmap, the server uses
values from the request to verify that the requested size is not
greater than the allocated shared memory. The calculation can overflow,
which leads to the overwriting of arbitrary addresses in memory that
aren't part of the shared memory segment.

The vulnerable code is shown below:

148  #define VERIFY_SHMSIZE(shmdesc,offset,len,client) \

149  { \

150   if ((offset + len) > shmdesc->size) \

151   { \

152     return BadAccess; \

153   } \

154  }

Same file, ProcShmCreatePixmap():

1070  VERIFY_SHMSIZE(shmdesc, stuff->offset,

1071   PixmapBytePad(stuff->width, stuff->depth) * stuff->height,

1072   client);

1073  pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)(

1074   pDraw->pScreen, stuff->width,

1075   stuff->height, stuff->depth,

1076   shmdesc->addr + stuff->offset);

The calculcation in the VERIFY_SHMSIZE() macro can overflow if len +
offset > 0xffffffff. These values are then used later to create the
pixmap in the CreatePixmap() function. The result is the creation of
zero sized pixmap, and the ability to overwrite arbitrary values in
memory by indexing beyond the end of the shared memory segment.

ANALYSIS

Exploitation allows an attacker to execute arbitrary code with root
privileges. In order to exploit this vulnerability, an attacker must be
able to send commands to an affected X server. This typically requires
access to the console or access to the same account as a user who is on
the console. One method of gaining the required access is to remotely
exploit a vulnerability in, for example, a graphical web browser. This
would then allow an attacker to exploit this vulnerability and elevate
their privileges to root.

If an X Server is configured to listen for TCP based client connections,
and a client is granted access to create sessions (via the xhosts file),
then the vulnerability can be exploited remotely.

WORKAROUND

If the MIT-SHM extension has not been built-in to the server, then it
can be prevented from loading by inserting the following into the X
configuration file (usually in /etc/X11/xorg.conf):

Section "Module"

        SubSection "extmod"

                Option "omit MIT-SHM"

        EndSubSection

EndSection

To check if the extension is built-in to the server, grep the output of
the X Server log file:

grep built-in /var/log/Xorg.0.log

The result will list all built in extensions. The location of the log
file may need to be changed.

Comment 1 Tomas Hoger 2007-12-06 11:13:24 UTC
Referenced code is in Xext/shm.c file.

Comment 2 Tomas Hoger 2007-12-06 11:14:28 UTC
Upstream bug report:

  https://bugs.freedesktop.org/show_bug.cgi?id=13520

Comment 9 Tomas Hoger 2008-01-02 07:26:12 UTC
CVE id CVE-2007-6429 is used to cover integer overflows in both EVI and MIT-SHM
extensions.

EVI extension issue is tracked via bug #413721.

Comment 16 Josh Bressers 2008-01-17 14:46:41 UTC
Lifting embargo:
http://lists.freedesktop.org/archives/xorg/2008-January/031918.html

Comment 18 Tomas Hoger 2008-01-18 17:13:26 UTC
There have been reports from other distributions that the fix for this issue
causes problems with some applications.  See for example: 

https://bugs.launchpad.net/ubuntu/+bug/183969
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=461410

Our engineers are currently investigating this issue.  It is currently believed
that a work-around that can be used with these new packages is to disable the
mitshm extension, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=461410#26

Comment 19 Mark J. Cox 2008-01-19 09:35:15 UTC
[Updated 18th January 2008]
The original packages distributed with this errata had a bug which could
cause some X applications to fail on 32-bit platforms. We have updated the
packages to correct this bug.

http://rhn.redhat.com/errata/RHSA-2008-0031.html
http://rhn.redhat.com/errata/RHSA-2008-0030.html
http://rhn.redhat.com/errata/RHSA-2008-0029.html

Comment 20 Fedora Update System 2008-01-22 15:31:37 UTC
xorg-x11-server-1.3.0.0-39.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 21 Fedora Update System 2008-01-22 15:49:08 UTC
xorg-x11-server-1.3.0.0-15.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.