Skip to content
OpenAdvisories
High · 8.4 CVE-2023-37271 EUVD-2023-0228GHSA-wqc8-x2pr-7jqhPYSEC-2023-118

RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape

Published Jul 11, 2023 · Updated Nov 7, 2024 · Assigned by GitHub_M

Description

RestrictedPython is a tool that helps to define a subset of the Python language which allows users to provide a program input into a trusted environment. RestrictedPython does not check access to stack frames and their attributes. Stack frames are accessible within at least generators and generator expressions, which are allowed inside RestrictedPython. Prior to versions 6.1 and 5.3, an attacker with access to a RestrictedPython environment can write code that gets the current stack frame in a generator and then walk the stack all the way beyond the RestrictedPython invocation boundary, thus breaking out of the restricted sandbox and potentially allowing arbitrary code execution in the Python interpreter. All RestrictedPython deployments that allow untrusted users to write Python code in the RestrictedPython environment are at risk. In terms of Zope and Plone, this would mean deployments where the administrator allows untrusted users to create and/or edit objects of type `Script (Python)`, `DTML Method`, `DTML Document` or `Zope Page Template`. This is a non-default configuration and likely to be extremely rare. The problem has been fixed in versions 6.1 and 5.3.

Affected products

VendorProductAffectedFixed
zopefoundation RestrictedPython >= 6.0a1.dev0, < 6.1, < 5.3 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 restrictedpython 6.2-1 —
Debian 13 restrictedpython 6.2-1 —
Debian 12 restrictedpython No fix yet —
ReleasePackageFixed inAdvisory
Ubuntu Pro 24.04 LTS restrictedpython 6.2-1ubuntu0.24.04.1~esm1 USN-7355-1
Ubuntu Pro 22.04 LTS restrictedpython 4.0~b3-3ubuntu0.1~esm1 USN-7355-1
Ubuntu Pro 20.04 LTS restrictedpython 4.0~b3-2ubuntu0.1~esm1 USN-7355-1

Affected packages

EcosystemPackageAffectedFixedRecord
PyPI restrictedpython < 5.3 5.3 GHSA-wqc8-x2pr-7jqh
PyPI restrictedpython >= 6.0a1.dev0, < 6.1 6.1 GHSA-wqc8-x2pr-7jqh

Advisories 1

References