Skip to content

fix(builtins): reject path traversal in patch diff headers#1051

Merged
chaliy merged 3 commits intomainfrom
fix/issue-989-patch-path-traversal
Apr 4, 2026
Merged

fix(builtins): reject path traversal in patch diff headers#1051
chaliy merged 3 commits intomainfrom
fix/issue-989-patch-path-traversal

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 3, 2026

Summary

  • Add validate_path() that rejects paths containing .. components after strip_path()
  • Prevents crafted diff headers like --- a/../../../etc/passwd from writing outside working directory
  • Normal patch paths still work correctly

Test plan

  • ../../../etc/passwd traversal rejected with error
  • foo/../../secret.txt embedded traversal rejected
  • Normal clean paths after strip still work
  • All 20 patch unit tests pass
  • All existing spec tests pass

Closes #989

@chaliy chaliy merged commit 67d2bad into main Apr 4, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-989-patch-path-traversal branch April 4, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Patch builtin path traversal via crafted diff headers

1 participant