From: Yogita Urade <yogita.ur...@windriver.com>

A vulnerability was found in libX11 due to an integer overflow
within the XCreateImage() function. This flaw allows a local
user to trigger an integer overflow and execute arbitrary code
with elevated privileges.

Reference:
https://security-tracker.debian.org/tracker/CVE-2023-43787
https://www.openwall.com/lists/oss-security/2023/10/03/1

Signed-off-by: Yogita Urade <yogita.ur...@windriver.com>
---
 .../xorg-lib/libx11/CVE-2023-43787.patch      | 64 +++++++++++++++++++
 .../xorg-lib/libx11_1.7.3.1.bb                |  1 +
 2 files changed, 65 insertions(+)
 create mode 100644 meta/recipes-graphics/xorg-lib/libx11/CVE-2023-43787.patch

diff --git a/meta/recipes-graphics/xorg-lib/libx11/CVE-2023-43787.patch 
b/meta/recipes-graphics/xorg-lib/libx11/CVE-2023-43787.patch
new file mode 100644
index 0000000000..48cb56831b
--- /dev/null
+++ b/meta/recipes-graphics/xorg-lib/libx11/CVE-2023-43787.patch
@@ -0,0 +1,64 @@
+From 7916869d16bdd115ac5be30a67c3749907aea6a0 Mon Sep 17 00:00:00 2001
+From: Yair Mizrahi <ya...@jfrog.com>
+Date: Tue, 17 Oct 2023 08:26:32 +0000
+Subject: [PATCH] CVE-2023-43787: Integer overflow in XCreateImage() leading to
+  a heap overflow
+
+When the format is `Pixmap` it calculates the size of the image data as:
+    ROUNDUP((bits_per_pixel * width), image->bitmap_pad);
+There is no validation on the `width` of the image, and so this
+calculation exceeds the capacity of a 4-byte integer, causing an overflow.
+
+Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+CVE: CVE-2023-43787
+
+Upstream-Status: Backport 
[https://gitlab.freedesktop.org/xorg/lib/libx11/-/commit/7916869d16bdd115ac5be30a67c3749907aea6a0]
+
+Signed-off-by: Yogita Urade <yogita.ur...@windriver.com>
+---
+ src/ImUtil.c | 20 +++++++++++++++-----
+ 1 file changed, 15 insertions(+), 5 deletions(-)
+
+diff --git a/src/ImUtil.c b/src/ImUtil.c
+index 36f08a0..fbfad33 100644
+--- a/src/ImUtil.c
++++ b/src/ImUtil.c
+@@ -30,6 +30,7 @@ in this Software without prior written authorization from 
The Open Group.
+ #include <X11/Xlibint.h>
+ #include <X11/Xutil.h>
+ #include <stdio.h>
++#include <limits.h>
+ #include "ImUtil.h"
+
+ static int _XDestroyImage(XImage *);
+@@ -361,13 +362,22 @@ XImage *XCreateImage (
+       /*
+        * compute per line accelerator.
+        */
+-      {
+-      if (format == ZPixmap)
++      if (format == ZPixmap) {
++          if ((INT_MAX / bits_per_pixel) < width) {
++              Xfree(image);
++              return NULL;
++          }
++
+           min_bytes_per_line =
+-             ROUNDUP((bits_per_pixel * width), image->bitmap_pad);
+-      else
++              ROUNDUP((bits_per_pixel * width), image->bitmap_pad);
++      } else {
++          if ((INT_MAX - offset) < width) {
++              Xfree(image);
++              return NULL;
++          }
++
+           min_bytes_per_line =
+-              ROUNDUP((width + offset), image->bitmap_pad);
++              ROUNDUP((width + offset), image->bitmap_pad);
+       }
+       if (image_bytes_per_line == 0) {
+           image->bytes_per_line = min_bytes_per_line;
+--
+2.35.5
diff --git a/meta/recipes-graphics/xorg-lib/libx11_1.7.3.1.bb 
b/meta/recipes-graphics/xorg-lib/libx11_1.7.3.1.bb
index 19687d546b..e77b148d76 100644
--- a/meta/recipes-graphics/xorg-lib/libx11_1.7.3.1.bb
+++ b/meta/recipes-graphics/xorg-lib/libx11_1.7.3.1.bb
@@ -18,6 +18,7 @@ SRC_URI += "file://disable_tests.patch \
             file://CVE-2022-3554.patch \
             file://CVE-2022-3555.patch \
             file://CVE-2023-3138.patch \
+            file://CVE-2023-43787.patch \
            "
 SRC_URI[sha256sum] = 
"2ffd417266fb875028fdc0ef349694f63dbcd76d0b0cfacfb52e6151f4b60989"
 
-- 
2.35.5

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#189493): 
https://lists.openembedded.org/g/openembedded-core/message/189493
Mute This Topic: https://lists.openembedded.org/mt/102075512/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to