SecOraLens
HighCVE

Dulwich: Symlink write-through in checkout(paths=[]) via raw os.open bypasses all symlink protections

GitHub Security Advisories·Source published ·1 min read

What happened?

Summary Dulwich's porcelain.checkout(paths=[...]) code path writes files using raw os.open(file_path, O_WRONLY|O_CREAT|O_TRUNC, mode) followed by f.write(obj.data). This code path does NOT call build_file_from_blob() at all, completely bypassing any symlink protections (including the unreleased d09f8af fix). os.open without O_NOFOLLOW follows symlinks at both the target file and intermediate directories, allowing arbitrary file writes.

Key details

  • The vulnerable code path writes files directly without calling build_file_from_blob, skipping symlink checks.
  • An attacker can craft a malicious repository that writes arbitrary content to any location accessible to the user.
  • Writing to .git/hooks/post-checkout enables remote code execution on the next git checkout operation.
  • The attack uses a symlink in HEAD pointing to .git/hooks/post-checkout and a malicious executable file in a tag.
  • _checked_worktree_path only validates path names and performs zero filesystem symlink detection.
  • The suggested fix is to replace raw os.open with build_file_from_blob or add explicit symlink detection using os.path.realpath.

What is affected?

  • Dulwich versions 0.24.0 through 1.2.7 are affected.

Summarised by SecOraLens from GitHub Security Advisories. Always read the original source before acting. How SecOraLens verifies advisories.

What to do next

For CISOs and SOC leads

Brief your board. Brief your team.

Executive risk briefs for governance, technical kill-chains for the SOC — delivered as advisories publish. Critical alerts within 1 hour. No spam, unsubscribe anytime.