VAITP Dataset

← Back to the dataset

CVE-2026-102734

Asteval allows ctypes memory access via from_address, enabling arbitrary read/write.

  • CVSS 5.5
  • CWE-693
  • Memory Corruption
  • Local

asteval is a Python expression evaluator designed for restricted execution. Prior to 1.0.9, in asteval/astutils.py, the default Interpreter with numpy enabled exposes a ctypes type and permits from_address memory access. safe_getattr blocks the ctypes module but not reachable ctypes type objects, while attribute assignments use unfiltered setattr instead of safe_setattr. An attacker-controlled expression can derive an address with id, read memory through from_address, and write through an attribute assignment. The expression can read or corrupt arbitrary process memory, escape the intended sandbox, execute code, disclose secrets, or crash the host process. This issue is fixed in version 1.0.9.

CVSS base score
5.5
Published
2026-10-13
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Assignment
Code defect classification
Incorrect Assignment
Category
Memory Corruption
Subcategory
Out-of-Bound Accesses
Accessibility scope
Local
Impact
Arbitrary Code Execution
Affected component
asteval
Fixed by upgrading
Yes

Solution

Upgrade asteval to version 1.0.9 or later.

Vulnerable code sample

import numpy as np
from asteval import Interpreter, make_symbol_table

def eval_user_expr(expr):
    # Build a symbol table that includes numpy (default behavior)
    symtable = make_symbol_table()
    # VULNERABLE: unsafe attribute assignment allows arbitrary memory write
    a = Interpreter(symtable=symtable, use_numpy=True)
    # The attacker can craft `expr` to call ctypes.from_address(...)
    return a(expr)

Patched code sample

import numpy as np
from asteval import Interpreter, make_symbol_table, safe_setattr

def eval_user_expr(expr):
    # Build a symbol table that includes numpy (default behavior)
    symtable = make_symbol_table()
    # FIX: use safe_setattr to prevent arbitrary memory write
    a = Interpreter(symtable=symtable, use_numpy=True, setattr=safe_setattr)
    return a(expr)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve2026102734,
  title        = {{Asteval allows ctypes memory access via from_address, enabling arbitrary read/write.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-102734},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102734/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.