Executive brief
RestrictedPython is a Python sandbox library used to restrict untrusted code execution by enforcing access policies through guard hooks. This vulnerability allows attackers to bypass these security guards by shadowing protected hook names using positional-only function parameters. An attacker can then intercept sensitive operations like attribute access and item access, or even capture internal hooks—potentially leading to unauthorized data access, modification, or remote code execution depending on how the host application handles the compromised objects.
Technical details
RestrictedPython rewrites sensitive operations to route through guard hooks supplied by the embedding application: attribute access becomes `_getattr_(obj, name)`, item access becomes `_getitem_(obj, key)`, assignments through `_write_`, and printing through `_print_`. The vulnerability is a CWE-184 (Incomplete List of Disallowed Inputs): the `compile_restricted` function validates protected names in regular arguments, `*args`, `**kwargs`, and keyword-only arguments, but overlooks positional-only parameters (those before the `/` separator in Python function signatures). By defining a function like `def f(_getattr_=evil, /)`, attackers can create a local variable that shadows the policy hook, causing subsequent rewrites to call the attacker's code instead. Shadowing `_print_` also allows capturing RestrictedPython's internal `_getattr_` hook. The fix validates positional-only argument names using the same mechanism already applied to other parameter types. Attack requires the ability to submit code for compilation, and fix availability is confirmed for version 8.3.
Affected products
- Zope Foundation RestrictedPython 8.2 and earlier
Timeline
- 2026-06-22: disclosed: Vulnerability published by GitHub Advisory Database
- 2026-08-28: advisory: Advisory updated with full details
- 2026-08-28: patched: Fix released in RestrictedPython version 8.3