GitHub Advisoryadvisory · PyPI

GHSA-hp3v-5vw7-fx9w RestrictedPython vulnerable to sandbox escape via string.Formatter field resolution

HIGH Published 2026-09-17 Modified 2026-09-17 Official page ↗
Aliases
CVE-2026-76825
Ecosystem
PyPI
Packages
RestrictedPython
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H
Weaknesses
CWE-200, CWE-470, CWE-680, CWE-693
Reviewed
2026-09-17

Affected packages

• PyPI RestrictedPython: < 8.4 → fixed in 8.4

Description

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.

Related

Alias · CVE (1)

  • CVE-2026-76825 RestrictedPython is a tool that helps define a subset of the Python language for accepting program input in a trusted environment. vulnerability

Weakness · CWE (4)

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

References