/

CVE-2026-55546

Severity:

CRITICAL RISK

(9.8)

Code Injection (CWE-94) in QWED-MCP Math Verification

CVE-2026-55546

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

QWED-MCP versions before 0.2.1 allow attacker-controlled mathematical expressions and claimed results to reach SymPy's parse_expr() without sufficient restrictions. When a downstream integration passes untrusted input to this public function, an attacker may execute operating-system commands with the privileges of the qwed-mcp process.

Affected context

The vulnerability occurs in integrations that invoke QWED-MCP's verify_math_expression() function with attacker-controlled strings. The default MCP tool registry does not expose this function, so the issue generally requires a downstream application, service, or wrapper to connect external input to the library API without enforcing a trusted expression grammar.

Exploit preconditions

  • Attack surface: Any downstream integration exposing verify_math_expression() through an externally reachable interface
  • Required access: Ability to influence the expression or claimed-result arguments supplied to the function
  • Trigger point: Expression parsing by SymPy's parse_expr() during verification
  • Why exploitation is possible: The parser evaluates attacker-controlled content with Python evaluation capabilities, while built-ins, globals, and the expression structure are not sufficiently restricted

Why this happens

The underlying bug is code injection through unsafe evaluation of untrusted mathematical expressions. The function normalizes syntax but does not establish a constrained parsing environment, remove Python built-ins, or validate the resulting expression against an approved abstract syntax tree before evaluation. Because parse_expr() can invoke Python evaluation with accessible execution features, input intended as data may be interpreted as executable logic, mapping to CWE-94: Improper Control of Generation of Code ('Code Injection').

Potential impact

  • An attacker may execute arbitrary operating-system commands
  • The qwed-mcp process and its accessible resources could be compromised
  • Accessible files and application data could be read, modified, or deleted
  • Process secrets, credentials, or tokens could be exfiltrated
  • The compromised process could access internal services or enable lateral movement

General mitigation guidance

Mitigation generally focuses on eliminating evaluation of attacker-controlled language constructs and reducing the trust placed in expression inputs.

Common defensive patterns include:

  • Replacing general-purpose expression evaluation with a dedicated mathematical grammar or safe, non-evaluating parser
  • Allowlisting operators, literals, functions, and symbol names before any computation
  • Parsing into an approved AST and rejecting imports, attributes, calls, assignments, comprehensions, and other executable constructs
  • Supplying tightly restricted parser globals and removing access to Python built-ins where evaluation cannot be avoided
  • Validating both expression and claimed-result inputs at the integration boundary
  • Exposing only narrowly scoped verification operations and running the process with least privilege
  • Limiting filesystem, network, secret, and subprocess access available to the service

How teams detect issues like this

Detection approaches may include:

  • Static analysis rules for eval(), SymPy parse_expr(), and other dynamic evaluation APIs receiving request-derived values
  • Code review checks for parser calls that do not define restricted namespaces or validate an AST
  • Data-flow analysis tracing HTTP, RPC, MCP, or user-provided input into mathematical expression evaluators
  • Tests containing disallowed Python constructs to confirm that the integration accepts only the intended mathematical grammar
  • Policy enforcement that requires allowlisted parsers and prohibits dynamic code evaluation in request-processing paths
  • Neutral automated code-review or SAST tools that flag unsafe evaluation patterns

Sources

SourceLink
github.comgithub.com/QWED-AI/qwed-mcp/commit/362e61892052e250c56cb1ee852024d6f98c467b
github.comgithub.com/QWED-AI/qwed-mcp/pull/22
github.comgithub.com/QWED-AI/qwed-mcp/releases/tag/v0.2.1
github.comgithub.com/QWED-AI/qwed-mcp/security/advisories/GHSA-mw6r-2hvm-4rp2

Frequently asked

questions

It can be remotely exploitable when a downstream service accepts attacker-controlled input and passes it to verify_math_expression(). The default MCP tool registry does not expose the vulnerable function, so exposure depends on the integrating application.

An attacker needs a way to influence the expression or claimed-result strings supplied to the public library function. Direct access to the host is not necessarily required if an exposed integration forwards external input.

Use a dedicated safe mathematical parser with an allowlisted grammar, or validate a restricted AST before computation. General-purpose Python evaluation should not process untrusted expressions.

Treat expression strings as untrusted data, enforce validation at integration boundaries, prohibit dynamic evaluation in request paths, and run verification services with least-privilege access to files, secrets, and networks.

Find out what's already
exploitable in your codebase.