Skip to content

Commit

Permalink
:fix: path traversal bug
Browse files Browse the repository at this point in the history
- fixes #438

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan committed Feb 22, 2024
1 parent d764462 commit 05a05ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pkg/sources/tarball.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,13 @@ func (t *TarballBundle) extractPkgFromBundle() ([]string, error) {
})

path := desc.Annotations[ocispec.AnnotationTitle]
cleanPath := filepath.Clean(path)
if strings.Contains(cleanPath, "..") {
// Log the attempt or handle it as needed
return fmt.Errorf("invalid path detected: %s", path)
}
size := desc.Size
layerDst := filepath.Join(t.TmpDir, path)
layerDst := filepath.Join(t.TmpDir, cleanPath)
if err := zarfUtils.CreateDirectory(filepath.Dir(layerDst), 0700); err != nil {
return err
}
Expand Down

0 comments on commit 05a05ed

Please sign in to comment.