/

CVE-2026-32640

Severity:

CRITICAL RISK

(9.8)

Code Injection / Sandbox Escape in SimpleEval

CVE-2026-32640

Modified

Vulnerability type

Category:

Code Injection / Sandbox Escape

CWE:

CWE-94, CWE-915

Impact:

Arbitrary Code Execution within the Host Python Process

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

SimpleEval's expression evaluation sandbox can inadvertently expose dangerous Python objects and modules via attributes of user-provided objects and callbacks.

Under certain conditions, an attacker who can supply expressions or influence the objects passed into SimpleEval may escape the intended sandbox and execute arbitrary code.

Affected context

This vulnerability affects Python applications that embed SimpleEval as a "safe" or sandboxed expression engine, particularly when:

  • User-controlled or semi-trusted expressions are evaluated.
  • Application objects are passed into SimpleEval as names or accessible values.
  • Callbacks or callable objects that can reach powerful APIs (e.g., OS, filesystem, networking, or import mechanisms) are exposed to evaluated expressions.

The risk increases when developers rely on SimpleEval as a primary security boundary for untrusted input rather than as a convenience expression engine.

Exploit preconditions

  • Attack surface: Expression strings processed by SimpleEval (e.g., configuration expressions, filters, rules, or user-supplied formulas).
  • Required access: Ability to influence or control the evaluated expression, and/or the objects and callbacks provided to the evaluator (directly or indirectly).
  • Trigger point: Execution of a crafted expression through SimpleEval that navigates object attributes or uses callbacks to reach dangerous modules or functions.
  • Why exploitation is possible: The sandbox design does not fully constrain attribute access on provided objects, nor does it reliably prevent callbacks from being used as conduits to powerful APIs. This allows traversal from "safe" entry points to unsafe objects inside the sandboxed environment.

Why this happens

The core issue stems from treating SimpleEval as a secure sandbox while allowing rich Python objects and callbacks to be passed in as evaluation context.

Internally, the evaluator permits attribute access on these objects and does not robustly enforce a strict allowlist of safe types and attributes.

This aligns with CWE-94: Improper Control of Generation of Code, because user-controllable expressions can drive execution paths that reach arbitrary, powerful functions.

It is also related to CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes, as user expressions can influence which attributes are accessed, inadvertently exposing dangerous modules or methods.

Potential impact

  • Arbitrary Python code execution within the affected application process.
  • Reading, modifying, or deleting local files accessible to the application.
  • Network access using the application's privileges (e.g., data exfiltration or pivoting to internal services).
  • Access to sensitive runtime data such as API keys, tokens, or secrets held in memory or environment variables.
  • Full compromise of application integrity, including tampering with business logic or stored data.

General mitigation guidance

Effective mitigation focuses on treating expression evaluation as inherently risky and minimizing trust in user-provided expressions:

  • Avoid using SimpleEval (or similar libraries) as a hard security boundary for untrusted users; place it behind additional access controls where possible.
  • Pass only primitive, inert data structures (e.g., numbers, booleans, short strings) into the evaluator; avoid passing full objects, modules, or rich callables.
  • Design the evaluation context around a strict allowlist: explicitly expose only the minimal set of safe functions and values needed by expressions.
  • Prevent exposure of callbacks that can indirectly reach dangerous APIs, import mechanisms, or arbitrary attribute access.
  • Apply the principle of least privilege at the process and container level (file-system access, network permissions, credentials) to limit impact if the sandbox is bypassed.
  • Consider alternative designs that avoid dynamic evaluation for user-controlled input, such as declarative configuration or tightly constrained domain-specific languages.

How teams detect issues like this

Organizations can look for potential misuse of expression engines through a combination of static and review-based techniques:

  • Static analysis and code search:
  • Identify use of SimpleEval and similar evaluators across the codebase.
  • Flag call sites where untrusted or user-influenced data flows into expression parameters.
  • Detect patterns where complex objects, modules, or functions are passed as names, functions, or callbacks into the evaluator.
  • Code review signals:
  • Any comments or documentation that describe SimpleEval as "secure", "sandboxed", or "safe for user input".
  • Evaluation contexts that expose global application objects, database handles, HTTP clients, or direct OS interfaces.
  • Expressions used in multi-tenant, plug-in, or user-rule scenarios without additional isolation.
  • Policy and automated checks:
  • CI policies that require justification when dynamic evaluation is introduced.
  • Security linting rules to enforce a strict allowlist of safe helpers for SimpleEval or similar tools.
  • Optional use of automated code scanning tools can help identify high-risk code evaluation patterns and data flows from user input into expression evaluators.

Sources

SourceLink
github.comgithub.com/danthedeckie/simpleeval/security/advisories/GHSA-44vg-5wv2-h2hg
lists.debian.orglists.debian.org/debian-lts-announce/2026/04/msg00023.html
access.redhat.comaccess.redhat.com/errata/RHSA-2026:10184
access.redhat.comaccess.redhat.com/errata/RHSA-2026:37275
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-32640
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2447529
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-32640.json

Frequently asked

questions

Yes, in many designs. If a remote user can supply or significantly influence expressions evaluated by SimpleEval, and the application passes objects or callbacks into the evaluator, the issue can often be exploited over the network.

The attacker generally needs the ability to control or influence the evaluated expression, or the objects/callbacks exposed to the expression. This commonly arises in features like user-defined formulas, rules, or scripts, especially in multi-tenant or SaaS applications.

Treat SimpleEval as a convenience tool, not a security sandbox. Restrict the evaluation context to simple, immutable data and a tightly controlled set of pure, side-effect-free helper functions. Remove or wrap any callbacks that can reach dangerous modules, perform I/O, or access arbitrary attributes.

Avoid dynamic evaluation of user-controlled expressions where possible. If expression support is required, design a minimal, domain-specific language with a strict grammar and limited operations, enforce strict allowlists for accessible functions and data, and combine this with process-level isolation and least-privilege execution so that a sandbox escape does not lead to full system compromise.

Find out what's already
exploitable in your codebase.