Checkov: ASTEVAL Allows Malicious Tampering of Exposed AST Nodes Leads to Sandbox Escape
A vulnerability in the asteval library used by Checkov allows attackers who can control input to bypass safety checks and execute arbitrary Python code. The flaw arises because the attribute access verification can be circumvented by modifying AST nodes at runtime, exploiting a time-of-check to time-of-use (TOCTOU) issue. Specifically, the Procedure class exposes its AST in an unprotected attribute, enabling attackers to alter the AST and access dangerous dunder methods like __getattribute__. This leads to sandbox escape and arbitrary code execution within the application's context.
AI Analysis
Technical Summary
The vulnerability in asteval stems from insufficient protection of the Procedure class's 'body' attribute, which holds AST nodes. The on_attribute handler attempts to block unsafe attribute access by checking if attributes are in UNSAFE_ATTRS or are dunder methods. However, an attacker can exploit a TOCTOU race condition by hooking the 'startswith' method on an AST node's attribute string to replace it with '__getattribute__' after the safety check but before the attribute is accessed. This allows bypassing the safety check and obtaining references to sensitive Python internals, enabling arbitrary code execution. A proof-of-concept demonstrates executing the 'whoami' command via this method.
Potential Impact
Successful exploitation allows an attacker to escape the asteval sandbox and execute arbitrary Python code with the privileges of the hosting application. This can lead to full compromise of the host system, including executing system commands, accessing sensitive data, and manipulating application behavior. The CVSS score of 8.4 reflects high confidentiality, integrity, and availability impacts with low attack complexity and no user interaction required.
Mitigation Recommendations
A patch is available for this vulnerability. Users should upgrade to a fixed version of the asteval library as incorporated in Checkov versions 3.2.490 and later. Until patched, avoid processing untrusted input with asteval or restrict usage contexts to trusted environments. Review vendor advisories for the official fix and apply updates promptly.
Checkov: ASTEVAL Allows Malicious Tampering of Exposed AST Nodes Leads to Sandbox Escape
Description
A vulnerability in the asteval library used by Checkov allows attackers who can control input to bypass safety checks and execute arbitrary Python code. The flaw arises because the attribute access verification can be circumvented by modifying AST nodes at runtime, exploiting a time-of-check to time-of-use (TOCTOU) issue. Specifically, the Procedure class exposes its AST in an unprotected attribute, enabling attackers to alter the AST and access dangerous dunder methods like __getattribute__. This leads to sandbox escape and arbitrary code execution within the application's context.
CVSS v3.1
Score 8.4high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability in asteval stems from insufficient protection of the Procedure class's 'body' attribute, which holds AST nodes. The on_attribute handler attempts to block unsafe attribute access by checking if attributes are in UNSAFE_ATTRS or are dunder methods. However, an attacker can exploit a TOCTOU race condition by hooking the 'startswith' method on an AST node's attribute string to replace it with '__getattribute__' after the safety check but before the attribute is accessed. This allows bypassing the safety check and obtaining references to sensitive Python internals, enabling arbitrary code execution. A proof-of-concept demonstrates executing the 'whoami' command via this method.
Potential Impact
Successful exploitation allows an attacker to escape the asteval sandbox and execute arbitrary Python code with the privileges of the hosting application. This can lead to full compromise of the host system, including executing system commands, accessing sensitive data, and manipulating application behavior. The CVSS score of 8.4 reflects high confidentiality, integrity, and availability impacts with low attack complexity and no user interaction required.
Mitigation Recommendations
A patch is available for this vulnerability. Users should upgrade to a fixed version of the asteval library as incorporated in Checkov versions 3.2.490 and later. Until patched, avoid processing untrusted input with asteval or restrict usage contexts to trusted environments. Review vendor advisories for the official fix and apply updates promptly.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- BREW-checkov-GHSA-vp47-9734-prjw
- Osv Schema Version
- 1.7.3
- Ecosystems
- ["Homebrew"]
- Cvss Version
- 3.1
Threat ID: 6aac8e1d55bf5e2cf549073b
Added to database: 09/18/2026, 01:04:29 UTC
Last enriched: 09/18/2026, 01:37:40 UTC
Last updated: 09/18/2026, 02:11:51 UTC
Views: 4
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.