-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fixes #474 #476
Open
porcupineyhairs
wants to merge
581
commits into
bonn-activity-maps:master
Choose a base branch
from
porcupineyhairs:FixPathInjection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fixes #474 #476
porcupineyhairs
wants to merge
581
commits into
bonn-activity-maps:master
from
porcupineyhairs:FixPathInjection
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ty keypoints in ignore regions with kps
…nd working. Complex checks TODO.
…cts inside bbox and ignore region. TODO further validation to find weird interactions. bonn-activity-maps#399
…ion to bonn-activity-maps#399 (I forgot to reference the previous one)
Fix bug by which some person keypoints were not checked.
…elop Add clickable list of sanity check errors. bonn-activity-maps#399
…elop Update fixed error with not checking recursive length of bbox keypoin…
…elop bonn-activity-maps#467 update change person id
A path traversal attack (also known as directory traversal) aims to access files and directories that are stored outside the web root folder. By manipulating variables that reference files with “dot-dot-slash (../)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code or configuration and critical system files. This attack is also known as “dot-dot-slash”, “directory traversal”, “directory climbing” and “backtracking”. ## Common Weakness Enumeration category CWE - 36 ## Root Cause Analysis Passing untrusted input to `flask.send_file`can lead to path traversal attacks. In this case, the problems occurs due to the following code : https://github.com/bonn-activity-maps/bam_annotation_tool/blob/7a950e27ca9ea850f3f83907fc890c343d8bff3a/src/api.py#L342 Here, the `filename` parameter is attacker controlled and is used as the filename passed to the `send_file` call. This leads to a path traversal attack. ## Proof of Concept The bug can be verified using a proof of concept similar to the one shown below. ``` curl --path-as-is 'http://<domain>/usr/storage//../../../../etc/passwd"' ``` ## Remediation This can be fixed by preventing flow of untrusted data to the vulnerable `send_file` function. In case the application logic necessiates this behaviour, one can either use the `werkzeug.utils.safe_join` to join untrusted paths or replace `flask.send_file` calls with `flask.send_from_directory` calls. ## Common Vulnerability Scoring System Vector The attack can be carried over the network. A complex non-standard configuration or a specialized condition is not required for the attack to be successfully conducted. There is no user interaction required for successful execution. The attack can affect components outside the scope of the target module. The attack can be used to gain access to confidential files like passwords, login credentials and other secrets. It cannot be directly used to affect a change on a system resource. Hence has limited to no impact on integrity. Using this attack vector a attacker may make multiple requests for accessing huge files such as a database. This can lead to a partial system denial service. However, the impact on availability is quite low in this case. Taking this account an appropriate CVSS v3.1 vector would be (AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:L)[https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:L&version=3.1] This gives it a base score of 9.3/10 and a severity rating of critical. ## References * [OWASP Path Traversal](https://owasp.org/www-community/attacks/Path_Traversal) * github/securitylab#669 ### This bug was found using *[CodeQL by Github](https://codeql.github.com/)*
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Absolute Path Traversal due to incorrect use of
send_file
callA path traversal attack (also known as directory traversal) aims to access files and directories that are stored outside the web root folder. By manipulating variables that reference files with “dot-dot-slash (../)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code or configuration and critical system files. This attack is also known as “dot-dot-slash”, “directory traversal”, “directory climbing” and “backtracking”.
Common Weakness Enumeration category
CWE - 36
Root Cause Analysis
Passing untrusted input to
flask.send_file
can lead to path traversal attacks.In this case, the problems occurs due to the following code :
bam_annotation_tool/src/api.py
Line 342 in 7a950e2
Here, the
filename
parameter is attacker controlled and is used as the filename passed to thesend_file
call. This leads to a path traversal attack.Proof of Concept
The bug can be verified using a proof of concept similar to the one shown below.
Remediation
This can be fixed by preventing flow of untrusted data to the vulnerable
send_file
function. In case the application logic necessiates this behaviour, one can either use thewerkzeug.utils.safe_join
to join untrusted paths or replaceflask.send_file
calls withflask.send_from_directory
calls.Common Vulnerability Scoring System Vector
The attack can be carried over the network. A complex non-standard configuration or a specialized condition is not required for the attack to be successfully conducted. There is no user interaction required for successful execution. The attack can affect components outside the scope of the target module. The attack can be used to gain access to confidential files like passwords, login credentials and other secrets. It cannot be directly used to affect a change on a system resource. Hence has limited to no impact on integrity. Using this attack vector a attacker may make multiple requests for accessing huge files such as a database. This can lead to a partial system denial service. However, the impact on availability is quite low in this case. Taking this account an appropriate CVSS v3.1 vector would be
(AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:L)[https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:L&version=3.1]
This gives it a base score of 9.3/10 and a severity rating of critical.
References
This bug was found using CodeQL by Github