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

Fix path traversal #3

Merged
merged 3 commits into from
Aug 30, 2024
Merged

Conversation

qkaiser
Copy link
Contributor

@qkaiser qkaiser commented Nov 2, 2022

The code was implementing a path traversal check based on the detection of .. in directory names and file names. This is sufficient to protect against path traversal attacks using relative paths but insufficient for attacks using absolute paths.

This is due to the fact that the second argument of os.path.join() takes precedence if it starts with /:

>>> print(os.path.join('outdir', '/tmp/hacked'))
/tmp/hacked

Added the same check we used for ubireader (see onekey-sec/ubi_reader@c6a1272).

qkaiser and others added 3 commits January 13, 2022 16:16
Do not fail if the output directory already exists.
The code was implementing a path traversal check based on the detection
of '..' in directory names and file names. This is sufficient to protect
against path traversal attacks using relative paths but insuficcient for
attacks using absolute paths.

This is due to the fact that the second argument of os.path.join() takes
precedence if it starts with '/':

>>> print(os.path.join('outdir', '/tmp/hacked'))
/tmp/hacked
@qkaiser
Copy link
Contributor Author

qkaiser commented Jan 31, 2023

We have an upcoming publication about similar vulnerabilities affecting different extractors in ubi-reader, jefferson, yaffshiv, and binwalk. We requested CVEs for each of these vulnerability so that users are aware they should upgrade to the latest version (through dependabot for example).

The one that should be fixed by this PR has been assigned CVE-2023-0593.

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.

2 participants