Sitemap
Mohammed Hassan

Mohammed Hassan

Cyber Security Engineer, interested in Penetration Testing

Path Traversal

2 min readAug 20, 2025
  • Path traversal vulnerability (also known as directory traversal) is a type of security flaw that allows an attacker to access files and directories that are outside the intended directory structure of a web application.
Press enter or click to view image in full size
  • Web applications often take user input to access files on the server (e.g., loading images, downloading documents, or reading logs). If this input isn’t properly validated or sanitized, an attacker can manipulate it to “traverse” directories and access files that should be restricted.
  • A usual path in the URL is like: https://www.example.com/test
  • This path is translated in the server side like: /var/www/html/test
  • Now we have sensitive paths that start from the root / like : /etc/passwd OR /etc/shadow OR /etc/hosts OR /etc/hostname
  • to get one step back we use the command ../
  • Now we want to delete /var/www/html/test to go to the root /
  • So we will use ../../../../ after the original path
  • Then we can easily insert the sensitive path that we want like : /etc/passwd , or any path.
  • And if the server is windows just replace the ../ with ..\
  • And you will find a sensitive paths for windows like: ..\..\..\windows\win.ini
  • The work is not that easy all the time, there may be some filtrations on the user input that makes the previous steps not work, so we need to bypass these filtrations
  • To bypass the filtrations:
  1. encode ../
  2. use ⇒ ..//..// instead of ../../
  3. use ⇒ …/./…/./ instead of ../../
  4. use ⇒ ….//….// instead of ../../
  5. use ⇒ .././.././ instead of ../../
  6. replace / with \ even if you know that the server is Linux server
  7. read this article⇒ path traversal cheat sheet
  • Some Tips And Tricks:
  1. make the burp not filter images because images come from the server

2. you can use /etc/passwd directly without the need of ../../

Get Mohammed Hassan’s stories in your inbox

Join Medium for free to get updates from this writer.

3. intruder has a wordlist for path traversal, but don`t relay on it because you will probably get blocked by the server

4. if encoding once not work encode more than once

5. source code shows paths that deals with the server

6. use the null value to fool the server like ⇒ ../../../etc/passwd%00.jpg

7. path traversal may appear in headers like ⇒ Accept: ../../../../../../../../../../etc/passwd{{

8. GET /assets/css///////../../../../../../../../etc/passwd

9. GET /path\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\etc\passwd%3F.js

--

--

Mohammed Hassan
Mohammed Hassan

Written by Mohammed Hassan

Cyber Security Engineer, interested in Penetration Testing