-
Notifications
You must be signed in to change notification settings - Fork 10
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
Security Vulnerability Found #7
Comments
@operatorequals Can you please issue an GHSA advisory for this? |
I just did! Thanks for reporting! |
@operatorequals Thanks for creating the GHSA but I disagree with the impact as mentioned in the GHSA. For severity assessment, we take the default software as it runs out of box without any config or other changes and assess the impact. In this case, since there is no auth on the route, the severity is explained by the CVSS v3.1 vector AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:L. This gives the bug a severity of 9.3/10 which is critical. Also, can you please add me as the contributor on the GHSA there? |
@operatorequals Can you please add CVE-2022-31502 as the CVE id to the GHSA? MITRE issued this earlier today. |
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”.
Root Cause Analysis
The
os.path.join
call is unsafe for use with untrusted input. When theos.path.join
call encounters an absolute path, it ignores all the parameters it has encountered till that point and starts working with the new absolute path. Please see the example below.Since the "malicious" parameter represents an absolute path, the result of
os.path.join
ignores the static directory completely. Hence, untrusted input is passed via theos.path.join
call toflask.send_file
can lead to path traversal attacks.In this case, the problems occurs due to the following code :
wormnest/app.py
Line 127 in dd98162
Here, the
req_path
parameter is attacker controlled. This parameter passes through the unsafeos.path.join
call making the effective directory and filename passed to thesend_file
call attacker controlled. 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 theflask.safe_join
to join untrusted paths or replaceflask.send_file
calls withflask.send_from_directory
calls.References
This bug was found using CodeQL by Github
The text was updated successfully, but these errors were encountered: