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

Symlink directory traversal security fix #556

Merged
merged 12 commits into from
Sep 10, 2021
Merged

Symlink directory traversal security fix #556

merged 12 commits into from
Sep 10, 2021

Conversation

devttys0
Copy link
Collaborator

@devttys0 devttys0 commented Sep 5, 2021

Extracted archives could create symlinks which point anywhere on the file system, potentially resulting in a directory traversal attack if subsequent extraction utilties blindly follow these symlinks. More generically, Binwalk makes use of many third-party extraction utilties which may have unpatched security issues. This branch addresses these issues by:

  • Sanitizing symlinks that point outside of the extraction directory by changing the symlink target to os.devnull. A warning is displayed to the end user, which includes the path to the offending symlink as well as the original symlink target. Symlink sanitization can be disabled by the end user if desired.
  • Providing a --run-as command line option, which specifies a user account to run third-party extraction utilities under (requires Binwalk itself to be run as root).
  • Refusing to perform extraction as root unless --run-as=root is specified.
  • Adding a notice in the README pertaining to these issues and changes.
  • Adding an explicit test for relative and absolute symlink directory traversal attempts.

@devttys0 devttys0 self-assigned this Sep 5, 2021
@devttys0 devttys0 marked this pull request as draft September 6, 2021 13:56
@devttys0 devttys0 marked this pull request as ready for review September 6, 2021 14:57
@eacmen eacmen merged commit fa0c0bd into master Sep 10, 2021
@eacmen eacmen deleted the unpriv_user_exec branch September 10, 2021 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants