Skip to content

Go: zip-slip FP / missed a zip-slip guard in argoproj/argo-cd #17573

Open
@jsoref

Description

@jsoref

"Unsanitized archive entry, which may contain '..', is used in a $@.", sink.getNode(),
"file system operation"

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)
			}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions