Security: --delete follows symlinks and may delete outside destination tree #162
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
delete_extras()insrc/shared/utils.c:123-125walks the destination tree and removes files/directories not present in the sender manifest. The helperdelete_extras_walk()usesstat()(which follows symlinks) andunlink()/rmdir()on paths constructed by concatenating the root with manifest-relative entries. If the destination tree contains a symlink, the walker may follow it and delete files outside the intended destination directory.Location
src/shared/utils.c:84-120—delete_extras_walk()follows symlinks viastat()and deletes the target.src/shared/file.c:521-539—receive_manifest()feeds the manifest directly intodelete_extras().Suggested fix
lstat()instead ofstat()and never follow symlinks during cleanup.unlinkat(dirfd, ...)relative to it.--forcebefore deleting directories, and count deletions for a--max-deletesafety limit.Severity
Medium
Category
security
This issue was automatically generated by the issue-creator agent.