GHSA-cm62-gvxx-vmxx: Dulwich Path Traversal Vulnerability

HIGH
CVSS 8.6
CWE-59 CWE-22
Published
Advisory Summary

GHSA-cm62-gvxx-vmxx is a HIGH (CVSS 8.6) path traversal vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting Dulwich libraries in the PyPI ecosystem. The issue involves symlink directory traversal in stash pop allows arbitrary file write via intermediate directory symlinks. Remediation is available by upgrading affected packages to version 1.2.8.

GHSA-cm62-gvxx-vmxx at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-cm62-gvxx-vmxx
Severity HIGH
CVSS v3.1 Base Score 8.6
CWE Classification CWE-59: Improper Link Resolution Before File Access ('Link Following')
Affected Product Dulwich
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.6

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:C/C:H/I:H/A:H).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix GHSA-cm62-gvxx-vmxx

To remediate this vulnerability, upgrade all affected Dulwich dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

dulwich fixed: 1.2.8
pip install dulwich>=1.2.8
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 dulwich

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-cm62-gvxx-vmxx, inspect your installed packages using pip:

pip show dulwich

Analyze the terminal output to locate any version of Dulwich in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.2.8), your application is affected.

Note: The pip show dulwich command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following'), where the product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. In Dulwich, 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 Dulwich's `stash.py:pop()` function is vulnerable to symlink directory traversal, allowing an attacker to write arbitrary files outside the repository worktree when a victim pops a stash in a malicious repository. ## Root Cause The `pop()` function at `dulwich/stash.py:236` uses `os.path.exists(parent_dir)` to check if a parent directory exists before writing stashed files. `os.path.exists()` follows symlinks, so when an intermediate directory in the path is a symlink pointing outside the worktree (e.g., `link → ../../.git/hooks`), the check passes and subsequent file writes resolve through the symlink. The `validate_path()` function (line 228) only validates path component names against `INVALID_DOTNAMES` — it performs zero filesystem symlink detection. On dulwich 1.2.7 (latest release), `build_file_from_blob()` has no symlink protection whatsoever. ## Impact An attacker can craft a malicious repository that, when a victim clones it and performs a stash pop operation, writes attacker-controlled content to arbitrary filesystem locations. Writing to `.git/hooks/post-checkout` achieves Remote Code Execution on the victim's machine on the next git checkout operation. ## Attack Scenario 1. Attacker creates a repository with branch `main` containing `link` (symlink → `../../.git/hooks`) and branch `feature` containing `link/post-checkout` (executable payload) 2. Victim clones the repository (landing on `main` — symlink `link` exists in worktree) 3. Victim checks out `feature`, makes changes, runs `stash.push()` 4. Victim checks out `main` (restoring the `link` symlink) 5. Victim runs `stash.pop(0)` — stash contains `link/post-checkout` 6. `os.path.exists("link")` returns True (symlink to existing directory), `os.makedirs` skipped 7. `build_file_from_blob(blob, mode, "link/post-checkout")` → `open("link/post-checkout", "wb")` follows the intermediate symlink → payload written to `.git/hooks/post-checkout` 8. Next checkout operation triggers the hook → RCE ## Suggested Fix Before writing any file, verify that no component of the target path resolves through a symlink outside the worktree. Use `os.path.realpath(parent_dir)` and confirm it stays within the repository root. Alternatively, use `os.open()` with `O_NOFOLLOW` on each path component. Reported by **zx (Jace)**

GHSA-cm62-gvxx-vmxx Affected Dulwich Versions

1 component(s)
Fixed Versions:
1.2.8
Product / Package Ecosystem Affected Versions Fixed Version
dulwich
PyPI
≥ 0.22.5
< 1.2.8
1.2.8

References

Frequently Asked Questions

What is GHSA-cm62-gvxx-vmxx?
GHSA-cm62-gvxx-vmxx is a security vulnerability in Dulwich involving Symlink directory traversal in stash pop allows arbitrary file write via intermediate directory symlinks under CWE-59: Improper Link Resolution Before File Access ('Link Following').
Which Dulwich versions are affected?
Affected versions include releases prior to 1.2.8 across affected packages: dulwich.
What version fixes GHSA-cm62-gvxx-vmxx?
Upgrading to 1.2.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is dulwich affected?
Yes, dulwich is affected in releases prior to 1.2.8. Upgrade your dependency to 1.2.8 or later.
What is the CVSS score of GHSA-cm62-gvxx-vmxx?
GHSA-cm62-gvxx-vmxx has a CVSS v3.1 base score of 8.6 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H.
What CWE is associated with GHSA-cm62-gvxx-vmxx?
GHSA-cm62-gvxx-vmxx is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following') (The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.).
How can I check PyPI dependencies for GHSA-cm62-gvxx-vmxx?
Run the dependency tree command: 'pip show dulwich'. 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-cm62-gvxx-vmxx",
  "modified" : "2026-10-02T18:52:53Z",
  "published" : "2026-10-02T18:52:53Z",
  "aliases" : [ ],
  "summary" : "Dulwich: Symlink directory traversal in stash pop allows arbitrary file write via intermediate directory symlinks",
  "details" : "## Summary\n\nDulwich's `stash.py:pop()` function is vulnerable to symlink directory traversal, allowing an attacker to write arbitrary files outside the repository worktree when a victim pops a stash in a malicious repository.\n\n## Root Cause\n\nThe `pop()` function at `dulwich/stash.py:236` uses `os.path.exists(parent_dir)` to check if a parent directory exists before writing stashed files. `os.path.exists()` follows symlinks, so when an intermediate directory in the path is a symlink pointing outside the worktree (e.g., `link → ../../.git/hooks`), the check passes and subsequent file writes resolve through the symlink.\n\nThe `validate_path()` function (line 228) only validates path component names against `INVALID_DOTNAMES` — it performs zero filesystem symlink detection. On dulwich 1.2.7 (latest release), `build_file_from_blob()` has no symlink protection whatsoever.\n\n## Impact\n\nAn attacker can craft a malicious repository that, when a victim clones it and performs a stash pop operation, writes attacker-controlled content to arbitrary filesystem locations. Writing to `.git/hooks/post-checkout` achieves Remote Code Execution on the victim's machine on the next git checkout operation.\n\n## Attack Scenario\n\n1. Attacker creates a repository with branch `main` containing `link` (symlink → `../../.git/hooks`) and branch `feature` containing `link/post-checkout` (executable payload)\n2. Victim clones the repository (landing on `main` — symlink `link` exists in worktree)\n3. Victim checks out `feature`, makes changes, runs `stash.push()`\n4. Victim checks out `main` (restoring the `link` symlink)\n5. Victim runs `stash.pop(0)` — stash contains `link/post-checkout`\n6. `os.path.exists(\"link\")` returns True (symlink to existing directory), `os.makedirs` skipped\n7. `build_file_from_blob(blob, mode, \"link/post-checkout\")` → `open(\"link/post-checkout\", \"wb\")` follows the intermediate symlink → payload written to `.git/hooks/post-checkout`\n8. Next checkout operation triggers the hook → RCE\n\n## Suggested Fix\n\nBefore writing any file, verify that no component of the target path resolves through a symlink outside the worktree. Use `os.path.realpath(parent_dir)` and confirm it stays within the repository root. Alternatively, use `os.open()` with `O_NOFOLLOW` on each path component.\n\nReported by **zx (Jace)**",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "dulwich"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.22.5"
      }, {
        "fixed" : "1.2.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.2.7"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/jelmer/dulwich/security/advisories/GHSA-cm62-gvxx-vmxx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jelmer/dulwich/commit/40a542cb02f9ac39a9eeac1193472903098698f9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jelmer/dulwich"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jelmer/dulwich/releases/tag/dulwich-1.2.8"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-59" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-02T18:52:53Z",
    "nvd_published_at" : null
  }
}