High

RestrictedPython vulnerable to sandbox escape via string.Formatter field resolution

  • Disclosed: 17.09.2026
  • Updated: 11.10.2026 15:18

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.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) restrictedpython < 8.4 8.4

References

CVSS score 8.4/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H
Weakness (CWE)
CWE-200, CWE-470, CWE-680, CWE-693
Platform
Python (PyPI)
Package
restrictedpython
Disclosed
17.09.2026
Updated
11.10.2026 15:18

Sources and licenses

OSV / GitHub Advisory Database - PYSEC-2026-4161 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-hp3v-5vw7-fx9w - CC BY 4.0

Vulnerability history: restrictedpython

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
6
First → latest
07.2023 09.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 6

Disclosures per year

  1. 2023: 2
  2. 2024: 1
  3. 2025: 1
  4. 2026: 2
  1. RestrictedPython vulnerable to sandbox escape via string.Formatter field resolution this entry
    High · 8.4 CVE-2026-76825 < 8.4 8.4
  2. High · 8.3 CVE-2023-41039 < 5.4, >= 6.0, < 6.2 5.4, 6.2
  3. High · 8.4 CVE-2023-37271 < 5.3, >= 6.0a1.dev0, < 6.1, < 5.3 5.3, 6.1

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.