diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2023-02-11 14:47:59 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2023-03-19 10:57:00 +0100 |
commit | c16add7fd9783db46bb5b308a885af62f0299e61 (patch) | |
tree | 53ddfa71f32007b8e61ae5f578038b0d2cffed38 /gnu | |
parent | d7b4ecdb4c1a845690d943f8b8d883e065081eb9 (diff) | |
download | guix-c16add7fd9783db46bb5b308a885af62f0299e61.tar guix-c16add7fd9783db46bb5b308a885af62f0299e61.tar.gz |
gnu: python-pillow: Fix CVE-2022-45199.
Fixes: <https://issues.guix.gnu.org/issue/61172>
* gnu/packages/python-xyz.scm (python-pillow/security-fixes): New variable.
(python-pillow): Add replacement.
* gnu/packages/patches/python-pillow-CVE-2022-45199.patch: New file.
* gnu/local.mk: Register it.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/patches/python-pillow-CVE-2022-45199.patch | 36 | ||||
-rw-r--r-- | gnu/packages/python-xyz.scm | 5 |
3 files changed, 42 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 2944211e12..1b922a9356 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1745,6 +1745,7 @@ dist_patch_DATA = \ %D%/packages/patches/python-peachpy-determinism.patch \ %D%/packages/patches/python-pep8-stdlib-tokenize-compat.patch \ %D%/packages/patches/python-piexif-fix-tests-with-pillow-7.2.patch \ + %D%/packages/patches/python-pillow-CVE-2022-45199.patch \ %D%/packages/patches/python-pyfakefs-remove-bad-test.patch \ %D%/packages/patches/python-pyflakes-test-location.patch \ %D%/packages/patches/python2-pyopenssl-openssl-compat.patch \ diff --git a/gnu/packages/patches/python-pillow-CVE-2022-45199.patch b/gnu/packages/patches/python-pillow-CVE-2022-45199.patch new file mode 100644 index 0000000000..3b01d3a8f4 --- /dev/null +++ b/gnu/packages/patches/python-pillow-CVE-2022-45199.patch @@ -0,0 +1,36 @@ +From 13f2c5ae14901c89c38f898496102afd9daeaf6d Mon Sep 17 00:00:00 2001 +From: Eric Soroos <eric-github@soroos.net> +Date: Fri, 28 Oct 2022 14:11:25 +0200 +Subject: [PATCH 1/5] Prevent DOS with large SAMPLESPERPIXEL in Tiff IFD + +A large value in the SAMPLESPERPIXEL tag could lead to a memory and +runtime DOS in TiffImagePlugin.py when setting up the context for +image decoding. + +diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py +index 04a63bd2b44..46166fc6335 100644 +--- a/src/PIL/TiffImagePlugin.py ++++ b/src/PIL/TiffImagePlugin.py +@@ -257,6 +257,8 @@ + (MM, 8, (1,), 1, (8, 8, 8), ()): ("LAB", "LAB"), + } + ++MAX_SAMPLESPERPIXEL = max(len(key_tp[4]) for key_tp in OPEN_INFO.keys()) ++ + PREFIXES = [ + b"MM\x00\x2A", # Valid TIFF header with big-endian byte order + b"II\x2A\x00", # Valid TIFF header with little-endian byte order +@@ -1396,6 +1398,12 @@ def _setup(self): + SAMPLESPERPIXEL, + 3 if self._compression == "tiff_jpeg" and photo in (2, 6) else 1, + ) ++ ++ if samples_per_pixel > MAX_SAMPLESPERPIXEL: ++ # DOS check, samples_per_pixel can be a Long, and we extend the tuple below ++ logger.error("More samples per pixel than can be decoded: %s", samples_per_pixel) ++ raise SyntaxError("Invalid value for samples per pixel") ++ + if samples_per_pixel < bps_actual_count: + # If a file has more values in bps_tuple than expected, + # remove the excess. + diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index 7c8b3b3378..abe4862121 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -7676,6 +7676,7 @@ retrieve text and metadata from PDFs as well as merge entire files together.") (package (name "python-pillow") (version "9.2.0") + (replacement python-pillow/security-fixes) (source (origin (method url-fetch) (uri (pypi-uri "Pillow" version)) @@ -7723,6 +7724,10 @@ a general image processing tool.") "http://www.pythonware.com/products/pil/license.htm" "The PIL Software License")))) +(define-public python-pillow/security-fixes + (package-with-patches python-pillow + (search-patches "python-pillow-CVE-2022-45199.patch"))) + (define-public python-pillow-2.9 (package (inherit python-pillow) |