CVE-2026-76825: RestrictedPython vulnerable to sandbox escape via string.Formatter field resolution
Impact RestrictedPython could allow a sandbox escape when a policy exposes the standard library string module, or otherwise exposes string.Formatter, to restricted code. string.Formatter field resolution methods such as getfield can perform attribute and item traversal internally and return live object references.
Published Sep 17, 2026 · Updated Sep 22, 2026
Affected packages
RestrictedPython
- Ecosystem
- PyPI
- Affected
- < 8.4
- Fixed in
- 8.4
- Check
pip show RestrictedPython
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Impact
RestrictedPython could allow a sandbox escape when a policy exposes the standard library string module, or otherwise exposes string.Formatter, to restricted code.
string.Formatter field resolution methods such as get_field can perform attribute and item traversal internally and return live object references. This can bypass RestrictedPython's normal attribute guards and may allow access to sensitive objects such as function globals, builtins, file access, or code execution primitives.
Users are impacted if they run untrusted code with RestrictedPython and expose string.Formatter, directly or indirectly, for example through a custom import policy or globals.
Patches
The problem has been patched by blocking access to string.Formatter and unsafe string.Formatter traversal methods in safer_getattr.
Users should upgrade to the patched release once available. Affected and patched version numbers should be filled in when the release is published.
Workarounds
Do not expose the standard library string module or string.Formatter to restricted code.
If a custom import hook is used, deny imports of string or provide only a restricted wrapper that does not expose Formatter. If custom globals are supplied, ensure neither string.Formatter nor Formatter instances are available to restricted code.
Credited to icemac, kakashi-1337, dataflake, T-Chachamaru.
References
- https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-hp3v-5vw7-fx9w
- https://nvd.nist.gov/vuln/detail/CVE-2026-76825
- https://github.com/zopefoundation/RestrictedPython/commit/3b47440070b91f8807c2b2998aca99e94783639a
- https://github.com/zopefoundation/RestrictedPython/releases/tag/8.4
- https://github.com/advisories/GHSA-hp3v-5vw7-fx9w
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-55830
RestrictedPython guard hooks can be shadowed via positional-only arguments
high8.3Aug 28, 2026CVE-2025-22153
try/except* clauses could allow bypass RestrictedPython via type confusion bug in the CPython interpreter
high7.9Jan 23, 2025CVE-2024-47532
RestrictedPython information leakage via `AttributeError.obj` and the `string` module
high7.5Sep 30, 2024
