Miggo Logo

GHSA-vp47-9734-prjw: ASTEVAL Allows Malicious Tampering of Exposed AST Nodes Leads to Sandbox Escape

8.4

CVSS Score
3.1

Basic Information

CVE ID
-
EPSS Score
-
Published
1/23/2025
Updated
1/23/2025
KEV Status
No
Technology
TechnologyPython

Technical Details

CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
astevalpip<= 1.0.51.0.6

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from two key points:

  1. on_attribute's attribute safety check is vulnerable to TOCTOU attacks due to mutable AST nodes. The check uses node.attr.startswith('__') which attackers can bypass by modifying node.attr after the check but before getattr() is called.
  2. Procedure.init stores user-defined function ASTs in Procedure.body without any access restrictions. This allows attackers to replace AST nodes like Attribute.value.attr with dangerous values like getattribute during evaluation. The commit diff shows the vulnerability was fixed by replacing on_attribute's logic with safe_getattr and hardening Procedure attributes, confirming these as the vulnerable components.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

### Summ*ry I* *n *tt**k*r **n *ontrol t** input to t** *st*v*l li*r*ry, t**y **n *yp*ss its s***ty r*stri*tions *n* *x**ut* *r*itr*ry Pyt*on *o** wit*in t** *ppli**tion's *ont*xt. ### **t*ils T** vuln*r**ility is root** in *ow `*st*v*l` p*r*orms *t

Reasoning

T** vuln*r**ility st*ms *rom two k*y points: *. on_*ttri*ut*'s *ttri*ut* s***ty ****k is vuln*r**l* to TO*TOU *tt**ks *u* to mut**l* *ST no**s. T** ****k us*s no**.*ttr.st*rtswit*('__') w*i** *tt**k*rs **n *yp*ss *y mo*i*yin* no**.*ttr **t*r t** ****