{"id":"CVE-2026-141547","aliases":["EUVD-2026-141814","GHSA-fv38-chg5-6pg2"],"status":"published","title":"PDM: A project pdm.toml can still set cache_dir, which brings back project-controlled plugin code at pdm startup","description":"PDM is a Python package and dependency manager. From 2.27.0 until 2.29.8, a repository-controlled pdm.toml can override the global_only setting cache_dir 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 project_plugins_dir is computed beneath the resulting cache directory. During Core.__init__ in src/pdm/core.py, load_plugins 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 PDM_CACHE_DIR 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.","severity":{"version":"3.1","score":7,"vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high","assessor":"cna","from":"cve"},"epss":{"day":"2026-12-04","score":0.0047,"percentile":0.42343,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true,"poc_reported":true},"cwes":["CWE-15","CWE-94"],"published":"2026-12-02T18:58:22Z","modified":"2026-12-04T21:49:19Z","fixes":[{"ecosystem":"PyPI","package":"pdm","fixed_in":["2.29.8"],"sources":["ghsa"]}],"affected":[{"source":"ghsa","ecosystem":"PyPI","package":"pdm","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.27.0"},{"fixed":"2.29.8"}]}]}],"products":[{"vendor":"pdm-project","product":"pdm"}],"references":[{"url":"https://github.com/pdm-project/pdm/security/advisories/GHSA-fv38-chg5-6pg2","tags":["x_refsource_CONFIRM","exploit","advisory"]},{"url":"https://github.com/pdm-project/pdm/commit/8cfea30571b0694dacbc7c5e4459527f83a4c4cc","tags":["x_refsource_MISC","fix"]},{"url":"https://github.com/pdm-project/pdm/releases/tag/2.29.8","tags":["x_refsource_MISC","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-141547","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-fv38-chg5-6pg2"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/141xxx/CVE-2026-141547.json","tags":["advisory"]}],"sources":{"cve":[{"id":"CVE-2026-141547","title":"PDM: A project pdm.toml can still set cache_dir, which brings back project-controlled plugin code at pdm startup","description":"PDM is a Python package and dependency manager. From 2.27.0 until 2.29.8, a repository-controlled pdm.toml can override the global_only setting cache_dir 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 project_plugins_dir is computed beneath the resulting cache directory. During Core.__init__ in src/pdm/core.py, load_plugins 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 PDM_CACHE_DIR 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.","status":"published","published":"2026-12-02T18:58:22.343Z","modified":"2026-12-02T23:06:59.19Z","cvss":[{"version":"3.1","score":7,"vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high","assessor":"cna"}],"cwes":["CWE-15","CWE-94"],"ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"total","date":"2026-12-02"},"updated_at":"2026-12-02T23:23:06.228509Z"}],"euvd":[{"id":"EUVD-2026-141814","description":"PDM is a Python package and dependency manager. From 2.27.0 until 2.29.8, a repository-controlled pdm.toml can override the global_only setting cache_dir 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 project_plugins_dir is computed beneath the resulting cache directory. During Core.__init__ in src/pdm/core.py, load_plugins 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 PDM_CACHE_DIR 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.","status":"published","published":"2026-12-02T18:58:22Z","modified":"2026-12-02T23:06:59Z","cvss":[{"version":"3.1","score":7,"vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high"}],"updated_at":"2026-12-02T20:26:56.555732Z"}],"ghsa":[{"id":"GHSA-fv38-chg5-6pg2","title":"PDM: A project pdm.toml can still set cache_dir, which brings back project-controlled plugin code at pdm startup","description":"## Summary\n\nGHSA-qq6c-99pv-prvf was fixed by moving the per-project plugin library out of the project, to `\u003ccache_dir\u003e/plugins/\u003cproject name\u003e-\u003chash\u003e`. `cache_dir` is declared global-only, but that is checked only when a value is written. A `pdm.toml` committed to a repository (the docs recommend committing it) can still set `cache_dir`, and the plugin library path is then computed under a directory the repository controls. A repository can ship that directory with a `.pth` file, and pdm runs it at startup, before parsing arguments. In my test `pdm --version` was enough.\n\nThe plugin directory name contains a hash of the absolute project path, so the repository has to guess where it will be checked out. In CI and container builds the path is usually fixed (`/app`, `/home/runner/work/\u003crepo\u003e/\u003crepo\u003e`, `/workspaces/\u003crepo\u003e`), and a repository can include directories for several guesses.\n\n## Details\n\nLine numbers are for 2.29.7 (main 4d5c6216 has the same three files).\n\n- `src/pdm/project/config.py:111-115` declares `cache_dir` with `global_only=True`. The check is in `__setitem__` (`:422`); `__getitem__` (`:369-393`) returns the project file's value, and `Config.__init__` loads the project file without filtering (`:316`).\n- `src/pdm/project/core.py:252-256`: `Project.config` is `ChainMap(project_config, global_config)`, so the project value wins.\n- `src/pdm/project/core.py:121-128`: `cache_dir` is read from that config, and `project_plugins_dir` is `cache_dir / \"plugins\" / f\"{root.name}-{sha224(normcase(str(root)))[:12]}\"`.\n- `src/pdm/core.py:86` and `:329-350`: `Core.__init__` calls `load_plugins()`, which runs `site.addsitedir()` on that directory's `site-packages` if it exists, so `.pth` import lines execute.\n\nThis is the same impact as GHSA-qq6c (fixed in 16bab5cd, 2.27.0) through a different path: the config precedence ignores `global_only`.\n\n## PoC\n\nA project at `/tmp/app` with a minimal `pyproject.toml`, a `pdm.toml` containing `cache_dir = \".pdmcache\"`, and `.pdmcache/plugins/app-\u003csha224(\"/tmp/app\")[:12]\u003e/lib/python3.12/site-packages/zz_demo.pth`, whose one `import` line writes a marker file. Then `cd /tmp/app \u0026\u0026 pdm --version`. Docker, no network, pdm 2.29.7 from PyPI (the latest release), Python 3.12:\n\n```\nPDM, version 2.29.7\n[attack] pdm --version -\u003e marker: pth executed, cmd=['/work/venv/bin/pdm', '--version']\n$ pdm config cache_dir\n.pdmcache\n[control, no pdm.toml] marker: NONE\n```\n\nThe same on main (`PDM, version 2.29.8.dev18`). I can post the script here.\n\n## Impact\n\nCode execution as the user who runs pdm in an untrusted checkout, when the checkout path matches one the repository prepared and `PDM_CACHE_DIR` is not set. I showed it with `pdm --version`; since the plugin library is loaded in `Core.__init__`, other commands should behave the same, including ones that otherwise do not run project code (`pdm lock`, `pdm export`), but `--version` was only ran. The directory layout also has to match the victim's Python version (`lib/python3.12/...`), which a repository can cover by shipping several.\n\n## Suggested fix\n\nWhen loading a project `pdm.toml`, ignore `global_only` keys with a warning (or skip project data for them in `__getitem__`), and compute `project_plugins_dir` from the global `cache_dir` only. A regression test: a project `pdm.toml` that sets `cache_dir` must not change `project.cache_dir` or `project_plugins_dir`.\n\n## Notes\n\nAI tools (Claude, with a separate Codex review) were used while auditing the code and writing this report. The PoC was manually ran by the reporter. Tested 2.29.7 and main; 2.27.0 as the first affected version is inferred from 16bab5cd.","status":"published","published":"2026-12-04T21:49:17Z","modified":"2026-12-04T21:49:19Z","cvss":[{"version":"3.1","score":7,"vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high"}],"cwes":["CWE-15","CWE-94"],"updated_at":"2026-12-04T21:59:20.06816Z"}],"nvd":[{"id":"CVE-2026-141547","description":"PDM is a Python package and dependency manager. From 2.27.0 until 2.29.8, a repository-controlled pdm.toml can override the global_only setting cache_dir 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 project_plugins_dir is computed beneath the resulting cache directory. During Core.__init__ in src/pdm/core.py, load_plugins 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 PDM_CACHE_DIR 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.","status":"published","published":"2026-12-02T19:18:01.557Z","modified":"2026-12-03T00:18:05.123Z","cvss":[{"version":"3.1","score":7,"vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high","assessor":"secondary"}],"cwes":["CWE-15","CWE-94"],"ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"total","date":"2026-12-02"},"updated_at":"2026-12-03T00:20:05.019864Z"}],"osv":[{"id":"CVE-2026-141547","title":"PDM: A project pdm.toml can still set cache_dir, which brings back project-controlled plugin code at pdm startup","description":"PDM is a Python package and dependency manager. From 2.27.0 until 2.29.8, a repository-controlled pdm.toml can override the global_only setting cache_dir 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 project_plugins_dir is computed beneath the resulting cache directory. During Core.__init__ in src/pdm/core.py, load_plugins 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 PDM_CACHE_DIR 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.","status":"published","published":"2026-12-02T18:58:22.343Z","modified":"2026-12-03T21:01:58.872536996Z","cvss":[{"version":"3.1","score":7,"vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high"}],"cwes":["CWE-15","CWE-94"],"updated_at":"2026-12-03T21:10:05.302032Z"}]}}
