Member-only story
Directory Traversal

WHAT IS DIRECTORY TRAVERSAL?
Directory traversal or some say “path traversal” is a type of web security vulnerability, which if exploited by the attacker/hacker can result in the information leakage of the arbitrary files on the server which is handling the application.
This leaked information may include the application code data, sensitive info like credentials, username, or operating system-related files. If the attack is persistent then the attacker can write data in the application which can result in compromising the system.
So let’s have a peek at how all this begins. Consider any website of your choice that display images, to load these images in the backend some HTML code is running which looks something like this
<img src="/image?filename=1.png">
So what’s happening here is that the ‘image’ URL is taking the ‘filename’ parameter and returns the content of the specified file. By default, the images are themselves stored in the ‘/var/www/html’ location for the Linux system. To get the specified ‘1.png’ image the application will append the requested filename into the base directory using a filesystem API. So for the above specified eg. the file path would be :
/var/www/html/1.png