Skip to content

Vulnerable to path traversal #5

@certlg

Description

@certlg

The unTar function constructs destination paths by concatenating the destination directory, a path separator, and the untrusted filename from the archive here:

		dst := dstPath + "/" + header.Name

This is vulnerable to path traversal if header.Name contains ../outside for example.

The shortest code to sanitize the path would be:

header.Name = strings.TrimPrefix(filepath.Clean("/" + header.Name), "/")

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions