HTTP Dir Traversal
SeverityHigh
trBu makaleyi Türkçe okuyunALTERNATIVE NAMES
Directory Traversal, Path Traversal, dot-dot-slash, directory climbing or backtracking.
AFFECTED SYSTEMS
Systems with insecure permissions or poor coding
SEVERITY
High
BACKGROUND
Dir traversal Attack aims to access files and folders that are available on the server as a result of poor server-side coding and/or security measures. When scripting languages first developed, no one realized files stored outside the document folder will be readable because of poor coding.
DESCRIPTION
Directory Traversal mostly handled with manual intervention. An attacker must try filenames and paths on server-side scripts if the script is offering a usage similar to this one:
http://site.com/get-file?f=main.php
And the attacker may try a GET URL like this:
http://site.com/get-template?f=../../../etc/passwd
Suppose that get-file is used to view the file called by f= variable, one can try to view the files that are beyond the document folder.
ANALYSIS
Attackers will check for arbitrary file requests that can be made by GET or POST. Manually trying for several locations, it will not take more than 10 tries to reveal or view files located on the server.
SOLUTION
There is no exact solution to this kind of attack but it is always better to harden servers for such kind of attacks. This steps below should be checked to prevent data leaks:
- Be sure that you can’t access the files beyond document root, try to view the files such as /etc/passwd or c:\Windows\win.ini by hardcoding them on a script under the public folder with the specific user privileges
- Apply latest patches for the system and applications. Older versions of scripting languages known to allow path traversal
- Use GET and POST filtering functions provided by the scripting language such as realpath() function offered by PHP.
- Disable unused shell command functions on the script interpreter such as PHP disable_functions directive.
- Restrict access to compilers from web user.
- Remove unused user privileges and user groups from web user.
- Make sure web user doesn’t have execute privileges on publicly writable folders.
- Use WAF
LEGAL
Copyright (c) 2019 – 2026 ONLAYER Bilişim Teknolojileri A.Ş.
Permission is granted for the redistribution of this alert by explicitly linking the page to be referred. It may not be edited in any way without written consent.
Disclaimer: The information in the advisory is believed to be accurate at the time of publishing based on currently available information. Use of the information constitutes acceptance for use in an AS IS condition. There are no warranties concerning this information. Neither the author nor the publisher accepts any liability for any direct, indirect, or consequential loss or damage arising from the use of, or reliance on, this information.