Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
Path traversal lets an attacker read or write files outside the directory an application intended, usually by inserting relative path sequences into a filename parameter.

What Is Path Traversal?
Path traversal, also called directory traversal and tracked as CWE-22, is the oldest trick in web security that still works. An application takes a filename from a request and uses it to build a path. The attacker includes ../ sequences, the path resolves somewhere else on the filesystem, and files the application never meant to expose are returned to the browser.
Most attempts to fix this with string matching are defeated within an afternoon. Developers strip ../, so attackers send ....//, which becomes ../ after a single non-recursive replacement. Percent-encoding gives %2e%2e%2f, double encoding gives %252e%252e%252f, and on systems that decode UTF-8 loosely, overlong sequences have historically produced the same result. Windows accepts backslashes as well as forward slashes and ignores trailing dots and spaces. Absolute paths skip the question altogether where the application concatenates without checking.
Nor does a filename have to come from a URL. Archive extraction is a recurring source: an entry inside a zip file whose name contains traversal sequences writes outside the extraction directory when unpacked, a pattern named Zip Slip and found in libraries across every major language. Upload filenames, email attachment names, and values read from a database all reach the same code.
Both illustrate the same point: these are not only application bugs. Web servers, build systems, and file transfer products handle paths constantly, and a traversal in one of them usually reaches credentials before it reaches anything else.
On Linux, /etc/passwd confirms the vulnerability and is rarely the objective. The targets that matter are application configuration files holding database credentials and API keys, .env files, private keys under a user’s SSH directory, cloud credential files, and source code that reveals further weaknesses. On Windows, the equivalents are web.config, unattended installation answer files, and the SAM database. Where the application writes rather than reads, traversal becomes file upload to an arbitrary location, which generally means a web shell.
Traversal attempts are noisy in logs, and alerting on encoded dot sequences in request parameters catches opportunistic scanning. The more valuable signal is behavioural: a web process opening files outside its content directory is a strong indicator, and file integrity monitoring on configuration directories detects the write variant. For testing, every parameter that could reach a file operation deserves a set of encoded probes, as described for file upload vulnerabilities and file inclusion. Our web application security testing covers both read and write paths, including archive handling.
Both start with user input influencing a file path. Traversal reads the file and returns its contents, so the impact is disclosure of configuration, credentials, or source code. File inclusion passes the file to an interpreter, so the contents are executed. An application with inclusion is usually one step from code execution; one with traversal is usually one step from credentials.
No. A single non-recursive replacement is defeated by nested sequences that reassemble after substitution, and the filter never sees percent-encoded, double-encoded, or backslash variants. Validation also runs against the raw string rather than the path the operating system will resolve. Canonicalise the full path first, then verify it sits inside the permitted directory.
Frequently, through two routes. If the vulnerable operation writes rather than reads, an attacker places a script in a directory the web server executes. If it only reads, the stolen material, such as SSH keys, cloud credentials, or an application secret, usually provides access elsewhere. Apache CVE-2021-41773 reached execution directly where CGI scripts were enabled.
It limits the blast radius rather than preventing the flaw. A container restricts the attacker to that filesystem, which is a genuine improvement, but application configuration, mounted secrets, service account tokens, and environment variables all live inside it and are usually the objective. Treat isolation as containment and fix the path handling itself.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.