# 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.

- **Severity:** High 8.4 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 24 Jan 2025
- **Updated:** 12 Feb 2025
- **Also known as:** DEBIAN-CVE-2025-24359, GHSA-3wwr-3g9f-9gc7, OESA-2025-1297, OESA-2025-1298, OESA-2025-2558, PYSEC-2026-1195, ROOT-APP-PYPI-CVE-2025-24359, UBUNTU-CVE-2025-24359, openSUSE-SU-2025:0052-1, openSUSE-SU-2025:14701-1

## 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.

Weakness: CWE-749 (Exposed Dangerous Method or Function), CWE-134 (Use of Externally-Controlled Format String)

## Which versions are affected by CVE-2025-24359?

3 open source packages ship an affected version, including asteval.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `asteval` | PyPI | All versions | 1.0.6 |
| `asteval` | PyPI | All versions | 1.0.6 |
| `asteval` | PyPI | All versions | 1.0.6 |
| `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.

## Is CVE-2025-24359 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-24359 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-24359 and fix it if it is affected.

What it is: 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.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-24359 exists.

Affected packages and fixed versions:
- asteval (PyPI): affected all versions; fixed in 1.0.6
- asteval (PyPI): affected all versions; fixed in 1.0.6
- asteval (PyPI): affected all versions; fixed in 1.0.6

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-24359/ (Markdown: https://insights.sbomify.com/CVE-2025-24359/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-24359
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-24359
- OSV: https://osv.dev/vulnerability/CVE-2025-24359

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-24359/
Summaries are generated and may contain mistakes; the official description above is the record.
