VAITP Dataset

← Back to the dataset

CVE-2026-55585

RCE via attacker-controlled math expressions passed to SymPy parse_expr.

  • CVSS 8.8
  • CWE-94
  • Input Validation and Sanitization
  • Remote

QWED is open-source AI verification infrastructure for deterministic verification of LLM outputs, tool calls, code, schemas, and agent state before production execution. Prior to 5.1.2, the qwed package passes caller-controlled math expressions directly to SymPy parse_expr() without restricted global_dict and local_dict namespaces, allowing Python eval() to resolve builtins and execute arbitrary Python code in the API server process. In src/qwed_new/api/main.py, POST /verify/math is protected by get_current_tenant but accepts any valid tenant API key, reads the expression field, applies only a cosmetic re.sub(r'(\d)(()', r'\1*\2', expression) normalization, and passes the result to parse_expr(). In src/qwed_new/core/batch.py, POST /verify/batch sends math items through batch_service.create_job(), stores item.query verbatim, and _verify_item() passes VerificationType.MATH input to parse_expr() without sanitization. The default-enabled POST /auth/signup endpoint allows anyone to create a standard tenant account, POST /auth/api-keys issues an x-api-key, and either vulnerable path can then be used to read or write files, modify data, execute operating system commands, terminate the service, and compromise other tenants in a shared deployment. This issue is fixed in version 5.1.2.

CVSS base score
8.8
Published
2026-08-25
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
qwed
Fixed by upgrading
Yes

Solution

Upgrade QWED to version 5.1.2 (or later), which patches the unsafe SymPy parse_expr usage.

Vulnerable code sample

import re
from sympy.parsing.sympy_parser import parse_expr
from fastapi import APIRouter, Depends, HTTPException

router = APIRouter()

def get_current_tenant(api_key: str = Depends(...)):
    # placeholder tenant lookup
    if not api_key:
        raise HTTPException(status_code=401)
    return {"tenant_id": "demo"}

@router.post("/verify/math")
def verify_math(payload: dict, tenant: dict = Depends(get_current_tenant)):
    expression = payload.get("expression", "")
    # Cosmetic normalization only
    expression = re.sub(r'(\d)(\()', r'\1*\2', expression)
    # VULNERABLE: passing unchecked expression to parse_expr allows arbitrary code execution
    expr = parse_expr(expression)
    return {"result": str(expr)}

Patched code sample

import re
from sympy.parsing.sympy_parser import parse_expr
from fastapi import APIRouter, Depends, HTTPException

router = APIRouter()

def get_current_tenant(api_key: str = Depends(...)):
    if not api_key:
        raise HTTPException(status_code=401)
    return {"tenant_id": "demo"}

@router.post("/verify/math")
def verify_math(payload: dict, tenant: dict = Depends(get_current_tenant)):
    expression = payload.get("expression", "")
    expression = re.sub(r'(\d)(\()', r'\1*\2', expression)
    # FIX: restrict globals/locals to prevent eval of builtins
    expr = parse_expr(expression, global_dict={}, local_dict={})
    return {"result": str(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.

  • fix: restrict sympy parse_expr to prevent code execution (CWE-95) (QWED-AI/qwed-verification)
    src/qwed_new/api/main.py · verify_math, src/qwed_new/core/batch.py · BatchVerificationService._verify_item, src/qwed_new/core/validator.py, src/qwed_new/core/validator.py · SemanticValidator.validate, src/qwed_new/core/verifier.py, src/qwed_new/core/verifier.py · VerificationEngine.verify_derivative, src/qwed_new/core/verifier.py · VerificationEngine.verify_identity, src/qwed_new/core/verifier.py · VerificationEngine.verify_integral, src/qwed_new/core/verifier.py · VerificationEngine.verify_limit, src/qwed_new/core/verifier.py · VerificationEngine.verify_math

Cite this entry

@misc{vaitp:cve202655585,
  title        = {{RCE via attacker-controlled math expressions passed to SymPy parse_expr.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-55585},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-55585/}}
}

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.