Skip to contentSkip to conversation

imagemagick: Fix CVE vulnerablities

PATCH New Sana Kazi 1 participant 1 message May 12, 2025

lore
Share & tools
lore

Sana Kazi

author
#0 lore raw

PATCH 1/1 imagemagick: Fix CVE vulnerablities

Fix following CVEs for imagemagick:
CVE-2021-20311, CVE-2021-20312, CVE-2021-20313
CVE-2021-20309, CVE-2021-20310, CVE-2021-3610
CVE-2022-0284, CVE-2022-2719
fix-cipher-leak.patch fixes CVE-2021-20311, CVE-2021-20312, CVE-2021-20313

Ignore following CVES as current version is not affected by them:
CVE-2014-9826, CVE-2016-7538, CVE-2017-5506

---
 .../imagemagick/files/CVE-2021-20309.patch    |  25 +++
 .../imagemagick/files/CVE-2021-20310.patch    |  31 +++
 .../imagemagick/files/CVE-2021-3610.patch     |  26 +++
 .../imagemagick/files/CVE-2022-0284.patch     |  34 ++++
 .../imagemagick/files/CVE-2022-2719.patch     | 136 +++++++++++++
 .../imagemagick/files/fix-cipher-leak.patch   | 178 ++++++++++++++++++
 .../imagemagick/imagemagick_7.0.10.bb         |  19 +-
 7 files changed, 448 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-support/imagemagick/files/CVE-2021-20309.patch
 create mode 100644 meta-oe/recipes-support/imagemagick/files/CVE-2021-20310.patch
 create mode 100644 meta-oe/recipes-support/imagemagick/files/CVE-2021-3610.patch
 create mode 100644 meta-oe/recipes-support/imagemagick/files/CVE-2022-0284.patch
 create mode 100644 meta-oe/recipes-support/imagemagick/files/CVE-2022-2719.patch
 create mode 100644 meta-oe/recipes-support/imagemagick/files/fix-cipher-leak.patch
meta-oe/recipes-support/imagemagick/files/CVE-2021-20309.patch new file +25 -0
new file mode 100644
index 0000000000..c5e9b71454
@@ -0,0 +1,25 @@
+From 94174beff065cb5683d09d79e992c3ebbdead311 Mon Sep 17 00:00:00 2001
+From: Cristy <[email protected]>
+Date: Thu, 25 Feb 2021 19:34:39 -0500
+Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/3296
+
+CVE: CVE-2021-20309
+Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/94174beff065cb5683d09d79e992c3ebbdead311.patch]
+Signed-off-by: Sana Kazi [email protected]
+---
+ MagickCore/visual-effects.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/MagickCore/visual-effects.c b/MagickCore/visual-effects.c
+index 789660231b9..60a227951f9 100644
+--- a/MagickCore/visual-effects.c
++++ b/MagickCore/visual-effects.c
+@@ -3360,7 +3360,7 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
+     }
+   for (i=0; i < (ssize_t) wave_image->columns; i++)
+     sine_map[i]=(float) fabs(amplitude)+amplitude*sin((double)
+-      ((2.0*MagickPI*i)/wave_length));
++      ((2.0*MagickPI*i)*PerceptibleReciprocal(wave_length)));
+   /*
+     Wave image.
+   */
meta-oe/recipes-support/imagemagick/files/CVE-2021-20310.patch new file +31 -0
new file mode 100644
index 0000000000..f6ac425886
@@ -0,0 +1,31 @@
+From 75f6f5032690077cae3eaeda3c0165cc765eaeb5 Mon Sep 17 00:00:00 2001
+From: Cristy <[email protected]>
+Date: Thu, 25 Feb 2021 19:31:37 -0500
+Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/3295
+
+CVE: CVE-2021-20310
+Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/75f6f5032690077cae3eaeda3c0165cc765eaeb5.patch]
+Signed-off-by: Sana Kazi [email protected]
+---
+ MagickCore/colorspace.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c
+index e3b7df339f6..9c5ea11e300 100644
+--- a/MagickCore/colorspace.c
++++ b/MagickCore/colorspace.c
+@@ -329,11 +329,11 @@ static void inline ConvertXYZToJzazbz(const double X,const double Y,
+   L=0.41478972*Xp+0.579999*Yp+0.0146480*Zp;
+   M=(-0.2015100)*Xp+1.120649*Yp+0.0531008*Zp;
+   S=(-0.0166008)*Xp+0.264800*Yp+0.6684799*Zp;
+-  gamma=pow(L/white_luminance,Jzazbz_n);
++  gamma=pow(L*PerceptibleReciprocal(white_luminance),Jzazbz_n);
+   Lp=pow((Jzazbz_c1+Jzazbz_c2*gamma)/(1.0+Jzazbz_c3*gamma),Jzazbz_p);
+-  gamma=pow(M/white_luminance,Jzazbz_n);
++  gamma=pow(M*PerceptibleReciprocal(white_luminance),Jzazbz_n);
+   Mp=pow((Jzazbz_c1+Jzazbz_c2*gamma)/(1.0+Jzazbz_c3*gamma),Jzazbz_p);
+-  gamma=pow(S/white_luminance,Jzazbz_n);
++  gamma=pow(S*PerceptibleReciprocal(white_luminance),Jzazbz_n);
+   Sp=pow((Jzazbz_c1+Jzazbz_c2*gamma)/(1.0+Jzazbz_c3*gamma),Jzazbz_p);
+   Iz=0.5*Lp+0.5*Mp;
+   *az=3.52400*Lp-4.066708*Mp+0.542708*Sp+0.5;
meta-oe/recipes-support/imagemagick/files/CVE-2021-3610.patch new file +26 -0
new file mode 100644
index 0000000000..ab42d506db
@@ -0,0 +1,26 @@
+From 930ff0d1a9bc42925a7856e9ea53f5fc9f318bf3 Mon Sep 17 00:00:00 2001
+From: Cristy <[email protected]>
+Date: Thu, 27 May 2021 10:30:17 -0400
+Subject: [PATCH] eliminate heap buffer overflow vulnerability, thanks to
+ ZhangJiaxing (@r0fm1a) from Codesafe Team of Legendsec at Qi'anxin Group
+
+CVE: CVE-2021-3610
+Upstream-Status: https://github.com/ImageMagick/ImageMagick/commit/930ff0d1a9bc42925a7856e9ea53f5fc9f318bf3.patch]
+Signed-off-by: Sana Kazi [email protected]
+---
+ coders/tiff.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/coders/tiff.c b/coders/tiff.c
+index 277b9788be5..b88ce368ba5 100644
+--- a/coders/tiff.c
++++ b/coders/tiff.c
+@@ -1894,7 +1894,7 @@ static Image *ReadTIFFImage(const ImageInfo *image_info,
+         /*
+           Convert stripped TIFF image.
+         */
+-        extent=2*TIFFStripSize(tiff);
++        extent=4*TIFFStripSize(tiff);
+ #if defined(TIFF_VERSION_BIG)
+         extent+=image->columns*sizeof(uint64);
+ #else
meta-oe/recipes-support/imagemagick/files/CVE-2022-0284.patch new file +34 -0
new file mode 100644
index 0000000000..2d1c0d7c8e
@@ -0,0 +1,34 @@
+From e50f19fd73c792ebe912df8ab83aa51a243a3da7 Mon Sep 17 00:00:00 2001
+From: Cristy <[email protected]>
+Date: Wed, 19 Jan 2022 16:26:12 -0500
+Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/4729
+
+CVE: CVE-2022-0284
+Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/e50f19fd73c792ebe912df8ab83aa51a243a3da7.patch]
+Signed-off-by: Sana Kazi [email protected]
+---
+ coders/xpm.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/coders/xpm.c b/coders/xpm.c
+index 782ed732544..5f73df8bca4 100644
+--- a/coders/xpm.c
++++ b/coders/xpm.c
+@@ -773,7 +773,7 @@ static MagickBooleanType WritePICONImage(const ImageInfo *image_info,
+               break;
+             for (x=0; x < (ssize_t) picon->columns; x++)
+             {
+-              if (GetPixelAlpha(image,q) == (Quantum) TransparentAlpha)
++              if (GetPixelAlpha(picon,q) == (Quantum) TransparentAlpha)
+                 transparent=MagickTrue;
+               else
+                 SetPixelAlpha(picon,OpaqueAlpha,q);
+@@ -804,7 +804,7 @@ static MagickBooleanType WritePICONImage(const ImageInfo *image_info,
+           break;
+         for (x=0; x < (ssize_t) picon->columns; x++)
+         {
+-          if (GetPixelAlpha(image,q) == (Quantum) TransparentAlpha)
++          if (GetPixelAlpha(picon,q) == (Quantum) TransparentAlpha)
+             SetPixelIndex(picon,(Quantum) picon->colors,q);
+           q+=GetPixelChannels(picon);
+         }
meta-oe/recipes-support/imagemagick/files/CVE-2022-2719.patch new file +136 -0

136 lines not on this page · raw message

meta-oe/recipes-support/imagemagick/files/fix-cipher-leak.patch new file +178 -0

178 lines not on this page · raw message

meta-oe/recipes-support/imagemagick/imagemagick_7.0.10.bb +18 -1
index b8167f5a72..6108dece27 100644
@@ -11,11 +11,28 @@ DEPENDS = "lcms bzip2 jpeg libpng tiff zlib fftw freetype libtool"
 
 BASE_PV := "${PV}"
 PV .= "-62"
-SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https"
+SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https \
+    file://CVE-2021-20309.patch \
+    file://CVE-2021-20310.patch \
+    file://CVE-2021-3610.patch \
+    file://CVE-2022-0284.patch \
+    file://fix-cipher-leak.patch \
+    file://CVE-2022-2719.patch \
+"
+
 SRCREV = "35b4991eb0939a327f3489988c366e21068b0178"
 
 S = "${WORKDIR}/git"
 
+# current version is not affected by the CVE which affects versions at least earlier than 6.9.4-0
+CVE_CHECK_IGNORE += "CVE-2014-9826"
+
+# current version is not affected by the CVE which affects versions at least earlier than 6.9.4-0
+CVE_CHECK_IGNORE += "CVE-2016-7538"
+
+# current version is not affected by the CVE which affects versions at least earlier than 7.0.4-4
+CVE_CHECK_IGNORE += "CVE-2017-5506"
+
 inherit autotools pkgconfig update-alternatives
 
 # xml disabled because it's using xml2-config --prefix to determine prefix which returns just /usr with our libxml2
Signature · 1 line
2.25.1