VYPR
Critical severityNVD Advisory· Published Jan 7, 2022· Updated Oct 15, 2024

CVE-2022-22817

CVE-2022-22817

Description

PIL.ImageMath.eval in Pillow before 9.0.0 allows evaluation of arbitrary expressions, such as ones that use the Python exec method. A lambda expression could also be used.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Pillow before 9.0.0 allows arbitrary code execution via ImageMath.eval by passing expressions that invoke Python builtins such as `exec`.

Vulnerability

PIL.ImageMath.eval in Pillow versions prior to 9.0.0 exposed Python builtins to the expression evaluator, allowing an attacker to craft arbitrary expressions. For example, ImageMath.eval("exec(exit())") would execute the exec builtin. The vulnerability is present in all versions before 9.0.0 [1][3].

Exploitation

An attacker who can control the expression passed to PIL.ImageMath.eval can inject arbitrary Python code. No authentication or special privileges are needed beyond the ability to supply an expression to the vulnerable function. The attacker can use builtins like exec, eval, __import__, or lambda expressions to execute arbitrary commands. For instance, ImageMath.eval("exec('import os; os.system(\"id\")')") would run system commands [1][2].

Impact

Successful exploitation leads to arbitrary code execution with the privileges of the Python process using Pillow. This can result in full compromise of the application, including data exfiltration, file modification, or further lateral movement within the environment [2][3].

Mitigation

The fix was released in Pillow 9.0.0 on 2022-01-02, which restricts the builtins available to ImageMath.eval to only image-related functions. Users should upgrade to Pillow 9.0.0 or later. For older versions, no official workaround is provided; upgrading is the recommended action [3][4].

AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
pillowPyPI
< 9.0.19.0.1

Affected products

55

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

10

News mentions

0

No linked articles in our index yet.