Home > Security Tips > Threat Monitor > Protect your Web site against path traversal attacks
Security Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

THREAT MONITOR

Protect your Web site against path traversal attacks


Michael Cobb
10.19.2005
Rating: -4.75- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Web servers generally are set up to restrict public access to a specific portion of the Web server's file system, typically called the "Web document root" directory. This directory contains the files intended for public access and any scripts necessary to provide Web application functionality. In a path traversal attack, an intruder manipulates a URL in such a way that the Web server executes or reveals the contents of a file anywhere on the server, including those lying outside the document root directory. Path traversal attacks take advantage of special-characters sequences in URL input parameters, cookies and HTTP request header.

The most basic path traversal attack uses the "../" character sequence to alter the document or resource location requested in a URL. Although most Web servers prevent this method from escaping the web document root, alternate encodings of the "../" sequence, such as Unicode-encoding, can bypass basic security filters. Even if a Web server properly restricts path traversal attempts in the URL path, any application that exposes an HTTP-based interface is also potentially vulnerable to such attacks. For example, look at the two URLs below:

Correct URL:
http://www.yourserver.com/scripts/database.cgi?report=quarter1.txt

Attack URL:
http://www.yourserver.com/scripts/database.cgi?page=../scripts/ database.cgi%00txt

This attack URL forces the CGI application to reveal the source code of the database.cgi file because the file is interpreted as text instead of an executable script. The attacker uses the "../" special-character sequence to traverse one directory above the current directory and enter the /scripts directory. The "%00" sequence is used both to bypass a simple file extension check and to cut off the extension when the file is read and processed by the CGI application. This example highlights the critical importance of always checking and cleaning any user-supplied input before allowing it



to be processed by a Web server or Web applications.

You should, of course, apply the most recent security patches to your system and monitor security announcements and patch releases for any applications that run on your Web server. For example, some versions of PHP contain a bug that enables an attacker to perform directory traversal by manipulating the file name of an uploaded file, so make sure you have the relevant patches applied.

Because traversal attacks allow an attacker to execute operating system programs and tools, you should always locate Web root directories and virtual directories on a non-system partition. It's not possible to traverse across drives. For example, if your system is installed on the C: drive, consider moving your site and content directory to the E: drive, ensuring that all virtual directories point to the new drive. For a Windows-based Web site this means never using the default \Inetpub\wwwroot directory for the location of Web site content. This tactic also ensures that any future canonicalization worm that allows an attacker to access system files will fail.

The easiest way to tighten an IIS Web server against this and other attacks is to download and run the IISLockdown tool, free from http://download.microsoft.com. URLScan, which is installed when you run IISLockdown, blocks requests that contain unsafe characters. IISLockdown also disables the parent paths setting, which prevents the use of ".." in script and application calls. Finally, IIS Web administrators should check all Web permissions, which provide an extra layer of security to NTFS file permissions, and consider upgrading to IIS 6.0, which provides significantly enhanced default security over previous versions of IIS.

About the author
Michael Cobb, CISSP-ISSAP, is the founder and managing director of Cobweb Applications Ltd., a consultancy that offers IT training and support in data security and analysis. He co-authored the book IIS Security and has written numerous technical articles for leading IT publications. Mike is the guest instructor for SearchSecurity's Web Security School and, as a SearchSecurity.com site expert, answers user questions on application and platform security.


Rate this Tip
To rate tips, you must be a member of SearchSecurity.com.
Register now to start rating these tips. Log in if you are already a member.




BROWSE BY TAG
Threat Monitor,   Application and Platform Security,   Application Attacks (Buffer Overflows, Cross-Site Scripting),   Web Security Tools and Best Practices,   Web Server Threats and Countermeasures,   Web Application and Web 2.0 Threats,   VIEW ALL TAGS

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Threat Monitor
When BIOS updates become malware attacks
Mac OS memory flaws pose challenges for enterprise endpoint protection
Cybercrime and threat management
How to find and stop automated SQL injection attacks
Short-lived Web malware: Fading fad or future trend?
Security book chapter: The Truth About Identity Theft
How to use (almost) free tools to find sensitive data
How to block adult websites from enterprise users by logging content
Are Windows Vista security features up to par?
How to defend against data-pilfering attacks

Application Attacks (Buffer Overflows, Cross-Site Scripting)
Month of Twitter Bugs project to document Twitter flaws
Adobe issues first quarterly patch release fixing 13 flaws
Balancing security and performance: Protecting layer 7 on the network
Adobe issues Reader update fixing zero-day flaw
The Pipe Dream of No More Free Bugs
Security Squad: Federal cybersecurity defenses
Oracle issues 43 updates, fixes serious database flaws
Attackers target new Microsoft PowerPoint zero-day flaw
How to detect input validation errors and vulnerabilities
Vulnerability test methods for application security assessments
Application Attacks (Buffer Overflows, Cross-Site Scripting) Research

Web Server Threats and Countermeasures
Stolen FTP credentials likely in massive website attacks
Microsoft warns of IIS zero-day vulnerability
How to find and stop automated SQL injection attacks
How to spot attacks through Apache Web server log analysis
Symantec acquires Mi5 Networks, bolsters Web security
How to harden Linux operating systems
How to clear out anonymous Web proxy servers in the workplace
Information security book excerpts and reviews
Is it more secure to have a mainframe or a collection of servers?
How does a Web server model differ from an application server model?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
buffer overflow  (SearchSecurity.com)
cache poisoning  (SearchSecurity.com)
cyberterrorism  (SearchSecurity.com)
dictionary attack  (SearchSecurity.com)
directory harvest attack  (SearchSecurity.com)
distributed denial-of-service attack  (SearchSecurity.com)
JavaScript hijacking  (SearchSecurity.com)
ping of death  (SearchSecurity.com)
stack smashing  (SearchSecurity.com)
SYN flooding  (SearchSecurity.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Research Solutions for Network Security, Access Control and Security Threats
More Security Resources for Resellers, VARs and OEMs
TechTarget Security Media
Information Security View this month\\'s issue and subscribe today.
Information Security Decisions Apply online for free conference admission.
SearchSecurity.com
HomeNewsMagazineMultimediaWhite PapersLearningAdviceTopicsEventsAbout Us

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts