CVE-2025-24359 ASTEVAL Vulnerable to Maliciously Crafted Format Strings Leading to Sandbox Escape
Attackers can execute arbitrary Python code by crafting malicious format strings, bypassing the asteval library's sandbox restrictions.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2025-24359?
CVE-2025-24359 is a high-severity code injection vulnerability in lmfit asteval, published on 24 Jan 2025. It can only be exploited from the same machine or local network, with no action from the victim.
Official description
ASTEVAL is an evaluator of Python expressions and statements. Prior to version 1.0.6, if an attacker can control the input to the `asteval` library, they can bypass asteval's restrictions and execute arbitrary Python code in the context of the application using the library. The vulnerability is rooted in how `asteval` performs handling of `FormattedValue` AST nodes. In particular, the `on_formattedvalue` value uses the dangerous format method of the str class. The code allows an attacker to manipulate the value of the string used in the dangerous call `fmt.format(__fstring__=val)`. This vulnerability can be exploited to access protected attributes by intentionally triggering an `AttributeError` exception. The attacker can then catch the exception and use its `obj` attribute to gain arbitrary access to sensitive or protected object properties. Version 1.0.6 fixes this issue.
Which versions are affected by CVE-2025-24359?
3 open source packages ship an affected version, including asteval.
| Package | Affected | Fixed in |
|---|---|---|
asteval PyPI | All versions | 1.0.6 |
asteval PyPI | All versions | 1.0.6 |
asteval PyPI | All versions | 1.0.6 |
Linux distribution packages (3)
python-asteval SUSE:Package Hub 15 SP6 | All versions | 1.0.6-bp156.4.3.1 |
python-asteval openSUSE:Leap 15.6 | All versions | 1.0.6-bp156.4.3.1 |
python-asteval openSUSE:Tumbleweed | All versions | 1.0.6-1.1 |
How do I fix CVE-2025-24359?
Upgrade asteval to 1.0.6 or later.
Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.
Is CVE-2025-24359 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-24359 exists.
Sources
Also known as DEBIAN-CVE-2025-24359, GHSA-3wwr-3g9f-9gc7, OESA-2025-1297, OESA-2025-1298, OESA-2025-2558, PYSEC-2026-1195 and 4 more.