PT-2026-111185 · Pypi · Dulwich

تاريخ النشر

2026-10-02

·

تاريخ التحديث

2026-10-02

CVSS v3.1

8.6

عالية

المتجهAV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H

Summary

Dulwich's filter branch.py CommitFilter. apply index filter() is vulnerable to symlink directory traversal. When processing commit history, materialized tree entries (including symlinks) persist in the working directory between commits, allowing a symlink from an ancestor commit to redirect file writes from a descendant commit to arbitrary filesystem locations.

Root Cause

apply index filter() at dulwich/filter branch.py:212 calls build index from tree(".", tmp index path, ...) which materializes all tree entries to the current working directory. The finally block (line 229-230) only cleans up the temporary index file (os.unlink(tmp index path)) — NOT the filesystem files written to CWD. When process commit() processes parents recursively first (line 260), files materialized from ancestor commits persist and affect processing of descendant commits.
On dulwich 1.2.7, build file from blob() has no symlink protection, and validate path element only validates name patterns, not filesystem state.

Impact

An attacker can craft a malicious repository where running filter branch with an index filter writes attacker-controlled content to arbitrary filesystem locations via symlink traversal. This achieves RCE if the write targets .git/hooks/.

Attack Scenario

  1. Attacker creates a repository where commit history (linearized) has:
  • Ancestor commit: tree entry evil (mode 120000, symlink → /target dir)
  • Descendant commit: tree entry evil/payload (mode 100644, attacker content)
  1. Victim clones repository and runs filter branch with an index filter
  2. process commit() processes ancestor first → materializes evil as symlink to /target dir in CWD
  3. CWD is NOT cleaned between commits
  4. Processing descendant: os.path.exists("./evil") → True (symlink exists). build file from blob(blob, mode, "./evil/payload") → open("./evil/payload", "wb") follows intermediate symlink → writes to /target dir/payload

Suggested Fix

Clean the CWD between commit iterations in apply index filter(), or verify that no intermediate path components are symlinks before writing files.
Reported by zx (Jace)

إصلاح

Link Following

Path traversal

وجدت خطأً في الوصف؟ لديك ما تضيفه؟ لا تتردد في مراسلتنا 👾

تصنيف نقاط الضعف

المعرّفات ذات الصلة

GHSA-5FQC-MRG8-W798

المنتجات المتأثرة

Dulwich