You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Absolute Path Traversal due to incorrect use of send_file call
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_filecan lead to path traversal attacks.
In this case, the problems occurs due to the following code :
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
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 :
VideoServer/video_server.py
Line 295 in 136df79
Here, the
res
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
The text was updated successfully, but these errors were encountered: