Skip to content

Commit

Permalink
Update relative path check when extracting tar archives (#656)
Browse files Browse the repository at this point in the history
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
  • Loading branch information
egibs authored Nov 23, 2024
1 parent f81741f commit d1f4b00
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/action/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func extractTar(ctx context.Context, d string, f string) error {
}

clean := filepath.Clean(header.Name)
if filepath.IsAbs(clean) || strings.Contains(clean, "..") {
return fmt.Errorf("invalid file path: %s", header.Name)
if filepath.IsAbs(clean) || strings.Contains(clean, "../") {
return fmt.Errorf("path is absolute or contains a relative path traversal: %s", clean)
}

target := filepath.Join(d, clean)
Expand Down

0 comments on commit d1f4b00

Please sign in to comment.