Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert no. 2: Arbitrary file access during archive extraction ("Zip Slip") #1214

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions src/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,11 @@ func unzip(src string, dest string) error {
// Build the path for each file in the destination directory
fpath := filepath.Join(dest, f.Name)

// Validate the file path to prevent directory traversal
if strings.Contains(f.Name, "..") {
return fmt.Errorf("invalid file path: %s", f.Name)
}

// Check if the file is a directory
if f.FileInfo().IsDir() {
// Create directory if it doesn't exist
Expand Down
Loading