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. It should be noted that access to files is limited by system operational access control (such as in the case of locked or in-use files on the Microsoft Windows operating system).
This attack is also known as “dot-dot-slash”, “directory traversal”, “directory climbing” and “backtracking”.
Root Cause Analysis
In the case of Alquist, the path traversal vulnerability can be blamed on incorrect usage of the send_from_directory Flask call. The vulnerability occurs due to the code snippet shown below
Here, since the path and file parameters are attacker controlled, the effective directory and filename passed to the send_from_directory call can be controlled by the attacker leading to a path traversal attack.
Proof of Concept
The bug can be verified using the proof of concept similar to the one shown below.
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. It should be noted that access to files is limited by system operational access control (such as in the case of locked or in-use files on the Microsoft Windows operating system).
This attack is also known as “dot-dot-slash”, “directory traversal”, “directory climbing” and “backtracking”.
Root Cause Analysis
In the case of Alquist, the path traversal vulnerability can be blamed on incorrect usage of the
send_from_directoryFlask call. The vulnerability occurs due to the code snippet shown belowalquist/IO/input.py
Lines 69 to 72 in 280d99f
Here, since the
pathandfileparameters are attacker controlled, the effective directory and filename passed to thesend_from_directorycall can be controlled by the attacker leading to a path traversal attack.Proof of Concept
The bug can be verified using the proof of concept similar to the one shown below.
Remediation
This can be easily fixed my restricting the value of
fileandpathparameters by a fixed whitelist of possible values.This bug was found using CodeQL by Github
The text was updated successfully, but these errors were encountered: