From the course: CompTIA Security+ (SY0-701) Cert Prep
Defending against directory traversal
From the course: CompTIA Security+ (SY0-701) Cert Prep
Defending against directory traversal
- [Instructor] Directory traversal attacks are another common web application security flaw. These attacks allow the attacker to manipulate the file system structure on the web server. Let's first talk about two important characteristics of file systems. When using a Linux file system, a single period references the current directory, and using two periods references the directory one level up in the hierarchy. A directory traversal attack uses these navigation references to try to move up and down the directory structure searching for unsecured files. These attacks work when an application allows a user to request files stored elsewhere on the file system. We're going to try one of these attacks using a tool called WebGoat. But first, here's a look at the file system that we'll be using in this exercise to help you understand what's happening in the demo. The ThreadSafetyProblem.html file is the one that we're actually supposed to get with the web application. The tomcat-users.xml file is the one that we want to get our hands on. Now, we're currently in the en end directory, so we need to go up four levels to the .extract directory, and then from there, go down into the conf directory and access the target file. Let's try a demo. We're going to use the WebGoat application again. This time, we also need to use another application called ZAP. ZAP is a web proxy that intercepts web requests and lets us modify them. We'll use it to modify a file request to include a directory traversal attack. Here in WebGoat, you can see we have some lesson plans that we can review. Normally, we just click on a file name and click View File. Scroll down and see the contents of the file that the application intends to display. Now I'm going to try that again, but before I do, I'm going to go into ZAP and tell it to intercept the request before it's sent to the web server. This time, when I click View File, WebGoat stops the request and I can go in and edit the file name that's being requested before it's sent to the server. I'm going to change this to the path that we built together a moment ago, four sets of two periods, followed by the name of the conf directory and the tomcat-users.xml file. Then I'm going to go ahead and let the request go. If I now return to the web browser and scroll down, you'll see that instead of the ThreadSafetyProblem lesson plan, I now have the contents of the tomcat-users file from the elsewhere on the web server. Directory traversal attacks are dangerous because they allow attackers to bypass normal access controls and view sensitive files stored on a web server. There are two ways you can defend your applications against directory traversal attacks. First, you can use input validation to prevent the inclusion of periods in user requests. Second, you can set strict file system access controls to limit the web server user's ability to read sensitive files.
Download courses and learn on the go
Watch courses on your mobile device without an internet connection. Download courses using your iOS or Android LinkedIn Learning app.
Contents
-
-
The goals of information security2m 11s
-
Authentication, authorization, and accounting (AAA)3m 31s
-
Categorizing security controls5m 11s
-
Conducting a gap analysis2m 34s
-
Zero Trust5m 32s
-
Physical access control4m 40s
-
Physical security personnel2m 12s
-
Deception technologies2m 55s
-
Change management6m 2s
-
-
-
Trust models2m 52s
-
PKI and digital certificates4m 5s
-
Hash functions7m 38s
-
Digital signatures3m 50s
-
Digital signature standard1m 27s
-
Create a digital certificate4m 55s
-
Revoke a digital certificate1m 28s
-
Certificate stapling2m 29s
-
Certificate authorities6m 13s
-
Certificate subjects3m 35s
-
Certificate types2m 55s
-
Certificate formats2m 30s
-
-
-
Preventing SQL injection4m 25s
-
Understanding cross-site scripting3m 17s
-
Request forgery4m 8s
-
Overflow attacks3m 21s
-
Explaining cookies and attachments4m 7s
-
Session hijacking4m 8s
-
Code execution attacks2m 43s
-
Privilege escalation1m 56s
-
OWASP Top Ten4m 45s
-
Application security4m 3s
-
Defending against directory traversal3m 4s
-
Race condition vulnerabilities2m 13s
-
-
-
Restricting network access2m 8s
-
Network access control4m 30s
-
Router configuration security4m 5s
-
Switch configuration security3m 42s
-
Maintaining network availability2m 32s
-
Network monitoring3m 41s
-
SNMP2m 54s
-
Isolating sensitive systems2m
-
Zero trust networking4m 9s
-
Secure access service edge (SASE)3m 50s
-
-
-
Operating system security8m 44s
-
Malware prevention7m 25s
-
Application management3m 46s
-
Host-based network security controls7m 44s
-
File integrity monitoring4m 9s
-
Data loss prevention5m 17s
-
Data encryption5m 39s
-
Hardware and firmware security5m 24s
-
Linux file permissions4m 2s
-
Web content filtering1m 47s
-
-
-
What is vulnerability management?5m 2s
-
Identify scan targets4m 24s
-
Scan configuration5m 20s
-
Scan perspective4m 24s
-
Security Content Automation Protocol (SCAP)2m 27s
-
Common Vulnerability Scoring System (CVSS )3m 31s
-
Analyzing scan reports4m 37s
-
Correlating scan results2m 20s
-
Vulnerability response and remediation2m 14s
-
-
-
Authentication factors3m 26s
-
Multifactor authentication2m 17s
-
Something you have4m 24s
-
Password policy4m 19s
-
Password managers2m 3s
-
Passwordless authentication3m 23s
-
Single sign-on and federation3m 9s
-
Kerberos and LDAP5m 18s
-
SAML2m 35s
-
OAUTH and OpenID Connect2m 55s
-
Certificate-based authentication5m 25s
-