# CVE-2026-76825: RestrictedPython: Sandbox escape via string.Formatter field resolution

> Attackers can escape the RestrictedPython sandbox to execute arbitrary code if the string module is exposed to restricted code.

- **Severity:** High 8.4 (`CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 16 Sep 2026
- **Updated:** 16 Sep 2026
- **Also known as:** DEBIAN-CVE-2026-76825, ECHO-d1ef-a46c-f47d, GHSA-hp3v-5vw7-fx9w, MINI-5gh9-wxp2-6vjc, MINI-73w8-j9wr-5f93, MINI-g228-w3h2-2463, MINI-hvfx-rx5x-3r6g, MINI-m4qg-67jx-97qv, MINI-pjhj-v5mv-33vm, MINI-rp33-wjc9-qgxc, MINI-x2q9-xgh6-83rv, MINI-x7wr-3rmq-94p6, PYSEC-2026-4161, UBUNTU-CVE-2026-76825

## What is CVE-2026-76825?

CVE-2026-76825 is a high-severity code injection vulnerability in zopefoundation RestrictedPython, published on 16 Sep 2026. An attacker needs administrator access to exploit it, and only if a user opens a file or follows a link.

### Official description

RestrictedPython is a tool that helps define a subset of the Python language for accepting program input in a trusted environment. Prior to 8.4, RestrictedPython could allow a sandbox escape when a custom import policy or globals exposed the standard library string module, the string.Formatter class, a Formatter instance, or a Formatter subclass to restricted code. The string.Formatter methods format, get_field, get_value, and vformat performed attribute and item traversal internally without passing through RestrictedPython's safer_getattr protections. Restricted code could use those live object references to reach function globals, builtins, file access, or code execution primitives, affecting confidentiality, integrity, and availability in the host environment. This issue is fixed in version 8.4.

Weakness: CWE-693 (Protection Mechanism Failure), CWE-680 (Integer Overflow to Buffer Overflow), CWE-470 (Use of Externally-Controlled Input to Select Classes or Code), CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor)

## Which versions are affected by CVE-2026-76825?

3 open source packages ship an affected version, including restrictedpython and RestrictedPython.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `restrictedpython` | PyPI | All versions | 8.4 |
| `restrictedpython` | PyPI | All versions | 8.4 |
| `RestrictedPython` | PyPI | All versions | 8.4 |

## How do I fix CVE-2026-76825?

Upgrade restrictedpython to 8.4 or later.

## Is CVE-2026-76825 being exploited?

There is no known exploitation of CVE-2026-76825 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-76825 and fix it if it is affected.

What it is: CVE-2026-76825 is a high-severity code injection vulnerability in zopefoundation RestrictedPython, published on 16 Sep 2026. An attacker needs administrator access to exploit it, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2026-76825 in the wild and no public exploit code.

Affected packages and fixed versions:
- restrictedpython (PyPI): affected all versions; fixed in 8.4
- restrictedpython (PyPI): affected all versions; fixed in 8.4
- RestrictedPython (PyPI): affected all versions; fixed in 8.4

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-2026-76825/ (Markdown: https://insights.sbomify.com/CVE-2026-76825/index.md)
```

## Sources

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

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