Skip to content

Commit

Permalink
fix(utils): avoid zip slip vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
vimiix committed Jun 12, 2024
1 parent bb268b4 commit 1c05f17
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/denisbrodbeck/machineid"
"github.com/pkg/errors"
"github.com/vimiix/ssx/internal/file"
"github.com/vimiix/ssx/internal/lg"
"github.com/vimiix/ssx/ssx/env"
)

Expand Down Expand Up @@ -198,6 +199,11 @@ func Untar(tarPath string, targetDir string, filenames ...string) error {
case header == nil:
continue
}
if strings.Contains(header.Name, "..") {
// code scanning: https://github.com/vimiix/ssx/security/code-scanning/3
lg.Warn("ignore file %s due to zip slip vulnerability", header.Name)
continue
}

// the target location where the dir/file should be created
target := filepath.Join(targetDir, filepath.FromSlash(header.Name))
Expand Down

0 comments on commit 1c05f17

Please sign in to comment.