Path Traversal (dir/../filename variant)
Summary
This is CWE-27, "Path Traversal: dir/../../filename", one of a family of MITRE CWE entries that catalog path traversal by the exact character pattern used rather than by a distinct exploitation technique. CWE-23 covers relative traversal generally, while CWE-27 and its siblings (CWE-29 through CWE-31, covering backslash variants and leading-slash variants) exist because some validation logic historically tried to filter path traversal by checking for specific substrings, like a bare ../ at the very start of a string, and could be defeated by a payload that embeds the traversal sequence after a legitimate-looking directory name instead. dir/../../etc/passwd still resolves to the same place ../../etc/passwd does once the filesystem processes the .. segments, but a filter looking only for traversal at the start of the string, or expecting a fixed number of segments, can miss it.
Top Affected Components / Targets
- File-serving or file-inclusion parameters with validation logic that checks the start of the input string rather than resolving the full path
- Legacy or custom-written path-sanitization functions predating well-tested library-based path resolution
Common Attack Vectors
- Where a bare
../../../etc/passwdpayload is rejected or sanitized, retry with a legitimate-looking directory prefix in front of the traversal sequence, since filters keyed on the string's start position or a fixed traversal-segment count can behave differently depending on exactly where the..sequences sit in the string - Combine with different segment counts and a mix of real and fake leading directory names to probe for validation logic with an inconsistent or incomplete traversal check
Common Payloads
dir/../../../etc/passwddir/../../../../windows/win.iniassets/../../../etc/passwdusing a plausible, real-looking directory name as the prefix
Detection Strategy
Where a canonical ../../../etc/passwd-style payload is rejected, this variant is worth testing as a follow-up specifically because it targets validation logic with a different, narrower assumption about where traversal sequences appear in the input. The confirmation signal is the same as any path traversal test: the target file's known content (such as the structure of /etc/passwd or win.ini) appearing in the response.
Tip: Testing tools that run these checks in parallel across every discovered endpoint can cut the time required substantially compared to fully manual testing, as long as they confirm findings with more than one signal to keep the false-positive rate down.
False-Positive Notes
As with any path traversal probe, a response that merely echoes the submitted path back without revealing target file content isn't a confirmed finding; the response needs to contain content genuinely consistent with the requested system file.
How to Test
Manual Testing Methodology
Here is a systematic approach to identifying Path Traversal (dir/../filename variant) vulnerabilities in a target application.
Before testing, map all input vectors that could be affected. Identify parameters, headers, cookies, and request bodies that interact with the vulnerable component. A proxy such as Burp Suite or OWASP ZAP, paired with normal browsing of the target, is usually enough to build this list.
Send a legitimate request and record the normal response: status code, content length, response time, and any identifying tokens. This baseline matters because it's what you'll compare later responses against once payloads are involved.
Inject test payloads into each identified input vector one at a time. Start with benign detection payloads before escalating to anything that could actually trigger the vulnerability. For Path Traversal (dir/../filename variant) specifically, submit ../ sequences of increasing depth (../etc/passwd, ../../etc/passwd, and so on) alongside URL-encoded (%2e%2e%2f), double-encoded, and null-byte variants against every file-path parameter, and try both forward- and back-slash separators since one is sometimes filtered while the other isn't.
Compare the response against your baseline, looking specifically for the actual contents of a known system file (/etc/passwd, win.ini) appearing in the response, or a distinct error message (a different exception type or path echoed back) between a valid relative path and a traversal attempt.
Once a potential vulnerability is detected, confirm it with at least a few independent test cases to rule out coincidence. Document the exact request and response as proof. For Path Traversal (dir/../filename variant), a confirmed finding typically means showing that attacker-controlled input changes the application's behavior in a way that matters for security, not just that a payload was reflected somewhere harmless.
Real-World Impact
Real-World Impact
Path traversal lets attackers read, and sometimes write, files outside the directory an application intended to expose, usually by slipping ../ sequences into a file path parameter. Successful exploitation can expose source code, configuration files containing database credentials and API keys, and system files like /etc/passwd. In write scenarios, it can lead directly to code execution through a planted web shell.
In containerized environments, path traversal can escape an application's own file namespace to read secrets, environment variables, and mounted volumes belonging to other services entirely. In cloud deployments, it can expose provider-specific metadata files too.
This bug class becomes especially dangerous when combined with file inclusion. Reading a file is an information disclosure on its own, but if that file gets executed, the finding becomes remote code execution.
Prevention & Remediation
Prevention and Secure Coding
Preventing Path Traversal (dir/../filename variant) takes a defense-in-depth approach — no single control below is sufficient alone, but together they close off both the primary path and the most common bypasses.
Canonicalize and verify containment. Resolve the requested path to its canonical absolute form and check that it still falls inside an allowlisted base directory before touching the filesystem — check this after resolving symlinks and encoded sequences, not before.
Map to an internal ID, not a raw path. Where feasible, have user input select from a server-side allowlist or database record (an internal file ID) rather than being used as any part of a filesystem path directly.
Reject traversal sequences outright. Reject requests containing ../, .., URL-encoded variants (%2e%2e%2f), and null bytes rather than trying to strip them — stripping is a common source of filter-bypass bugs when done with a single non-recursive replace.
Least-privilege filesystem access. Run the file-serving process under an account with read access to only the directories it legitimately needs, so a traversal that gets past the application-layer check still hits an OS-level permission wall.
Disable directory listing and dangerous parsers. Serve static content through a web server configuration that has autoindexing disabled and doesn't execute uploaded files as scripts.