Skip to content

Commit

Permalink
fix tar path issue with parent directory (#147)
Browse files Browse the repository at this point in the history
* fix tar path issue

Signed-off-by: hirokuni-kitahara <[email protected]>

* update path check

Signed-off-by: hirokuni-kitahara <[email protected]>

---------

Signed-off-by: hirokuni-kitahara <[email protected]>
  • Loading branch information
hirokuni-kitahara authored Dec 3, 2024
1 parent 2fde1f9 commit f7da642
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/util/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ func GetYAMLsInArtifact(blob []byte) ([][]byte, error) {
return nil, errors.Wrap(err, "tarReader.Next() failed while decompressing tar gz")
}

// Skip files that have path starting with ".."
// Ref: CWE-22
if strings.HasPrefix(header.Name, "..") {
continue
}

switch header.Typeflag {
case tar.TypeDir:
fpath := filepath.Join(dir, header.Name)
Expand Down

0 comments on commit f7da642

Please sign in to comment.