Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulnerable to path traversal #5

Open
certlg opened this issue Jul 26, 2021 · 0 comments
Open

Vulnerable to path traversal #5

certlg opened this issue Jul 26, 2021 · 0 comments

Comments

@certlg
Copy link

certlg commented Jul 26, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant