CVE-2026-31225
Unsafe eval() in the query parser allows remote code execution via user input.
- CVSS 8.8
- CWE-94
- Input Validation and Sanitization
- Remote
The superduper project thru v0.10.0 contains a critical remote code execution vulnerability in its query parsing component. The _parse_op_part() function in query.py uses the unsafe eval() function to dynamically evaluate user-supplied query operands without proper sanitization or restriction. Although the function attempts to limit the execution context by providing a restricted global namespace, it does not block access to dangerous built-in functions. A remote attacker can exploit this by submitting a specially crafted query string containing Python code that imports modules (e.g., os) and executes arbitrary system commands, leading to complete compromise of the server.
- CWE
- CWE-94
- CVSS base score
- 8.8
- Published
- 2026-05-12
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Algorithm
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- superduper
- Fixed by upgrading
- Yes
Solution
Upgrade to version 0.10.1 or later.
Vulnerable code sample
def _parse_op_part(operand_string: str):
"""
Parses and evaluates a query operand string.
"""
# This function attempts to limit the execution context by providing
# a restricted global namespace for the eval() call.
restricted_globals = {
# In a real application, some "safe" utility functions might be listed here.
}
# The vulnerability lies here. The `eval` function is called on raw user
# input. Although `restricted_globals` is provided, it does not block or
# sanitize access to the default `__builtins__`, which allows an attacker
# to call dangerous functions like `__import__`.
return eval(operand_string, restricted_globals)Patched code sample
import ast
def _parse_op_part(operand_string: str):
"""
Safely evaluates a query operand string.
The vulnerability described in CVE-2026-31225 is fixed by replacing the
unsafe use of eval() with ast.literal_eval(). This function only parses
and evaluates Python literals (e.g., strings, numbers, lists, dictionaries,
booleans, None) and raises an exception for any other type of code,
including function calls, attribute access, or module imports.
This prevents arbitrary code execution.
"""
try:
# The fix: Use ast.literal_eval to safely parse only static literals.
# This will fail on code like "__import__('os').system('ls')".
return ast.literal_eval(operand_string)
except (ValueError, SyntaxError, MemoryError, TypeError):
# If the input is not a valid literal (e.g., a field name, an
# unquoted string, or malicious code), it is treated as a raw
# string. This is a safe fallback that prevents execution.
return operand_stringPayload
__import__('os').system('cat /etc/passwd')
Cite this entry
@misc{vaitp:cve202631225,
title = {{Unsafe eval() in the query parser allows remote code execution via user input.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-31225},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-31225/}}
}
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 ::
