CVE-2023-45805: Pdm PDM Trojan Lockfile Vulnerability
HIGHCVE-2023-45805 is a HIGH (CVSS 7.8) pdm trojan lockfile vulnerability (CWE-20: Improper Input Validation) affecting Pdm libraries in the PyPI ecosystem. The issue involves pdm trojan lockfile. Remediation is available in the latest vendor maintenance releases.
CVE-2023-45805 at a Glance
Security Impact
CVSS: 7.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2023-45805
To remediate this vulnerability, upgrade all affected Pdm 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 pdm>=Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show pdm
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2023-45805, inspect your installed packages using pip:
pip show pdm
Analyze the terminal output to locate any version of Pdm in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.
Note: The pip show pdm command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Pdm, 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-2023-45805 Affected Pdm Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pdm
|
PyPI |
≤ 2.9.3
|
|
References
Frequently Asked Questions
What is CVE-2023-45805?
Which Pdm versions are affected?
What version fixes CVE-2023-45805?
Is pdm affected?
What is the CVSS score of CVE-2023-45805?
What CWE is associated with CVE-2023-45805?
How can I check PyPI dependencies for CVE-2023-45805?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-j44v-mmf2-xvm9",
"modified" : "2023-10-20T22:59:02Z",
"published" : "2023-10-20T19:30:23Z",
"aliases" : [ "CVE-2023-45805" ],
"summary" : "PDM Trojan Lockfile",
"details" : "### Summary\nIt's possible to craft a malicious `pdm.lock` file that could allow e.g. an insider or a malicious open source project to appear to depend on a trusted PyPI project, but actually install another project.\n\n### Details\nProject `foo` can be targeted by creating the project `foo-2` and uploading the file `foo-2-2.tar.gz` to pypi.org. PyPI will see this as project `foo-2` version `2`, while PDM will see this as project `foo` version `2-2`. The version must only be [parseable as a version](https://github.com/frostming/unearth/blob/eca170d9370ac5032f2e497ee9b1b63823d3fe0f/src/unearth/evaluator.py#L215-L229) (and the filename must be a prefix of the project name), but it's [not verified to match the version being installed](https://github.com/pdm-project/pdm/blob/45d1dfa47d4900c14a31b9bb761e4c46eb5c9442/src/pdm/models/candidates.py#L98-L99). (Version `2-2` is also not a valid [normalized version per PEP 440](https://peps.python.org/pep-0440/#post-release-spelling).)\n\nMatching the project name exactly (not just prefix) would fix the issue. The version should also be verified to avoid version downgrade attacks.\n\n### PoC\nExample `pdm.lock` snippet to appear to depend on `foo` but actually install `foo-2`\n```\n\"foo 2.2.0\" = [\n url = \"https://files.pythonhosted.org/.../foo-2-2.tar.gz\n]\n```\n\n### Impact\nWhen installing dependencies with PDM, what's actually installed could differ from what's listed in `pyproject.toml` (including arbitrary code execution on install). It could also be used for downgrade attacks by only changing the version.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pdm"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "2.9.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/pdm-project/pdm/security/advisories/GHSA-j44v-mmf2-xvm9"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-45805"
}, {
"type" : "WEB",
"url" : "https://github.com/pdm-project/pdm/commit/6853e2642dfa281d4a9958fbc6c95b7e32d84831"
}, {
"type" : "WEB",
"url" : "https://github.com/frostming/unearth/blob/eca170d9370ac5032f2e497ee9b1b63823d3fe0f/src/unearth/evaluator.py#L215-L229"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/pdm-project/pdm"
}, {
"type" : "WEB",
"url" : "https://github.com/pdm-project/pdm/blob/45d1dfa47d4900c14a31b9bb761e4c46eb5c9442/src/pdm/models/candidates.py#L98-L99"
}, {
"type" : "WEB",
"url" : "https://peps.python.org/pep-0440/#post-release-spelling"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-20" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2023-10-20T19:30:23Z",
"nvd_published_at" : "2023-10-20T19:15:08Z"
}
}