Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion router/router_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ out:
trnsfr.Log().WithField("path", installLogPath).Debug("install logs saved successfully")

case strings.HasPrefix(name, "backup_"):
backupName := strings.TrimPrefix(name, "backup_")
backupNameUnsafe := strings.TrimPrefix(name, "backup_")
// Strip all directory components
backupName := filepath.Base(backupNameUnsafe)
Comment on lines +266 to +268

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Reject path-bearing backup names instead of silently collapsing them.

filepath.Base prevents directory traversal, but it also maps distinct multipart names such as backup_a/foo.tar.gz and backup_b/foo.tar.gz to the same destination; the later part can truncate the earlier file. Checksum fields are still keyed from the raw suffix at Lines 308-317, so the filename and checksum contracts can also diverge.

Reject names where backupNameUnsafe != filepath.Base(backupNameUnsafe) (including . and ..) before creating the file, or canonicalize checksum names identically and reject duplicate normalized names.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@router/router_transfer.go` around lines 266 - 268, Validate the raw suffix in
the backup-name handling before creating any file: when backupNameUnsafe differs
from filepath.Base(backupNameUnsafe), including "." or "..", reject the
multipart part instead of using the collapsed basename. Keep accepted names
unchanged and ensure rejection occurs before destination creation and checksum
processing.

trnsfr.Log().WithField("backup", backupName).Debug("received backup file")

// Create backup directory if it doesn't exist
Expand Down
Loading