CVE-2026-141547: PDM: A project pdm.toml can still set cache_dir, which brings back project-controlled plugin code at pdm startup
PDM is a Python package and dependency manager. From 2.27.0 until 2.29.8, a repository-controlled pdm.toml can override the globalonly setting cachedir because src/pdm/project/config.py enforces the restriction on writes but not when project configuration is read. In src/pdm/project/core.py, Project.config gives the project value precedence and projectpluginsdir is computed beneath the resulting cache directory. During Core.init in src/pdm/core.py, loadplugins calls site.addsitedir on that directory's site-packages, processing executable .pth import lines before argument parsing. A malicious checkout can therefore execute Python code as the invoking user when PDM runs, including for pdm --version, if the prepared plugin directory matches the checkout path and Python version and PDMCACHEDIR is not set. This bypasses the earlier relocation of project plugins out of the checkout for CVE-2026-47781. This issue is fixed in version 2.29.8.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 2.29.8
Event History
Frequently Asked Questions
Who is exposed to exploitation?
Users running affected PDM versions from 2.27.0 through 2.29.7 in or against a malicious repository checkout are exposed. The code runs as the user invoking PDM, and even commands such as "pdm --version" can trigger it.
What conditions must an attacker satisfy?
The attacker needs to control a checkout containing a pdm.toml and prepare a plugin directory at the path derived from the overridden cache_dir and the relevant Python version. PDM_CACHE_DIR must not be set, and the prepared directory must contain site-packages content that causes executable .pth import lines to be processed.
Are default settings affected?
Yes. The described attack applies when PDM_CACHE_DIR is not set, because the repository-controlled cache_dir can then take precedence and influence the project plugin path.
What can be done before upgrading?
Set PDM_CACHE_DIR so the repository's cache_dir setting does not determine the plugin location, and avoid running PDM in untrusted checkouts. Upgrade to version 2.29.8 when possible.