Skip to content

CVE-2023-37271 RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape

CriticalCVSS 9.9 EPSS 0.85%
Published
Updated
Exploit status
No public exploit known

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

ProductAffected versionsFixed in
pypi restrictedpython(PyPI) < 5.3 5.3
pypi restrictedpython(PyPI) = 3.4.2 No fix listed
pypi restrictedpython(PyPI) = 3.4.3 No fix listed
pypi restrictedpython(PyPI) = 3.5.0 No fix listed
pypi restrictedpython(PyPI) = 3.5.1 No fix listed
pypi restrictedpython(PyPI) = 3.5.2 No fix listed
pypi restrictedpython(PyPI) = 3.6.0 No fix listed
pypi restrictedpython(PyPI) = 3.6.0a1 No fix listed
pypi restrictedpython(PyPI) = 4.0 No fix listed
pypi restrictedpython(PyPI) = 4.0a1 No fix listed
pypi restrictedpython(PyPI) = 4.0a2 No fix listed
pypi restrictedpython(PyPI) = 4.0a3 No fix listed
pypi restrictedpython(PyPI) = 4.0b1 No fix listed
pypi restrictedpython(PyPI) = 4.0b2 No fix listed
pypi restrictedpython(PyPI) = 4.0b3 No fix listed
pypi restrictedpython(PyPI) = 4.0b4 No fix listed
pypi restrictedpython(PyPI) = 4.0b5 No fix listed
pypi restrictedpython(PyPI) = 4.0b6 No fix listed
pypi restrictedpython(PyPI) = 4.0b7 No fix listed
pypi restrictedpython(PyPI) = 4.0b8 No fix listed
pypi restrictedpython(PyPI) = 5.0 No fix listed
pypi restrictedpython(PyPI) = 5.1 No fix listed
pypi restrictedpython(PyPI) = 5.2 No fix listed
pypi restrictedpython(PyPI) = 5.2a1.dev0 No fix listed
pypi restrictedpython(PyPI) = 5.3a1.dev0 No fix listed
Show 23 more
ProductAffected versionsFixed in
pypi restrictedpython(PyPI) >= 6.0a1.dev0, < 6.1 6.1
pypi restrictedpython(PyPI) = 6.0 No fix listed
pypi restrictedpython(PyPI) = 6.0a1.dev0 No fix listed
debian/restrictedpython(Debian:12) All versions No fix listed
debian/restrictedpython(Debian:12) = 4.0~b3-3 No fix listed
debian/restrictedpython(Debian:12) = 6.2-1 No fix listed
debian/restrictedpython(Debian:12) = 8.0-1 No fix listed
debian/restrictedpython(Debian:12) = 8.1-1 No fix listed
debian/restrictedpython(Debian:12) = 8.4-1 No fix listed
debian/restrictedpython(Debian:13) < 6.2-1 6.2-1
debian/restrictedpython(Debian:14) < 6.2-1 6.2-1
zopefoundation RestrictedPython = >= 6.0a1.dev0, < 6.1 No fix listed
zopefoundation RestrictedPython = < 5.3 No fix listed
ubuntu/restrictedpython(Ubuntu:22.04) < 4.0~b3-3ubuntu0.1~esm1 4.0~b3-3ubuntu0.1~esm1
zope restrictedpython < 5.3 5.3
zope restrictedpython = 6.0 No fix listed
zope restrictedpython = 6.0-a1.dev0 No fix listed
ubuntu/restrictedpython(Ubuntu:Pro:20.04) < 4.0~b3-2ubuntu0.1~esm1 4.0~b3-2ubuntu0.1~esm1
ubuntu/restrictedpython(Ubuntu:Pro:20.04) = 4.0~b3-2 No fix listed
ubuntu/restrictedpython(Ubuntu:Pro:22.04) < 4.0~b3-3ubuntu0.1~esm1 4.0~b3-3ubuntu0.1~esm1
ubuntu/restrictedpython(Ubuntu:Pro:22.04) = 4.0~b3-2 No fix listed
ubuntu/restrictedpython(Ubuntu:Pro:22.04) = 4.0~b3-2ubuntu1 No fix listed
ubuntu/restrictedpython(Ubuntu:Pro:22.04) = 4.0~b3-3 No fix listed

References