CVE-2026-76825: RestrictedPython RestrictedPython Vulnerable To Sandbox Escape Vulnerability

HIGH
Advisory Identifier: GHSA-hp3v-5vw7-fx9w
CVSS 8.4
CWE-470 CWE-693 CWE-680 CWE-200
Published
Advisory Summary

CVE-2026-76825 is a HIGH (CVSS 8.4) restrictedpython vulnerable to sandbox escape vulnerability (CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')) affecting RestrictedPython libraries in the PyPI ecosystem. The issue involves restrictedpython vulnerable to sandbox escape via string.formatter field resolution. Remediation is available by upgrading affected packages to version 8.4.

CVE-2026-76825 at a Glance

CVE Identifier CVE-2026-76825
GHSA Identifier GHSA-hp3v-5vw7-fx9w
Severity HIGH
CVSS v3.1 Base Score 8.4
CWE Classification CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')
Affected Product RestrictedPython
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-76825

To remediate this vulnerability, upgrade all affected RestrictedPython dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

RestrictedPython fixed: 8.4
pip install RestrictedPython>=8.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show RestrictedPython

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-76825, inspect your installed packages using pip:

pip show RestrictedPython

Analyze the terminal output to locate any version of RestrictedPython in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.4), your application is affected.

Note: The pip show RestrictedPython command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection'), where the product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code. In RestrictedPython, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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.

CVE-2026-76825 Affected RestrictedPython Versions

1 component(s)
Fixed Versions:
8.4
Product / Package Ecosystem Affected Versions Fixed Version
RestrictedPython
PyPI
< 8.4
8.4

References

Frequently Asked Questions

What is CVE-2026-76825?
CVE-2026-76825 is a security vulnerability in RestrictedPython involving RestrictedPython vulnerable to sandbox escape via string.Formatter field resolution under CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection').
Which RestrictedPython versions are affected?
Affected versions include releases prior to 8.4 across affected packages: RestrictedPython.
What version fixes CVE-2026-76825?
Upgrading to 8.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is RestrictedPython affected?
Yes, RestrictedPython is affected in releases prior to 8.4. Upgrade your dependency to 8.4 or later.
What is the CVSS score of CVE-2026-76825?
CVE-2026-76825 has a CVSS v3.1 base score of 8.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2026-76825?
CVE-2026-76825 is classified under CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') (The product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code.).
How can I check PyPI dependencies for CVE-2026-76825?
Run the dependency tree command: 'pip show RestrictedPython'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hp3v-5vw7-fx9w",
  "modified" : "2026-09-17T16:30:22Z",
  "published" : "2026-09-17T16:30:22Z",
  "aliases" : [ "CVE-2026-76825" ],
  "summary" : "RestrictedPython vulnerable to sandbox escape via string.Formatter field resolution",
  "details" : "### Impact\nRestrictedPython could allow a sandbox escape when a policy exposes the standard library `string` module, or otherwise exposes `string.Formatter`, to restricted code.\n\n`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.\n\nUsers 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.\n\n### Patches\nThe problem has been patched by blocking access to `string.Formatter` and unsafe `string.Formatter` traversal methods in `safer_getattr`.\n\nUsers should upgrade to the patched release once available. Affected and patched version numbers should be filled in when the release is published.\n\n### Workarounds\nDo not expose the standard library `string` module or `string.Formatter` to restricted code.\n\nIf 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "RestrictedPython"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "8.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-hp3v-5vw7-fx9w"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-76825"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zopefoundation/RestrictedPython/commit/3b47440070b91f8807c2b2998aca99e94783639a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zopefoundation/RestrictedPython"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zopefoundation/RestrictedPython/releases/tag/8.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200", "CWE-470", "CWE-680", "CWE-693" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-17T16:30:22Z",
    "nvd_published_at" : "2026-09-16T15:17:46Z"
  }
}