8.4high
RestrictedPython: Sandbox escape via string.Formatter field resolution
- Severity
- 8.4high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.59% (higher than 49% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-hp3v-5vw7-fx9wPYSEC-2026-4161
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| zopefoundation RestrictedPython | < 8.4 | CVE List |
| restrictedpython (PyPI) | before 8.4 | GitHub Advisory Database, PyPA Advisory Database |
All scores
| GitHub_M | 8.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H |
| GitHub | 8.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H |
| PyPA Advisory Database | 8.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H |
Classification
What each source says
CVE List
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.
GitHub Advisory Database
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.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-76825 changed 2026-09-16 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-hp3v-5vw7-fx9w changed 2026-10-01 | CC-BY-4.0 |
| NVD | CVE-2026-76825 changed 2026-09-16 | Public domain |
| PyPA Advisory Database | PYSEC-2026-4161 changed 2026-10-01 | CC-BY-4.0 |