Path Traversal, also known as Local File Inclusion (LFI), is a vulnerability that allows attackers to read files on the server that they aren't supposed to access. It occurs when user-supplied input is not properly sanitized, allowing the attacker to manipulate the file path.

How it Works

In a typical scenario, an attacker might manipulate a URL parameter that is used to fetch and display a file from the server. For example, a URL like http://example.com/?file=about.html might display the about.html file to the user. However, if the website does not properly sanitize this input, an attacker could change the URL to http://example.com/?file=../../etc/passwd, potentially allowing them to view sensitive system files.

Prevention

Preventing Path Traversal attacks primarily involves proper input sanitation. This can be achieved by ensuring that user-supplied file paths do not escape the intended directory. Techniques such as using absolute file paths, rejecting file paths that contain .., and validating user input against a list of permitted files can be effective in mitigating this vulnerability.

Additionally, limiting the permissions of the web server user can also be an effective measure as it can prevent the server from accessing sensitive files even if a Path Traversal attack is successful.

SOON 😊