Prevent partial path traversal in untar. by mayankshriv · Pull Request #7985 · apache/pinot · GitHub
Skip to content

Prevent partial path traversal in untar. - #7985

Merged
siddharthteotia merged 1 commit into
apache:masterfrom
mayankshriv:security-fix
Jan 9, 2022
Merged

siddharthteotia merged 1 commit into
apache:masterfrom
mayankshriv:security-fix

Conversation

@mayankshriv

Copy link
Copy Markdown
Contributor

The File.getCanonicalPath method transforms the path into a canonical form preventing such attack types as .. in path
segments. If the result of outputDir.getCanonicalPath() is not slash terminated it allows for partial path
traversal.

Consider "/usr/outnot".startsWith("/usr/out"). The check is bypassed although it is not the
out directory. The terminating slash may be removed in various places. On Linux println(new File("/var/")) returns /var, but println(new File("/var", "/")) - /var/, however println(new File("/var", "/").getCanonicalPath()) - /var

Description

Upgrade Notes

Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)

  • Yes (Please label as backward-incompat, and complete the section below on Release Notes)

Does this PR fix a zero-downtime upgrade introduced earlier?

  • Yes (Please label this as backward-incompat, and complete the section below on Release Notes)

Does this PR otherwise need attention when creating release notes? Things to consider:

  • New configuration options
  • Deprecation of configurations
  • Signature changes to public methods/interfaces
  • New plugins added or old plugins removed
  • Yes (Please label this PR as release-notes and complete the section on Release Notes)

Release Notes

Documentation

The `File.getCanonicalPath` method  transforms the path into a canonical form preventing such attack types as `..` in path
segments. If the result of `outputDir.getCanonicalPath()` is not slash terminated it allows for partial path
traversal.

Consider `"/usr/outnot".startsWith("/usr/out")`. The check is bypassed although it is not the
out directory. The terminating slash may be removed in various places. On Linux `println(new
File("/var/"))` returns /var, but `println(new File("/var", "/"))` - `/var/`, however `println(new
File("/var", "/").getCanonicalPath())` - `/var`
@codecov-commenter

codecov-commenter commented Jan 9, 2022 •

Copy link
Copy Markdown

@siddharthteotia
siddharthteotia merged commit 7030260 into apache:master Jan 9, 2022
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

Successfully merging this pull request may close these issues.

4 participants