Path Traversal Attack

So, you’ve heard… Path Traversal?

Path traversal vulnerabilities is one of the most common server-side vulnerabilities. Well, this is also known as directory traversal.

This vulnerability enables an attacker to access files in a server. These file…


This content originally appeared on DEV Community and was authored by WI$DOM

So, you've heard... Path Traversal?

Path traversal vulnerabilities is one of the most common server-side vulnerabilities. Well, this is also known as directory traversal.

This vulnerability enables an attacker to access files in a server. These files might include:

  • Application code and data
  • Credentials for backend systems
  • Sensitive files such as users data

In some cases, an attacker can write to a file to modify it. Thereby gaining full access control. So, how do you read these files?

Imagine a shopping application that displays an image, the image loads with the HTML tag:

<img src="/loadImage?filename=218.png">

The LoadImage takes the filename parameter and returns the content of the specified file. The image might be stored in /var/www/images. So what this means is that the stored image path on the server is /var/www/images/218.png.

Now an attacker can read from the file server with https://insecure-website.com/loadImage?filename=../../../etc/passwd which reads /var/www/images/../../../etc/passwd. The ../ means to step up in the directory structure, which means the file actually being read is /etc/passwd.

How path traversal is exploited

Here's a simplified story version for you to understand better.

Imagine your website is like a restaurant kitchen. Everything a customer (you, the user) can ask for—menu items, prices, the daily special—is in a specific, public area of the kitchen. That's like your "public files" folder.

Now, imagine there's a back room in that kitchen. This room holds all the secret stuff: the chef's private recipes, the safe with the day's earnings, and employee records. This area is strictly off-limits to customers.

Here's where the problem, called Path Traversal, sneaks in.

A hacker tries to order something from your website. But instead of asking for "menu.pdf," they try a trick:

../../secret_chef_recipes/private_sauce.txt

Think of ../ as telling the website, "Go back one step, then another step."

It's like someone telling the kitchen staff, "Instead of getting me the soup from here, go out of the kitchen, then back through the restaurant door, and then look for the 'secret chef recipes' room!"

If the website isn't careful, it blindly follows these "go back" instructions. Suddenly, it steps outside the public area and hands over the chef's secret sauce recipe – or even worse, the day's earnings!

Path Traversal happens when a website lets a hacker use these ../ tricks to leave the public areas and snoop around for private files they shouldn't see. Sometimes, they can even change these files, just like someone sneaking into the secret room and messing with the recipes!

So, while the concept of Path Traversal might seem simple, its implications are severe. Never trust user input!! 😂

Now that you understand path traversal, next step is to learn who can access what. That's where Access Control comes in. Check out the next blog post. ✌️


This content originally appeared on DEV Community and was authored by WI$DOM


Print Share Comment Cite Upload Translate Updates
APA

WI$DOM | Sciencx (2025-07-22T11:13:10+00:00) Path Traversal Attack. Retrieved from https://www.scien.cx/2025/07/22/path-traversal-attack/

MLA
" » Path Traversal Attack." WI$DOM | Sciencx - Tuesday July 22, 2025, https://www.scien.cx/2025/07/22/path-traversal-attack/
HARVARD
WI$DOM | Sciencx Tuesday July 22, 2025 » Path Traversal Attack., viewed ,<https://www.scien.cx/2025/07/22/path-traversal-attack/>
VANCOUVER
WI$DOM | Sciencx - » Path Traversal Attack. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/07/22/path-traversal-attack/
CHICAGO
" » Path Traversal Attack." WI$DOM | Sciencx - Accessed . https://www.scien.cx/2025/07/22/path-traversal-attack/
IEEE
" » Path Traversal Attack." WI$DOM | Sciencx [Online]. Available: https://www.scien.cx/2025/07/22/path-traversal-attack/. [Accessed: ]
rf:citation
» Path Traversal Attack | WI$DOM | Sciencx | https://www.scien.cx/2025/07/22/path-traversal-attack/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.