LiveActive security incident?Get immediate response
CVE Record

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

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.

HighCVSS 8.4Not KEV-listedUpdated
Glexia's TakeAutomated analysishigh

Security readout for executives and security teams

Plain-English summary

CVE-2023-37271 is a sandbox escape in RestrictedPython. If an attacker can submit Python code into a RestrictedPython environment, they may break out of the intended restrictions and potentially run arbitrary code inside the Python interpreter. Default Zope/Plone deployments are unlikely to be exposed unless untrusted users can create or edit specific script/template objects.

Executive priority

Treat this as high priority where RestrictedPython executes user-supplied code. For standard Zope/Plone deployments without untrusted script authoring, urgency is lower but still warrants inventory and version validation because sandbox escapes can undermine application trust boundaries.

Technical view

RestrictedPython failed to restrict access to stack frames and their attributes. Because generators and generator expressions are allowed, malicious code could obtain a current frame and traverse beyond the RestrictedPython boundary. The issue affects versions before 6.1 and before 5.3, and is tracked as CWE-913 with CVSS 8.4.

Likely exposure

Exposure is limited to deployments that let untrusted users write Python code executed by RestrictedPython. For Zope and Plone, the cited advisory says risk requires non-default administrator configuration allowing untrusted creation or editing of Script (Python), DTML Method, DTML Document, or Zope Page Template objects.

Exploitation context

The CVE is not in CISA KEV in the supplied bundle, and no cited source states active exploitation. Exploitation requires low privileges but high complexity and access to submit code into the restricted environment.

Researcher notes

Focus triage on whether RestrictedPython is used as a security boundary for untrusted code. The advisory describes frame access through generators as the escape path, but this analysis intentionally omits reproduction details. Evidence supports fixed versions and affected ranges, but not active exploitation.

Mitigation direction

  • Upgrade RestrictedPython to version 6.1 or 5.3 or later.
  • Remove untrusted user access to RestrictedPython code-authoring features.
  • Review Zope/Plone permissions for the listed script and template object types.
  • Update dependency lockfiles, containers, and deployed runtimes consistently.
  • Follow the GitHub advisory for any environment-specific guidance.

Validation and detection

  • Check installed RestrictedPython versions in production and build artifacts.
  • Identify applications or products embedding RestrictedPython.
  • Confirm untrusted users cannot author code executed by RestrictedPython.
  • Review Zope/Plone roles for the listed object creation and edit permissions.
  • Verify the fixed version is loaded at runtime after deployment.
Prepared
Confidence
high
Sources
4

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cwe · low confidence lookup

CWE-913: Exact CWE lookup

Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
description · low confidence lookup

Execution behavior lookup

The CVE wording references code or command execution, so execution technique review may help defensive triage. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.

Open ATT&CK lookup
description · low confidence lookup

Privilege behavior lookup

The CVE wording references privilege impact, so privilege escalation and authorization behavior review may help. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.

Open ATT&CK lookup
cve · low confidence lookup

CVE-2023-37271 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
High
CVSS
8.4 (3.1)
Known Exploited
No
Published

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

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
0Timeline events
0ADP providers
3Source links

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
8.4CVSS 3.1HighCVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L1.86Primary CVE score

Vulnerability scoring details

Base CVSS 3.1 score

8.4High
CVSS 3.1 vector shape for CVE-2023-37271Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

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

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone
Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
zopefoundationRestrictedPython>= 6.0a1.dev0, < 6.1, < 5.3Listed
Weakness

CWE details

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.

CWE-913 · source CWE mapping

Improper Control of Dynamically-Managed Code Resources

Improper Control of Dynamically-Managed Code Resources represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.