Skip to content

Commit

Permalink
Sanitize file target paths
Browse files Browse the repository at this point in the history
In order to reduce risk of directory traversal attack
  • Loading branch information
qu1queee committed Oct 13, 2023
1 parent 4bd3b46 commit bcac4e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ func Unpack(in io.Reader, targetPath string) error {
}

var target = filepath.Join(targetPath, header.Name)
if strings.Contains(target, "..") {
return fmt.Errorf("targetPath validation failed, path contains unexpected special elements")
}

switch header.Typeflag {
case tar.TypeDir:
if err := os.MkdirAll(target, os.FileMode(header.Mode)); err != nil {
Expand Down

0 comments on commit bcac4e5

Please sign in to comment.