Description
codeql/go/ql/src/Security/CWE-022/ZipSlip.ql
Lines 22 to 23 in 590e93d
Here's my fork's report:
https://github.com/check-spelling-sandbox/argo-cd/security/code-scanning/4
Arbitrary file access during archive extraction ("Zip Slip")
Code snippet
util/io/files/tar.go:75
tr := tar.NewReader(lr)
for {
header, err := tr.Next()
Unsanitized archive entry, which may contain '..', is used in a .
Here's the accused flow:
Arbitrary file access during archive extraction ("Zip Slip")
Step 1 ... := ...[0]
Source
util/io/files/tar.go:75
tr := tar.NewReader(lr)
for {
header, err := tr.Next()
Unsanitized archive entry, which may contain '..', is used in a .
Unsanitized archive entry, which may contain '..', is used in a .
Unsanitized archive entry, which may contain '..', is used in a .
if err != nil {
if err == io.EOF {
break
Step 2 selection of Name
util/io/files/tar.go:86
continue
}
target := filepath.Join(dstPath, header.Name)
Note
There is a check for zip-slip right here in the form of Inbound:
// Sanity check to protect against zip-slip
if !Inbound(target, dstPath) {
return fmt.Errorf("illegal filepath in archive: %s", target)
Step 3 call to Join
util/io/files/tar.go:86
continue
}
target := filepath.Join(dstPath, header.Name)
// Sanity check to protect against zip-slip
if !Inbound(target, dstPath) {
return fmt.Errorf("illegal filepath in archive: %s", target)
Step 4 target
Sink
util/io/files/tar.go:98
if preserveFileMode {
mode = os.FileMode(header.Mode)
}
err := os.MkdirAll(target, mode)
if err != nil {
return fmt.Errorf("error creating nested folders: %w", err)
}