CVE-2024-5187: Onnx Onnx Allows Arbitrary File Overwrite Vulnerability
HIGHCVE-2024-5187 is a HIGH (CVSS 8.8) onnx allows arbitrary file overwrite vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Onnx libraries in the PyPI ecosystem. The issue involves onnx allows arbitrary file overwrite in download_model_with_test_data. Remediation is available by upgrading affected packages to version 1.16.2.
CVE-2024-5187 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2024-5187
To remediate this vulnerability, upgrade all affected Onnx dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install onnx>=1.16.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show onnx
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2024-5187, inspect your installed packages using pip:
pip show onnx
Analyze the terminal output to locate any version of Onnx in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.16.2), your application is affected.
Note: The pip show onnx command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Onnx, 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
CVE-2024-5187 Affected Onnx Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
onnx
|
PyPI |
< 1.16.2
|
1.16.2
|
References
Frequently Asked Questions
What is CVE-2024-5187?
Which Onnx versions are affected?
What version fixes CVE-2024-5187?
Is onnx affected?
What is the CVSS score of CVE-2024-5187?
What CWE is associated with CVE-2024-5187?
How can I check PyPI dependencies for CVE-2024-5187?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-6rq9-53c3-f7vj",
"modified" : "2026-06-06T14:42:36Z",
"published" : "2024-06-06T21:30:37Z",
"aliases" : [ "CVE-2024-5187" ],
"summary" : "onnx allows Arbitrary File Overwrite in download_model_with_test_data",
"details" : "A vulnerability in the `download_model_with_test_data` function of the onnx/onnx framework, versions before 1.16.2, allow for arbitrary file overwrite due to inadequate prevention of path traversal attacks in malicious tar files. This vulnerability enables attackers to overwrite any file on the system, potentially leading to remote code execution, deletion of system, personal, or application files, thus impacting the integrity and availability of the system. The issue arises from the function's handling of tar file extraction without performing security checks on the paths within the tar file, as demonstrated by the ability to overwrite the `/home/kali/.ssh/authorized_keys` file by specifying an absolute path in the malicious tar file.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "onnx"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.16.2"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-5187"
}, {
"type" : "WEB",
"url" : "https://github.com/onnx/onnx/issues/6215"
}, {
"type" : "WEB",
"url" : "https://github.com/onnx/onnx/pull/6145"
}, {
"type" : "WEB",
"url" : "https://github.com/onnx/onnx/pull/6222"
}, {
"type" : "WEB",
"url" : "https://github.com/onnx/onnx/pull/6959"
}, {
"type" : "WEB",
"url" : "https://github.com/onnx/onnx/pull/7040"
}, {
"type" : "WEB",
"url" : "https://github.com/onnx/onnx/commit/1b70f9b673259360b6a2339c4bd97db9ea6e552f"
}, {
"type" : "WEB",
"url" : "https://github.com/onnx/onnx/commit/3fc3845edb048df559aa2a839e39e95503a0ee34"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-6rq9-53c3-f7vj"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/onnx/onnx"
}, {
"type" : "WEB",
"url" : "https://github.com/onnx/onnx/releases/tag/v1.16.2"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/onnx/PYSEC-2025-148.yaml"
}, {
"type" : "WEB",
"url" : "https://huntr.com/bounties/50235ebd-3410-4ada-b064-1a648e11237e"
}, {
"type" : "WEB",
"url" : "https://www.gecko.security/blog/cve-2025-51480"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-10-23T17:39:17Z",
"nvd_published_at" : "2024-06-06T19:16:06Z"
}
}