Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 915129 (CVE-2023-43785, CVE-2023-43786, CVE-2023-43787) - <x11-libs/libX11-1.8.7: Multiple vulnerabilities
Summary: <x11-libs/libX11-1.8.7: Multiple vulnerabilities
Status: IN_PROGRESS
Alias: CVE-2023-43785, CVE-2023-43786, CVE-2023-43787
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Security
URL: https://www.openwall.com/lists/oss-se...
Whiteboard: B3 [glsa?]
Keywords:
Depends on: 915193
Blocks:
  Show dependency tree
 
Reported: 2023-10-03 18:19 UTC by Sam James
Modified: 2023-12-21 19:28 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-03 18:19:31 UTC
"""
1) CVE-2023-43785 libX11: out-of-bounds memory access in _XkbReadKeySyms()

Introduced in: X11R6.1 [released March 1996]
Fixed in: libX11 1.8.7
Found by: Gregory James DUCK
Fixed by: Alan Coopersmith of Oracle Solaris Engineering

When libX11 is processing the reply from the X server to the XkbGetMap
request, if it detected the number of symbols in the new map was less
than the size of the buffer it had allocated, it always added room for
128 more symbols, instead of the actual size needed. While the
_XkbReadBufferCopyKeySyms() helper function returned an error if asked
to copy more keysyms into the buffer than there was space allocated for,
the caller never checked for an error and assumed the full set of keysyms
was copied into the buffer and could then try to read out of bounds when
accessing the buffer.  libX11 1.8.7 has been patched to both fix the size
allocated and check for error returns from _XkbReadBufferCopyKeySyms().

Fix:
https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/6858d468d9ca55fb4c5fd70b223dbc78a3358a7f
"""
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-03 18:21:17 UTC
2) CVE-2023-43786 libX11: stack exhaustion from infinite recursion
    in PutSubImage()

Introduced in: X11R2 [released Feb. 1988]
Fixed in: libX11 1.8.7
Found by: Yair Mizrahi of the JFrog Vulnerability Research team
Fixed by: Alan Coopersmith of Oracle Solaris Engineering

When splitting a single line of pixels into chunks that fit in a single
request (not using the BIG-REQUESTS extension) to send to the X server,
the code did not take into account the number of bits per pixel, so would
just loop forever finding it needed to send more pixels than fit in the
given request size and not breaking them down into a small enough chunk to
fit.  An XPM file was provided that triggered this bug when loaded via
libXpm's XpmReadFileToPixmap() function, which in turn calls XPutImage()
and hit this bug.

Further hardening to prevent similar bugs was done in libX11 by making
XPutImage() clip images to the maximum X protocol pixmap size (limited
by the use of unsigned 16-bit integers for height & width) when writing
to X pixmaps, and by making XCreatePixmap() generate X errors if a
height or width was specified that did not fit into an unsigned 16-bit
integer.  In libXpm, hardening was done to return error codes for any
call that would have passed out-of-bounds width or height values to
XCreatePixmap().

Fix:
https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/204c3393c4c90a29ed6bef64e43849536e863a86

Hardening:
https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/73a37d5f2fcadd6540159b432a70d80f442ddf4a
https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/b4031fc023816aca07fbd592ed97010b9b48784b
https://gitlab.freedesktop.org/xorg/lib/libxpm/-/commit/84fb14574c039f19ad7face87eb9acc31a50701c

3) CVE-2023-43787 libX11: integer overflow in XCreateImage() leading to
    a heap overflow

Introduced in: X11R2 [released Feb. 1988]
Fixed in: libX11 1.8.7
Found by: Yair Mizrahi of the JFrog Vulnerability Research team
Fixed by: Yair Mizrahi of the JFrog Vulnerability Research team

When creating an image, there was no validation that the multiplication
of the caller-provided width by the visual's bits_per_pixel did not
overflow and thus result in the allocation of a buffer too small to hold
the data that would be copied into it.  An XPM file was provided that
triggered this bug when loaded via libXpm's XpmReadFileToPixmap() function,
which in turn calls XCreateImage() and hit this bug.

Further hardening to prevent similar bugs was done in libXpm to return
error codes for any call to XCreateImage() that would have resulted in
this calculation overflowing.

Fix:
https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/7916869d16bdd115ac5be30a67c3749907aea6a0

Hardening:
https://gitlab.freedesktop.org/xorg/lib/libxpm/-/commit/91f887b41bf75648df725a4ed3be036da02e911e
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-03 18:23:30 UTC
Please stable when ready.
Comment 3 Larry the Git Cow gentoo-dev 2023-10-05 12:38:55 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f44d120180959aa208e78a9f71e2bde7435d32b6

commit f44d120180959aa208e78a9f71e2bde7435d32b6
Author:     Matt Turner <mattst88@gentoo.org>
AuthorDate: 2023-10-05 12:36:49 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2023-10-05 12:37:43 +0000

    x11-libs/libX11: Drop old versions
    
    Bug: https://bugs.gentoo.org/915129
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 x11-libs/libX11/Manifest            |  1 -
 x11-libs/libX11/libX11-1.8.6.ebuild | 45 -------------------------------------
 2 files changed, 46 deletions(-)