Miggo Logo

CVE-2025-58756: MONAI: Unsafe torch usage may lead to arbitrary code execution

8.8

CVSS Score
3.1

Basic Information

EPSS Score
0.22584%
Published
9/9/2025
Updated
9/9/2025
KEV Status
No
Technology
TechnologyPython

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
monaipip<= 1.5.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stems from the insecure use of torch.load for model deserialization within the MONAI library. The root cause is the failure to consistently use the weights_only=True parameter, which was introduced to mitigate deserialization attacks. When this parameter is False or absent (in older torch versions), torch.load uses Python's pickle module, which can be exploited to execute arbitrary code if a maliciously crafted model file is loaded.

Two primary vulnerable functions were identified:

  1. CheckpointLoader.__call__: This is the most critical vulnerable function. It is located in monai/handlers/checkpoint_loader.py and explicitly sets weights_only=False in its call to torch.load. This makes it unconditionally vulnerable, regardless of the installed torch version. The provided proof-of-concept and stack trace directly point to this function as the entry point for the attack.

  2. _run_net_with_config: This function, found in monai/bundle/scripts.py, is conditionally vulnerable. It loads pretrained network weights and includes a check for the torch version. If the version is below 1.13, it calls torch.load without the weights_only parameter, creating a security risk. While a mitigating check is in place, environments with older torch installations remain exposed.

The analysis confirms that the vulnerability is not isolated to a single point but exists in different parts of the codebase with varying conditions for exploitation. The primary remediation would be to enforce the use of weights_only=True in all torch.load calls or to accept the risk and allow users to disable it explicitly only when loading trusted models.

Vulnerable functions

CheckpointLoader.__call__
monai/handlers/checkpoint_loader.py
The function explicitly calls `torch.load` with the `weights_only` parameter set to `False`. This makes it vulnerable to arbitrary code execution through the deserialization of a malicious model file, as the file is processed with Python's `pickle` module. The provided proof-of-concept directly exploits this function.
_run_net_with_config
monai/bundle/scripts.py
This function loads a model using `torch.load`. While it attempts to use the secure `weights_only=True` parameter for torch versions 1.13 and newer, it falls back to an insecure call without this parameter on older torch versions. This makes the function vulnerable to arbitrary code execution on systems with torch versions older than 1.13.

WAF Protection Rules

WAF Rule

### Summ*ry In ```mo**l_*i*t = tor**.lo**(*ull_p*t*, m*p_lo**tion=tor**.**vi**(**vi**), w*i**ts_only=Tru*)``` in mon*i/*un*l*/s*ripts.py , ```w*i**ts_only=Tru*``` is lo**** s**ur*ly. *ow*v*r, ins**ur* lo**in* m*t*o*s still *xist *ls*w**r* in t** proj

Reasoning

T** vuln*r**ility st*ms *rom t** ins**ur* us* o* `tor**.lo**` *or mo**l **s*ri*liz*tion wit*in t** MON*I li*r*ry. T** root **us* is t** **ilur* to *onsist*ntly us* t** `w*i**ts_only=Tru*` p*r*m*t*r, w*i** w*s intro*u*** to miti**t* **s*ri*liz*tion *t