CVE-2026-55830: RestrictedPython RestrictedPython Guard Hooks Can Be Vulnerability

HIGH
Advisory Identifier: GHSA-ffg3-p8fm-mjx2
CVSS 8.3
CWE-184
Published
Advisory Summary

CVE-2026-55830 is a HIGH (CVSS 8.3) restrictedpython guard hooks can be vulnerability (CWE-184: Incomplete List of Disallowed Inputs) affecting RestrictedPython libraries in the PyPI ecosystem. The issue involves restrictedpython guard hooks can be shadowed via positional-only arguments. Remediation is available by upgrading affected packages to version 8.3.

CVE-2026-55830 at a Glance

CVE Identifier CVE-2026-55830
GHSA Identifier GHSA-ffg3-p8fm-mjx2
Severity HIGH
CVSS v3.1 Base Score 8.3
CWE Classification CWE-184: Incomplete List of Disallowed Inputs
Affected Product RestrictedPython
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.3

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:L).

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 Low (A:L)

How to Fix CVE-2026-55830

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.3
pip install RestrictedPython>=8.3
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-55830, 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.3), 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-184: Incomplete List of Disallowed Inputs, where the product implements a protection mechanism that relies on a list of inputs (or properties of inputs) that are not allowed by policy or otherwise require other action to neutralize before additional processing takes place, but the list is incomplete. 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 rewrites sensitive operations to go through guard hooks. Attribute access becomes `_getattr_(obj, name)`, item access becomes `_getitem_(obj, key)`, writes go through `_write_`, and print goes through `_print_`. The embedding application supplies these hooks to enforce its policy. Argument-name validation rejects these protected names for regular arguments, `*args`, `**kwargs`, and keyword-only arguments, but it misses positional-only arguments (the ones before `/`). So a function like: ```python def f(_getattr_=evil, /): return o.x ``` makes `_getattr_` a local that shadows the policy hook, and the rewritten access calls `evil` instead. The same works for `_getitem_`, `_write_`, and `_print_`. Shadowing `_print_` can also be used to capture the internal `_getattr_` hook that RestrictedPython passes in. The result is that sandboxed code can bypass the access policy the embedding application relies on. In applications that also handle sandbox-controlled objects unsafely (for example serializing them with pickle), this primitive can be chained further, up to remote code execution. That part depends on the embedding application, but the underlying guard bypass is in RestrictedPython. ### Proof of concept On an unpatched RestrictedPython this prints `shadowed` and an empty `calls` list, meaning the policy `_getattr_` never ran. With the fix, `compile_restricted` rejects the code. ```python from RestrictedPython import compile_restricted from RestrictedPython.Guards import safe_globals, safer_getattr calls = [] def policy_getattr(obj, name, default=None): calls.append(name) # the real guard records every access return safer_getattr(obj, name, default) src = """ def f(o, _getattr_=lambda obj, name: "shadowed", /): return o.x """ code = compile_restricted(src, "<s>", "exec") # currently compiles, should be rejected g = dict(safe_globals) g["_getattr_"] = policy_getattr exec(code, g) class O: x = "secret" print(g["f"](O())) # -> "shadowed" (attacker's local was used) print(calls) # -> [] (policy _getattr_ never ran) ``` ### Patches The fix validates positional-only argument names the same way the other argument kinds are already validated. It will ship in the next release. ### Workarounds None other than upgrading. If you cannot upgrade immediately, reject any submitted code whose function or lambda definitions use positional-only parameters with leading-underscore names before compiling.

CVE-2026-55830 Affected RestrictedPython Versions

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

References

Frequently Asked Questions

What is CVE-2026-55830?
CVE-2026-55830 is a security vulnerability in RestrictedPython involving RestrictedPython guard hooks can be shadowed via positional-only arguments under CWE-184: Incomplete List of Disallowed Inputs.
Which RestrictedPython versions are affected?
Affected versions include releases prior to 8.3 across affected packages: RestrictedPython.
What version fixes CVE-2026-55830?
Upgrading to 8.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is RestrictedPython affected?
Yes, RestrictedPython is affected in releases prior to 8.3. Upgrade your dependency to 8.3 or later.
What is the CVSS score of CVE-2026-55830?
CVE-2026-55830 has a CVSS v3.1 base score of 8.3 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L.
What CWE is associated with CVE-2026-55830?
CVE-2026-55830 is classified under CWE-184: Incomplete List of Disallowed Inputs (The product implements a protection mechanism that relies on a list of inputs (or properties of inputs) that are not allowed by policy or otherwise require other action to neutralize before additional processing takes place, but the list is incomplete.).
How can I check PyPI dependencies for CVE-2026-55830?
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-ffg3-p8fm-mjx2",
  "modified" : "2026-08-28T22:51:35Z",
  "published" : "2026-08-28T22:51:35Z",
  "aliases" : [ "CVE-2026-55830" ],
  "summary" : "RestrictedPython guard hooks can be shadowed via positional-only arguments",
  "details" : "### Impact\n\nRestrictedPython rewrites sensitive operations to go through guard hooks. Attribute access becomes `_getattr_(obj, name)`, item access becomes `_getitem_(obj, key)`, writes go through `_write_`, and print goes through `_print_`. The embedding application supplies these hooks to enforce its policy.\n\nArgument-name validation rejects these protected names for regular arguments, `*args`, `**kwargs`, and keyword-only arguments, but it misses positional-only arguments (the ones before `/`). So a function like:\n\n```python\ndef f(_getattr_=evil, /):\n    return o.x\n```\n\nmakes `_getattr_` a local that shadows the policy hook, and the rewritten access calls `evil` instead. The same works for `_getitem_`, `_write_`, and `_print_`. Shadowing `_print_` can also be used to capture the internal `_getattr_` hook that RestrictedPython passes in.\n\nThe result is that sandboxed code can bypass the access policy the embedding application relies on. In applications that also handle sandbox-controlled objects unsafely (for example serializing them with pickle), this primitive can be chained further, up to remote code execution. That part depends on the embedding application, but the underlying guard bypass is in RestrictedPython.\n\n### Proof of concept\n\nOn an unpatched RestrictedPython this prints `shadowed` and an empty `calls` list, meaning the policy `_getattr_` never ran. With the fix, `compile_restricted` rejects the code.\n\n```python\nfrom RestrictedPython import compile_restricted\nfrom RestrictedPython.Guards import safe_globals, safer_getattr\n\ncalls = []\ndef policy_getattr(obj, name, default=None):\n    calls.append(name)  # the real guard records every access\n    return safer_getattr(obj, name, default)\n\nsrc = \"\"\"\ndef f(o, _getattr_=lambda obj, name: \"shadowed\", /):\n    return o.x\n\"\"\"\n\ncode = compile_restricted(src, \"<s>\", \"exec\")   # currently compiles, should be rejected\ng = dict(safe_globals)\ng[\"_getattr_\"] = policy_getattr\nexec(code, g)\n\nclass O:\n    x = \"secret\"\n\nprint(g[\"f\"](O()))   # -> \"shadowed\"   (attacker's local was used)\nprint(calls)         # -> []           (policy _getattr_ never ran)\n```\n\n### Patches\n\nThe fix validates positional-only argument names the same way the other argument kinds are already validated. It will ship in the next release.\n\n### Workarounds\n\nNone other than upgrading. If you cannot upgrade immediately, reject any submitted code whose function or lambda definitions use positional-only parameters with leading-underscore names before compiling.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "RestrictedPython"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "8.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 8.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-ffg3-p8fm-mjx2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-55830"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zopefoundation/RestrictedPython/commit/3737596ec9f28c34a073cc845bd2f4c0a80cb671"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zopefoundation/RestrictedPython"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-184" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-08-28T22:51:35Z",
    "nvd_published_at" : "2026-07-08T22:17:15Z"
  }
}