Directory Traversal

If the web application does not sanitize or uses poor sanitization logic for (file path) parameter input. Then we can include in our own files or traverse files to leak data.

Example:

After clicking the “Menu” link, the URL is updated and contains a parameter named file with a value of “current_menu.php”.

The file extension on a parameter value is usually a good indication that we should investigate further because it suggests text or code is being included from a different resource. Most directory traversals are not this obvious but a fair number of old PHP applications load pages in a similar fashion. More examples at: https://owasp.org/www-community/attacks/Path_Traversal

Globally readable: Linux: /etc/passwd Windows: c:\boot.ini c:\windows\system32\drivers\etc\hosts \windows\win.ini Depending on the web server and app you may need to use forward slashes /

Null Byte:

In many operating systems, null bytes %00 can be injected to terminate the filename. For example, sending a parameter like: ?file=secret.doc%00.pdf will result in the Java application seeing a string that ends with “.pdf” and the operating system will see a file that ends in “.doc”. Attackers may use this trick to bypass validation routines.

Null bytes do not work with PHP >= 5.3.4

Last updated