Description
MONAI through 1.6.0 contains an eval injection vulnerability in _get_fake_spatial_shape() in monai/bundle/scripts.py. The function validates shape expressions with a helper that walks the AST and only collects ast.Name nodes, rejecting any name other than 'p' or 'n', before passing the string to eval(). Expressions built solely from constants and attribute, subscript, or call nodes (for example "(1).__class__.__bases__[0].__subclasses__()" or "int.__class__.__init__.__globals__") contain no ast.Name nodes and therefore bypass the allowlist. Because the shape value originates from bundle metadata consumed by _get_real_input_data and verify_net_in_out (reachable through the bundle 'verify_net_in_out' CLI flow), an attacker who can influence a bundle's metadata can escape the eval sandbox via object introspection chains and achieve code execution in this non-default flow.
Published: 2026-09-27
Score: 7.3 High
EPSS: n/a
KEV: No
Impact: Code Execution
Action: Patch Immediately
AI Analysis

Impact

The vulnerability arises in MONAI’s _get_fake_spatial_shape function, where user‑supplied shape expressions are improperly validated before being passed to eval(). The validator accepts only ast.Name nodes that equal 'p' or 'n', rejecting other identifiers, but it ignores expressions that do not contain any ast.Name nodes. By constructing expressions that rely solely on constants and chained attribute, subscript, or call nodes—such as (1).__class__.__bases__[0].__subclasses__() or int.__class__.__init__.__globals__—an attacker can bypass the whitelist and execute arbitrary Python code after eval() runs. The injected code runs with the privileges of the process that loads the bundle, allowing full code‑execution control in an otherwise restricted environment.

Affected Systems

The flaw affects Project‑MONAI’s MONAI library versions up to and including 1.6.0. These releases are identified by the vendor product MONAI and are referenced by the CPE cpe:2.3:a:project-monai:monai:*:*:*:*:*:*:*.*. Users who employ these versions and process bundles that include user‑controlled metadata through the verify_net_in_out command line flow are vulnerable. No other sub‑components or third‑party packages are reported to be affected.

Risk and Exploitability

The CVSS score of 7.3 indicates a medium‑to‑high severity. EPSS is not available and the vulnerability is not listed in CISA’s KEV catalog, suggesting no widespread, publicly known exploitation at the time of the advisory. Exploitation requires the attacker to supply or modify bundle metadata consumed by the non‑default verify_net_in_out flow, which is typically a local or privileged action. Therefore, the risk is significant for deployments that allow untrusted bundle metadata or that run the CLI flow without strict input validation.

Generated by OpenCVE AI on September 27, 2026 at 03:50 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade MONAI to the latest available release that addresses the _get_fake_spatial_shape eval bug.
  • If an upgrade is not immediately possible, restrict or validate the metadata fed into _get_fake_spatial_shape by removing untrusted fields or by sanitizing expressions to reject attribute, subscript, or call nodes.
  • Avoid invoking the verify_net_in_out CLI flow with bundles that include user‑supplied metadata until the vulnerability is mitigated, and monitor system logs for anomalous code execution patterns.

Generated by OpenCVE AI on September 27, 2026 at 03:50 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Sun, 27 Sep 2026 02:00:00 +0000

Type Values Removed Values Added
Description MONAI through 1.6.0 contains an eval injection vulnerability in _get_fake_spatial_shape() in monai/bundle/scripts.py. The function validates shape expressions with a helper that walks the AST and only collects ast.Name nodes, rejecting any name other than 'p' or 'n', before passing the string to eval(). Expressions built solely from constants and attribute, subscript, or call nodes (for example "(1).__class__.__bases__[0].__subclasses__()" or "int.__class__.__init__.__globals__") contain no ast.Name nodes and therefore bypass the allowlist. Because the shape value originates from bundle metadata consumed by _get_real_input_data and verify_net_in_out (reachable through the bundle 'verify_net_in_out' CLI flow), an attacker who can influence a bundle's metadata can escape the eval sandbox via object introspection chains and achieve code execution in this non-default flow.
Title MONAI through 1.6.0 _get_fake_spatial_shape eval() Sandbox Bypass via Attribute Chains
First Time appeared Project-monai
Project-monai monai
Weaknesses CWE-95
CPEs cpe:2.3:a:project-monai:monai:*:*:*:*:*:*:*:*
Vendors & Products Project-monai
Project-monai monai
References
Metrics cvssV3_1

{'score': 7, 'vector': 'CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H'}

cvssV4_0

{'score': 7.3, 'vector': 'CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N'}


Subscriptions

Project-monai Monai
cve-icon MITRE

Status: PUBLISHED

Assigner: VulnCheck

Published:

Updated: 2026-09-27T01:28:38.149Z

Reserved: 2026-09-26T23:23:03.411Z

Link: CVE-2026-100842

cve-icon Vulnrichment

No data.

cve-icon NVD

Status : Received

Published: 2026-09-27T02:17:22.693

Modified: 2026-09-27T02:17:22.693

Link: CVE-2026-100842

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-09-27T04:30:18Z

Weaknesses
  • CWE-95

    Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection')