CVE-2025-58756: MONAI: Unsafe torch usage may lead to arbitrary code execution
8.8
Basic Information
Technical Details
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
monai | pip | <= 1.5.0 |
Vulnerability Intelligence
Miggo AI
Root 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:
-
CheckpointLoader.__call__
: This is the most critical vulnerable function. It is located inmonai/handlers/checkpoint_loader.py
and explicitly setsweights_only=False
in its call totorch.load
. This makes it unconditionally vulnerable, regardless of the installedtorch
version. The provided proof-of-concept and stack trace directly point to this function as the entry point for the attack. -
_run_net_with_config
: This function, found inmonai/bundle/scripts.py
, is conditionally vulnerable. It loads pretrained network weights and includes a check for thetorch
version. If the version is below 1.13, it callstorch.load
without theweights_only
parameter, creating a security risk. While a mitigating check is in place, environments with oldertorch
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
_run_net_with_config
monai/bundle/scripts.py