Skip to contentSkip to conversation

gimp: patch CVE-2023-44441

PATCH New Gyorgy Sarvari 1 participant 3 messages Mar 9

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 gimp: patch CVE-2023-44441

Details: https://nvd.nist.gov/vuln/detail/CVE-2023-44441

Backport the commit that resolved the related upstream issue[1].

[1]: https://gitlab.gnome.org/GNOME/gimp/-/issues/10069

---
 .../gimp/gimp/CVE-2023-44441.patch            | 61 +++++++++++++++++++
 meta-gnome/recipes-gimp/gimp/gimp_2.10.30.bb  |  1 +
 2 files changed, 62 insertions(+)
 create mode 100644 meta-gnome/recipes-gimp/gimp/gimp/CVE-2023-44441.patch
meta-gnome/recipes-gimp/gimp/gimp/CVE-2023-44441.patch new file +61 -0
new file mode 100644
index 0000000000..d28cb1e848
@@ -0,0 +1,61 @@
+From babb323270a37091604bec44ee3597150cac8227 Mon Sep 17 00:00:00 2001
+From: Alx Sa <[email protected]>
+Date: Sun, 1 Oct 2023 17:54:08 +0000
+Subject: [PATCH] plug-ins: Fix DDS vulnerability (ZDI-CAN-22093)
+
+Resolves #10069
+
+Currently, the DDS header information for the width, height, and bytes per scan line
+are read in and assumed to be correct. As these values are used for memory allocation
+and reading, it would be good to verify they do not exceed the file size.
+
+This patch adds a condition after the header is read in to verify those values. If they exceed
+the file size (mins an offset), the file is not read in and an error message is shown.
+
+CVE: CVE-2023-44441
+Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/gimp/-/commit/7db71cd0b6e36c454aa0d2d3efeec7e636db4dbc]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ plug-ins/file-dds/ddsread.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/plug-ins/file-dds/ddsread.c b/plug-ins/file-dds/ddsread.c
+index a8eb8b8..98e122d 100644
+--- a/plug-ins/file-dds/ddsread.c
++++ b/plug-ins/file-dds/ddsread.c
+@@ -109,6 +109,7 @@ read_dds (gchar    *filename,
+   guchar *pixels;
+   gchar *tmp;
+   FILE *fp;
++  gsize file_size;
+   dds_header_t hdr;
+   dds_header_dx10_t dx10hdr;
+   dds_load_info_t d;
+@@ -130,6 +131,10 @@ read_dds (gchar    *filename,
+       return GIMP_PDB_EXECUTION_ERROR;
+     }
+ 
++  fseek (fp, 0L, SEEK_END);
++  file_size = ftell (fp);
++  fseek (fp, 0, SEEK_SET);
++
+   if (strrchr (filename, '/'))
+     tmp = g_strdup_printf ("Loading %s:", strrchr (filename, '/') + 1);
+   else
+@@ -186,6 +191,16 @@ read_dds (gchar    *filename,
+         }
+     }
+ 
++  /* verify header information is accurate */
++  if (hdr.depth < 1                                       ||
++      (hdr.pitch_or_linsize > (file_size - sizeof (hdr))) ||
++      (((guint64) hdr.height * hdr.width * hdr.depth) > (file_size - sizeof (hdr))))
++    {
++      fclose (fp);
++      g_message ("Invalid or corrupted DDS header\n");
++      return GIMP_PDB_EXECUTION_ERROR;
++    }
++
+   if (hdr.pixelfmt.flags & DDPF_FOURCC)
+     {
+       /* fourcc is dXt* or rXgb */
meta-gnome/recipes-gimp/gimp/gimp_2.10.30.bb +1 -0
index 4d2771e551..124760651d 100644
@@ -48,6 +48,7 @@ SRC_URI = "https://download.gimp.org/pub/${BPN}/v${SHPV}/${BP}.tar.bz2 \
            file://CVE-2022-32990-1.patch \
            file://CVE-2022-32990-2.patch \
            file://CVE-2022-32990-3.patch \
+           file://CVE-2023-44441.patch \
            "
 SRC_URI[sha256sum] = "88815daa76ed7d4277eeb353358bafa116cd2fcd2c861d95b95135c1d52b67dc"
 
#1 lore raw

PATCH 2/3 gimp: patch CVE-2023-44442

Details: https://nvd.nist.gov/vuln/detail/CVE-2023-44442

Backport the patch that resolved the related upstream issue[1].

[1]: https://gitlab.gnome.org/GNOME/gimp/-/issues/10101

---
 .../gimp/gimp/CVE-2023-44442.patch            | 28 +++++++++++++++++++
 meta-gnome/recipes-gimp/gimp/gimp_2.10.30.bb  |  1 +
 2 files changed, 29 insertions(+)
 create mode 100644 meta-gnome/recipes-gimp/gimp/gimp/CVE-2023-44442.patch
meta-gnome/recipes-gimp/gimp/gimp/CVE-2023-44442.patch new file +28 -0
new file mode 100644
index 0000000000..8b51b35792
@@ -0,0 +1,28 @@
+From a4f550be80f2f771927e2df9ae09e3f3354d22f1 Mon Sep 17 00:00:00 2001
+From: Alx Sa <[email protected]>
+Date: Fri, 29 Sep 2023 20:39:29 +0000
+Subject: [PATCH] plug-ins: Fix vulnerability in file-psd
+
+Resolves #10101.
+This patch adds a missing break statement after an error condition
+is detected to prevent the code from continuing afterwards.
+
+CVE: CVE-2023-44442
+Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/gimp/-/commit/985c0a20e18b5b3b8a48ee9cb12287b1d5732d3d]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ plug-ins/file-psd/psd-util.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/plug-ins/file-psd/psd-util.c b/plug-ins/file-psd/psd-util.c
+index 5686bb7..8514b07 100644
+--- a/plug-ins/file-psd/psd-util.c
++++ b/plug-ins/file-psd/psd-util.c
+@@ -518,6 +518,7 @@ decode_packbits (const gchar *src,
+             {
+               IFDBG(2) g_debug ("Overrun in packbits replicate of %d chars", n - unpack_left);
+               error_code = 2;
++              break;
+             }
+           memset (dst, *src, n);
+           src++;
meta-gnome/recipes-gimp/gimp/gimp_2.10.30.bb +1 -0
index 124760651d..ff34bfa6fd 100644
@@ -49,6 +49,7 @@ SRC_URI = "https://download.gimp.org/pub/${BPN}/v${SHPV}/${BP}.tar.bz2 \
            file://CVE-2022-32990-2.patch \
            file://CVE-2022-32990-3.patch \
            file://CVE-2023-44441.patch \
+           file://CVE-2023-44442.patch \
            "
 SRC_URI[sha256sum] = "88815daa76ed7d4277eeb353358bafa116cd2fcd2c861d95b95135c1d52b67dc"
 
#2 lore raw

PATCH 3/3 gimp: patch CVE-2023-44443 and CVE-2023-44444

In reply to Gyorgy Sarvari

Details: https://nvd.nist.gov/vuln/detail/CVE-2023-44443
https://nvd.nist.gov/vuln/detail/CVE-2023-44444

The relevant upstream issues:
https://gitlab.gnome.org/GNOME/gimp/-/issues/10072
https://gitlab.gnome.org/GNOME/gimp/-/issues/10071

For the backport, upstream has merged the two patches into one, solving both CVEs. That patch is in this change.

---
 .../gimp/CVE-2023-44443_CVE-2023-44444.patch  | 47 +++++++++++++++++++
 meta-gnome/recipes-gimp/gimp/gimp_2.10.30.bb  |  1 +
 2 files changed, 48 insertions(+)
 create mode 100644 meta-gnome/recipes-gimp/gimp/gimp/CVE-2023-44443_CVE-2023-44444.patch
meta-gnome/recipes-gimp/gimp/gimp/CVE-2023-44443_CVE-2023-44444.patch new file +47 -0
new file mode 100644
index 0000000000..c92aaa24a9
@@ -0,0 +1,47 @@
+From 8a8c3fe7cdb498d05d8e61e6b0f36d9a314caa62 Mon Sep 17 00:00:00 2001
+From: Alx Sa <[email protected]>
+Date: Sat, 23 Sep 2023 20:40:18 +0000
+Subject: [PATCH] plug-ins: Fix vulnerabilities in file-psp
+
+Backports commits e1bfd871 and 96f536a3
+from master
+
+CVE: CVE-2023-44443 CVE-2023-44444
+Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/gimp/-/commit/ef12c0a90752a06d4c465a768d052b07f5e8a8a0]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ plug-ins/common/file-psp.c | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/plug-ins/common/file-psp.c b/plug-ins/common/file-psp.c
+index c0f3480..6a6b93d 100644
+--- a/plug-ins/common/file-psp.c
++++ b/plug-ins/common/file-psp.c
+@@ -1128,8 +1128,17 @@ read_color_block (FILE      *f,
+     }
+ 
+   color_palette_entries = GUINT32_FROM_LE (entry_count);
++  /* TODO: GIMP currently only supports a maximum of 256 colors
++   * in an indexed image. If this changes, we can change this check */
++  if (color_palette_entries > 256)
++    {
++      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
++                   _("Error: Unsupported palette size"));
++      return -1;
++    }
++
+   /* psp color palette entries are stored as RGBA so 4 bytes per entry
+-     where the fourth bytes is always zero */
++   * where the fourth bytes is always zero */
+   pal_size = color_palette_entries * 4;
+   color_palette = g_malloc (pal_size);
+   if (fread (color_palette, pal_size, 1, f) < 1)
+@@ -1498,7 +1507,7 @@ read_channel_data (FILE        *f,
+         else
+           endq = q + line_width * height;
+ 
+-        buf = g_malloc (127);
++        buf = g_malloc (128);
+         while (q < endq)
+           {
+             fread (&runcount, 1, 1, f);
meta-gnome/recipes-gimp/gimp/gimp_2.10.30.bb +1 -0
index ff34bfa6fd..07c9fcf666 100644
@@ -50,6 +50,7 @@ SRC_URI = "https://download.gimp.org/pub/${BPN}/v${SHPV}/${BP}.tar.bz2 \
            file://CVE-2022-32990-3.patch \
            file://CVE-2023-44441.patch \
            file://CVE-2023-44442.patch \
+           file://CVE-2023-44443_CVE-2023-44444.patch \
            "
 SRC_URI[sha256sum] = "88815daa76ed7d4277eeb353358bafa116cd2fcd2c861d95b95135c1d52b67dc"