Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. RestrictedPython
  4. ›
  5. CVE-2023-37271

CVE-2023-37271: Improper Control of Dynamically-Managed Code Resources

July 10, 2023 (updated July 20, 2023)

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.

References

  • github.com/advisories/GHSA-wqc8-x2pr-7jqh
  • github.com/pypa/advisory-database/tree/main/vulns/restrictedpython/PYSEC-2023-118.yaml
  • github.com/zopefoundation/RestrictedPython/commit/c8eca66ae49081f0016d2e1f094c3d72095ef531
  • github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-wqc8-x2pr-7jqh
  • nvd.nist.gov/vuln/detail/CVE-2023-37271

Code Behaviors & Features

Detect and mitigate CVE-2023-37271 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 5.3, all versions starting from 6.0 before 6.1

Fixed versions

  • 5.3
  • 6.1

Solution

Upgrade to versions 5.3, 6.1 or above.

Impact 9.9 CRITICAL

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
  • CWE-913: Improper Control of Dynamically-Managed Code Resources

Source file

pypi/RestrictedPython/CVE-2023-37271.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:08 +0000.