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

MORE INFORMATION

Learn how to secure your Web site in Web Security School with guest instructor Michael Cobb

Submit your Web security questions to Michael Cobb in our Ask the Expert feature

Visit our resource center for more tips and advice on preventing Web threats

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.




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


RELATED CONTENT
Threat Monitor
Tracing malware's steps with RE:Trace
Worst practices: Learning from bad security tips
Worst practices: Encryption conniptions
Stopping malware in its tracks
Built-in Windows commands to determine if a system has been hacked
Exploit research: Keeping tabs on the hacker underground
Data loss prevention from the inside out
Enterprise security in 2008: Malware trends suggest new twists on old tricks
Thinking fast-flux: New bait for advanced phishing tactics
Lessons learned from TJX: Best practices for enterprise wireless encryption

Application Attacks (Buffer Overflows, Cross-Site Scripting)
Yahoo, McAfee to warn users of dangerous websites
Botnets and ethics
SQL injection attack infects hundreds of thousands of websites
HP customers vulnerable to software update tool flaw
New hacking technique exploits common NULL programming error
What are the dangers of cross-site request forgery attacks (CSRF)?
Stopping malware in its tracks
Shrewd attackers bypass old security defenses with Web attacks
What software development best practices can prevent input validation attacks?
What is the most secure way for application developers to manage cookies?
Application Attacks (Buffer Overflows, Cross-Site Scripting) Research

IIS Security
Trend Micro site compromised
What server considerations should be made when setting up an internal network's private applications?
IT discussion: Is malware the cause of a DNS server error?
Insider's guide to IIS Web server security
Microsoft July updates for critical Excel, Windows and .NET flaws
Finding and blocking Web application server attack vectors
What's the best way to verify client authentication across unrelated Web servers?
Microsoft to release DNS patch Tuesday
DNS worm strikes at Microsoft flaw
How to implement IIS authentication settings
IIS Security Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
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)
script kiddy  (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.

TechTarget Security Media
Information Security View this month\\'s issue and subscribe today.
Information Security Decisions Apply online for free conference admission.
SearchSecurity.com
HomeNewsMagazineWebcastsWhite PapersLearningAdviceTopicsEventsAbout Us

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

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




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