CVE-2026-102734
asteval sandbox escape: arbitrary native memory read/write via numpy ctypes in default asteval Interpreter
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.
Attack profile
How easy it is to exploit
- Attack vector
- Local
- Complexity
- Low
- Privileges needed
- None
- User interaction
- Required
What an attacker can affect
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Exploit likelihood
What each source reports
CVE List Score used
5.5
asteval sandbox escape: arbitrary native memory read/write via numpy ctypes in default asteval Interpreter
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.
- Record
CVE-2026-102734- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Weakness
- CWE-693, CWE-749, CWE-913
- Updated
- 2026-11-02
EUVDEUVD-2026-98813
5.5
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.
- Record
EUVD-2026-98813- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-9w56-46f6-3qhx
5.5
asteval Sandbox Escape: arbitrary native memory read/write via numpy ctypes in default asteval Interpreter
Summary
With its default configuration (numpy enabled, import disabled), asteval's Interpreter lets an attacker-controlled expression obtain a raw arbitrary process-memory read and write primitive, without using import, any __dunder__ attribute, or eval/exec/getattr. Arbitrary in-process read/write is equivalent to arbitrary code execution and is a complete escape of the sandbox whose entire purpose is "untrusted string in, no arbitrary execution out." Any application that feeds untrusted input to asteval with numpy installed (the default) is affected.
Details
asteval's attribute filter (asteval/astutils.py: safe_getattr) blocks every __dunder__ name and blocks objects whose attribute value is identity-equal to one of the modules in UNSAFE_MODULES = {io, os, sys, ctypes}. The ctypes module entry was added recently (commit 9d9d430) and correctly blocks ndarray.ctypes._ctypes.
However, the module check is identity-only against the ctypes module. It does not cover ctypes type objects and their metaclass methods, which are reachable through numpy's ndarray.ctypes wrapper using only ordinary (non-dunder) attribute names:
zeros(1, dtype=int32).ctypes.shape._type_ -> <class 'ctypes.c_long'>
ndarray.ctypes exposes .shape (a ctypes array) whose element type ._type_ is ctypes.c_long. None of ctypes, .shape, ._type_ is a dunder, none is in UNSAFE_ATTRS, and the returned value is a type, not the ctypes module, so safe_getattr permits all of them.
On that ctypes type, the metaclass method from_address is reachable (non-dunder, not in UNSAFE_ATTRS; it is not even listed by dir(), which is likely why it was missed):
- Arbitrary read:
c_long.from_address(addr).valuereads 8 bytes at any address.id()(a permitted builtin) supplies arbitrary object addresses. - Arbitrary write:
cell = c_long.from_address(addr); cell.value = Xwrites 8 bytes to any address. The write half rides asteval's unfilteredsetattrinInterpreter.node_assign(theast.Attributebranch performssetattr(self.run(node.value), node.attr, val)with no attribute-name check).
Root cause is two gaps:
safe_getattrblocks the ctypes module but not ctypes types / metaclass methods (from_address,from_buffer,from_buffer_copy,in_dll,from_param) reachable viandarray.ctypes ... ._type_.node_assignperforms attribute writes (setattr) and deletes (delattr) with no attribute-name filtering.
This belongs to the known "numpy is a large attack surface" class (the docs already note open() read and ndarray.tofile() write), but this specific arbitrary memory read/write chain is undocumented and bypasses the most recent ctypes-module hardening. All previously reported escapes (CVE-2025-24359 / GHSA-3wwr-3g9f-9gc7, GHSA-vp47-9734-prjw, reduce/reduce_ex, classic __subclasses__ traversal) are patched on the current code; this one is live.
PoC
Self contained POC here: https://gist.github.com/thegr1ffyn/16b67c5f9b5339a7e2bdc91423ff09e3
Environment: pip install asteval numpy (verified on asteval 1.0.8, numpy 2.4.6, CPython 3.12.3; the chain is numpy-1.x/2.x robust). Default Interpreter (use_numpy=True, import disabled).
Minimal one-expression arbitrary read (reads 8 bytes at an attacker-chosen address):
zeros(1,dtype=int32).ctypes.shape._type_.from_address(id(zeros(1))).value
Minimal arbitrary write (writes 0x4142434445464748 to a chosen address; here our own array buffer, observed back through numpy):
a = zeros(2, dtype=int32)
cell = a.ctypes.shape._type_.from_address(a.ctypes.data)
cell.value = 0x4142434445464748 # -> a[0]=0x45464748, a[1]=0x41424344
A full self-contained script is attached (poc_asteval_ctypes.py); running it prints the recovered PyObject header of a private object (arbitrary read) and confirms a raw write landing at a chosen pointer (arbitrary write), all from a default,…
- Record
GHSA-9w56-46f6-3qhx- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Weakness
- CWE-693, CWE-749, CWE-913
- Updated
- 2026-11-02
NVD
5.5
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.
- Record
CVE-2026-102734- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Weakness
- CWE-693, CWE-749, CWE-913
- Updated
- 2026-11-02
OSV
5.5
asteval sandbox escape: arbitrary native memory read/write via numpy ctypes in default asteval Interpreter
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.
- Record
CVE-2026-102734- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Weakness
- CWE-693, CWE-749, CWE-913
- Updated
- 2026-11-02
OSVDEBIAN-CVE-2026-102734
5.5
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.
- Record
DEBIAN-CVE-2026-102734- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVGHSA-9w56-46f6-3qhx
5.5
asteval Sandbox Escape: arbitrary native memory read/write via numpy ctypes in default asteval Interpreter
Summary
With its default configuration (numpy enabled, import disabled), asteval's Interpreter lets an attacker-controlled expression obtain a raw arbitrary process-memory read and write primitive, without using import, any __dunder__ attribute, or eval/exec/getattr. Arbitrary in-process read/write is equivalent to arbitrary code execution and is a complete escape of the sandbox whose entire purpose is "untrusted string in, no arbitrary execution out." Any application that feeds untrusted input to asteval with numpy installed (the default) is affected.
Details
asteval's attribute filter (asteval/astutils.py: safe_getattr) blocks every __dunder__ name and blocks objects whose attribute value is identity-equal to one of the modules in UNSAFE_MODULES = {io, os, sys, ctypes}. The ctypes module entry was added recently (commit 9d9d430) and correctly blocks ndarray.ctypes._ctypes.
However, the module check is identity-only against the ctypes module. It does not cover ctypes type objects and their metaclass methods, which are reachable through numpy's ndarray.ctypes wrapper using only ordinary (non-dunder) attribute names:
zeros(1, dtype=int32).ctypes.shape._type_ -> <class 'ctypes.c_long'>
ndarray.ctypes exposes .shape (a ctypes array) whose element type ._type_ is ctypes.c_long. None of ctypes, .shape, ._type_ is a dunder, none is in UNSAFE_ATTRS, and the returned value is a type, not the ctypes module, so safe_getattr permits all of them.
On that ctypes type, the metaclass method from_address is reachable (non-dunder, not in UNSAFE_ATTRS; it is not even listed by dir(), which is likely why it was missed):
- Arbitrary read:
c_long.from_address(addr).valuereads 8 bytes at any address.id()(a permitted builtin) supplies arbitrary object addresses. - Arbitrary write:
cell = c_long.from_address(addr); cell.value = Xwrites 8 bytes to any address. The write half rides asteval's unfilteredsetattrinInterpreter.node_assign(theast.Attributebranch performssetattr(self.run(node.value), node.attr, val)with no attribute-name check).
Root cause is two gaps:
safe_getattrblocks the ctypes module but not ctypes types / metaclass methods (from_address,from_buffer,from_buffer_copy,in_dll,from_param) reachable viandarray.ctypes ... ._type_.node_assignperforms attribute writes (setattr) and deletes (delattr) with no attribute-name filtering.
This belongs to the known "numpy is a large attack surface" class (the docs already note open() read and ndarray.tofile() write), but this specific arbitrary memory read/write chain is undocumented and bypasses the most recent ctypes-module hardening. All previously reported escapes (CVE-2025-24359 / GHSA-3wwr-3g9f-9gc7, GHSA-vp47-9734-prjw, reduce/reduce_ex, classic __subclasses__ traversal) are patched on the current code; this one is live.
PoC
Self contained POC here: https://gist.github.com/thegr1ffyn/16b67c5f9b5339a7e2bdc91423ff09e3
Environment: pip install asteval numpy (verified on asteval 1.0.8, numpy 2.4.6, CPython 3.12.3; the chain is numpy-1.x/2.x robust). Default Interpreter (use_numpy=True, import disabled).
Minimal one-expression arbitrary read (reads 8 bytes at an attacker-chosen address):
zeros(1,dtype=int32).ctypes.shape._type_.from_address(id(zeros(1))).value
Minimal arbitrary write (writes 0x4142434445464748 to a chosen address; here our own array buffer, observed back through numpy):
a = zeros(2, dtype=int32)
cell = a.ctypes.shape._type_.from_address(a.ctypes.data)
cell.value = 0x4142434445464748 # -> a[0]=0x45464748, a[1]=0x41424344
A full self-contained script is attached (poc_asteval_ctypes.py); running it prints the recovered PyObject header of a private object (arbitrary read) and confirms a raw write landing at a chosen pointer (arbitrary write), all from a default,…
- Record
GHSA-9w56-46f6-3qhx- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Weakness
- CWE-693, CWE-749, CWE-913
- Updated
- 2026-11-02
OSVUBUNTU-CVE-2026-102734
5.5
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.
- Record
UBUNTU-CVE-2026-102734- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
astevalPyPI |
before 1.0.9 | 1.0.9 |
python-astevalDebian:12 |
All versions, plus listed versions 0.9.28-10.9.30-10.9.31-11.0.6-11.0.6-2 |
None known |
python-astevalDebian:13 |
All versions, plus listed versions 1.0.6-2 |
None known |
python-astevalDebian:14 |
All versions, plus listed versions 1.0.6-2 |
None known |
astevalPyPI |
before 1.0.9, plus listed versions 0.90.9.10.9.100.9.110.9.12 Show 38 moreShow less0.9.130.9.140.9.150.9.160.9.170.9.180.9.190.9.20.9.200.9.210.9.220.9.230.9.240.9.250.9.260.9.270.9.280.9.290.9.30.9.300.9.310.9.320.9.330.9.40.9.50.9.60.9.70.9.80.9.91.0.01.0.11.0.21.0.31.0.41.0.51.0.61.0.71.0.8 |
1.0.9 |
python-astevalUbuntu:20.04:LTS |
All versions, plus listed versions 0.9.12-10.9.12-20.9.17-1 |
None known |
python-astevalUbuntu:22.04:LTS |
All versions, plus listed versions 0.9.19-20.9.25-2 |
None known |
python-astevalUbuntu:24.04:LTS |
All versions, plus listed versions 0.9.30-10.9.31-1 |
None known |
python-astevalUbuntu:26.10 |
All versions, plus listed versions 1.0.6-2 |
None known |
python-astevalUbuntu:26.04:LTS |
All versions, plus listed versions 1.0.6-2 |
None known |
History
| Recorded | Changed | Sources |
|---|---|---|
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2026-102734 is a medium vulnerability (CVSS 5.5) in Lmfit Asteval, published August 20, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.13%, the 2nd percentile. Fixed in asteval 1.0.9.
References
github.com/lmfit/asteval/security/advisories/GHSA-9w56-46f6-3qhx
github.com/lmfit/asteval/pull/153
github.com/lmfit/asteval/commit/a3e56e7f8ed567a4817684d94213b290359077b4
github.com/lmfit/asteval/releases/tag/1.0.9
github.com/advisories/GHSA-9w56-46f6-3qhx
github.com/CVEProject/cvelistV5/tree/main/cves/2026/102xxx/CVE-2026-102734.json
Left out here: the rest of 2 source descriptions. The JSON record has them.