/

CVE-2026-44717

Severity:

CRITICAL RISK

(9.8)

Code Injection in MCP Calculate Server

CVE-2026-44717

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

MCP Calculate Server uses Python's eval() to process mathematical expressions without adequate input validation, enabling attackers to inject arbitrary Python code.

If exposed over the MCP protocol or any network boundary, this flaw can allow remote code execution in the server context when untrusted users can submit expressions.

Affected context

This vulnerability appears in MCP Calculate Server deployments that:

  • Accept mathematical expressions from clients over the MCP protocol or similar interfaces
  • Evaluate these expressions directly using Python's eval()
  • Do not strictly constrain or sanitize which tokens and operations are allowed
  • Run the service under a Python interpreter with access to system resources (files, network, environment)

The risk is most significant when any untrusted or semi-trusted party can send calculation requests to the server.

Exploit preconditions

  • Attack surface: Network-accessible MCP Calculate Server endpoints or other integrations that forward user-supplied expressions to the service
  • Required access: Ability to submit crafted mathematical expressions (e.g., via API, MCP client, or upstream application)
  • Trigger point: Server-side evaluation of the supplied expression using eval() at request handling time
  • Why exploitation is possible: eval() executes arbitrary Python expressions in the current interpreter context, and without strict input constraints or sandboxing, attackers can escape simple math and execute arbitrary code

Why this happens

The root cause is the direct use of Python's eval() on user-controlled input without enforcing a strict, whitelisted expression language.

This pattern aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), where data from an untrusted source is treated as executable code.

Instead of using a constrained math parser or SymPy's safe evaluation mechanisms, the implementation relies on eval(), which interprets the input as Python code, allowing attackers to leverage language features, built-ins, or imports to run arbitrary commands.

Potential impact

  • Remote execution of arbitrary Python code within the MCP Calculate Server process
  • Access to sensitive data available to the server (configuration, environment variables, secrets)
  • File system manipulation, including reading, writing, or deleting files under the server's privileges
  • Lateral movement to other systems via network access from the compromised process
  • Service disruption or denial of service by executing resource-intensive or destructive code

General mitigation guidance

Mitigation typically focuses on eliminating direct code evaluation and constraining the expression language:

  • Replace eval() with a dedicated mathematical expression parser or SymPy's safe evaluation utilities that operate on pre-parsed expressions
  • Define a strict grammar or whitelist of allowed operators, functions, and symbols, rejecting anything outside that set
  • Execute expression evaluation in a constrained environment (e.g., restricted globals/locals), minimizing accessible objects and APIs
  • Run the service under least-privilege OS accounts and with minimized file system and network permissions to limit blast radius
  • Introduce defense-in-depth validation at all input boundaries, ensuring that only expected expression forms are forwarded to the calculator component

How teams detect issues like this

Detection efforts can focus on both code and runtime behavior:

  • Static analysis: Configure rules to flag any use of eval(), exec(), or similar dynamic execution primitives, especially when applied to request or user-supplied data
  • Code review: Treat dynamic code evaluation as a red flag; reviewers should look for direct evaluation of inputs, weak "sanitization" patterns, or partial blacklists of keywords
  • Policy enforcement: Establish coding guidelines that prohibit eval() in production code, backed by automated linters or pre-commit hooks
  • Runtime monitoring: Monitor the service for unusual process behavior, such as unexpected file access, command execution, or network connections initiated from the calculator process

Sources

SourceLink
github.comgithub.com/611711Dark/mcp_calculate_server/security/advisories/GHSA-2mgq-7rfg-rwpj

Frequently asked

questions

Yes, when MCP Calculate Server is reachable over a network and accepts expressions from untrusted or partially trusted clients, an attacker can exploit this issue remotely by sending crafted expressions.

The attacker needs the ability to submit expressions that the server evaluates—this could be via a direct MCP connection, an API endpoint, or any upstream application that forwards user input to the calculator.

Remove direct usage of eval() on untrusted input and adopt a constrained evaluation pathway: use a dedicated math parser or safe SymPy routines, operate on expression trees instead of raw strings, and restrict the evaluation environment to only the necessary mathematical operations.

Establish a rule that dynamic execution primitives (eval, exec, system-level shells) are never used on user-controlled data, enforce this via static checks and code review, and design input-handling components around strict whitelisting and clearly defined mini-languages rather than interpreting raw strings as code.

Find out what's already
exploitable in your codebase.