Summary
isomorphic-git could follow a tracked symbolic link outside a worktree when applying changes during a cherry-pick. If a cherry-picked tree places a file beneath that link, attacker-controlled content may be written to the external destination.
Affected context
The issue occurs in isomorphic-git's cherry-pick tree-change handling when a worktree contains a tracked symbolic link pointing outside the worktree. It becomes risky when a cherry-pick applies a file beneath that symlink without checking the path components before writing.
Exploit preconditions
- Attack surface: A worktree where isomorphic-git performs a cherry-pick
- Required access: The attacker must be able to influence the tree being cherry-picked, and the victim must have a worktree containing a suitable tracked symlink
- Trigger point: Applying a cherry-picked file beneath the symlink
- Why exploitation is possible: The write follows the leading symlink and does not confine the destination to the worktree
Why this happens
The tree-change handling does not verify that path components are not symbolic links before writing files. This allows a path that appears to be inside the worktree to resolve to a location outside it, matching CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Potential impact
- Attacker-controlled content may be written to files outside the worktree
- Data may be tampered with or deleted, depending on the selected destination
- Written content could cause code injection if it replaces or alters interpreted files
- The resulting changes may contribute to privilege escalation, denial of service, or follow-on code execution
General mitigation guidance
Defensive patterns focus on ensuring writes remain confined to the intended worktree and reducing trust in repository-controlled paths.
- Reject or safely handle paths containing symlinked components before writing
- Resolve and validate destination paths against the canonical worktree root
- Use filesystem operations and containment checks that account for symlink changes
- Treat repository trees and their path metadata as untrusted input
- Run Git operations with the minimum filesystem permissions needed
How teams detect issues like this
- Use static analysis to identify file writes that join untrusted paths to a worktree root without symlink-aware containment checks
- Review cherry-pick and checkout code for validation performed before, rather than after, filesystem path resolution
- Add tests for tracked symlinks that point outside the worktree and verify that writes cannot escape it
- Enforce code-review or CI policies requiring path containment checks for filesystem writes

