The scanner says the parameter reads files. What did it observe? Path traversal as a DAST finding: file signatures, echoed payloads, differential responses, where ../ disappears before the application sees it, and how the finding gets confirmed

DedSec Security Research ·

Here is a hypothetical. A dynamic scan of a staging environment returns three findings. The first, titled "Path traversal" and rated high, is on /help/article?name=. The scanner sent ../../../../etc/passwd, and the response contained root:x:0:0:, the first line of a Unix password file. The second is on /reports/download?id=, titled "Possible path traversal" and rated medium. The same payload returned a 400 with the message "Invalid file type for /srv/app/reports/../../../../etc/passwd", while ordinary report IDs returned 200. The third is on /assets/ itself, with the payload in the path rather than in a parameter. %2e%2e%2f sequences in the path returned the password file from staging. The same request against production got a 400 page from the reverse proxy, so the finding was marked "not reproducible in production".

The first finding is triaged as critical, because the file came back. The second is downgraded to informational, because an error message is not a file. The third is closed, because production sits behind the proxy. All three calls are probably wrong, and for the same reason as in the earlier posts in this series. Each one rests on the finding's title rather than on what the scanner observed and what that observation can prove.

This post is for whoever is holding a path traversal finding from a dynamic scan. It covers what path traversal is and how it differs from file inclusion and arbitrary file write, where ../ gets removed before the application ever sees it, which encodings survive which layers, why joining a path and then opening it is unsafe in Python and Node.js and what the correct check looks like, what each kind of DAST evidence proves and how each produces false positives and false negatives, how to confirm a finding by hand without reading anything you should not, and what the static analysis side of the same bug looks like. It is the sixth post in a series about confirming DAST findings, after reflected XSS, SQL injection, OS command injection, Nuclei template matches and ffuf content discovery. The Nuclei post includes a path traversal template fooled by a WAF block page, which is one case of the wider problem this post covers.

Sources, and how each was checked. Every passage quoted verbatim below was read on our test machine on 31 October 2026: the docstrings of os.path.join, os.path.realpath, pathlib.Path.resolve, PurePath.is_relative_to and html.escape, as printed by Python's help(); the source of SimpleHTTPRequestHandler.translate_path in Python's http.server module, read with the inspect module; the curl 8.5.0 manual page; and the openat2(2) manual page shipped with Ubuntu. CWE-22 (path traversal), CWE-98 (file inclusion in PHP) and RFC 3986 section 5.2.4 (the algorithm for removing dot segments) are cited by number and described in our own words, because we had no copy on the machine to quote from. The measurements were made the same day in a scratch directory on an Ubuntu 24.04 machine, inside a Linux network namespace that had only a loopback interface, with curl 8.5.0, Python 3.12.3, Node.js 22.22.2 and nginx 1.24.0. We wrote two deliberately vulnerable test servers, one with Python's http.server module and one with Node.js's http module, and put nginx in front of the Python one for the proxy tests. Nothing outside 127.0.0.1 was contacted. PHP, Java, Windows, web browsers, containers and application frameworks such as Flask or Express were not available, so where this post discusses them it says so and does not report a measurement. The opening scenario is hypothetical, and no number in this post measures any scanner, ours included.

Three bugs that share a payload

CWE-22 covers software that builds a filesystem path from outside input, intends that path to stay under a restricted directory, and does not neutralise the parts of the input that move it somewhere else. The usual culprits are .. segments and absolute paths. The weakness is in how the path is built. The impact depends on what the program then does with the path, and three different bugs share the same payloads.

The fix differs by class. For a read, the fix is a containment check, covered below, plus least privilege for the process. For an inclusion, the fix is to never include a path the user chose: map an identifier to a fixed list of templates or modules. For a write, generate the stored filename on the server, and for archives resolve and check every entry's destination before writing it. The severity spans the same range, from information disclosure to remote code execution, under one CWE number. A finding titled "path traversal" that does not say which sink it reached has a severity that is a guess.

Where ../ disappears before the application sees it

A dynamic scanner sees requests and responses. The first thing to establish about a path traversal finding, or about a clean result, is whether the request the application received was the request the scanner meant to send. Dot segments are part of URL syntax. RFC 3986 section 5.2.4 defines an algorithm that removes . and .. segments from the path when a relative reference is resolved. Some clients and intermediaries apply the same idea to the path of a URL before sending or forwarding it, and others do not, as the results below show. The query component is not a path to any of them. That is why a traversal in a path segment and a traversal in a query parameter behave differently in testing, and why the third hypothetical finding behaved differently in staging and production.

Our Python test server logged the raw request target of every request. These are the results for each client.

Node.js's URL class implements the WHATWG URL Standard, which browsers also follow. So a browser, or a scanner that drives one, probably behaves like fetch here. We had no browser on the machine and did not measure one.

The consequence for testing showed up on our deliberately vulnerable /static/ route, which takes the rest of the path, percent-decodes it and joins it to the files directory. Sent by curl with default settings, /static/../../../../etc/passwd arrived as /etc/passwd, which matched no route, and the server answered 404. That is a clean-looking result against a route that is vulnerable. With --path-as-is, the same request returned the password file. So did %2e%2e%2f and ..%2f without the switch, because the application decoded the path after routing it. A "not vulnerable" result for a path-segment test says as much about the scanner's HTTP client as about the application. If the client normalises, the payload never left the building.

The reverse proxy

We put nginx 1.24.0 in front of the Python server and configured proxy_pass in its two common forms.

proxy_pass without a URI part, as in location /static/ { proxy_pass http://127.0.0.1:8100; }. A request whose path stayed at or below the root after normalisation was forwarded exactly as the client sent it: /raw/a/../b reached the application as /raw/a/../b. A request whose path climbed above the root got 400 Bad Request from nginx and never reached the application. That held for literal ../, for %2e%2e%2f and for ..%2f alike, so nginx decoded the path before deciding.

nginx chose the route by the normalised path and forwarded the original. /raw/../static/report.txt, sent with --path-as-is, normalises to /static/report.txt, and nginx handled it in the /static/ location. It forwarded the original /raw/../static/report.txt, and the application routed that to its /raw handler. The proxy and the application disagreed about which route the request was for. This was not a file read, but if access control is enforced per location at the proxy, a disagreement of this kind is a finding in its own right.

proxy_pass with a URI part, as in proxy_pass http://127.0.0.1:8100/raw/;. nginx forwarded the normalised and re-encoded path. /assets/x/..%2fy, /assets/x/%2e%2e%2fy and literal /assets/x/../y all reached the application as /raw/y. The double-encoded %252e%252e%252f was forwarded still double-encoded, the application decoded it once to %2e%2e%2f, and nothing escaped. An application that decodes twice would have walked out of its directory.

A query parameter, /raw/?file=../../etc/passwd, passed through nginx unchanged in every configuration we tried.

That is the third hypothetical finding. A 400 from the proxy says that nginx, configured as it is today, refused a path that climbed above the root. The application code is the same in both environments. It is still vulnerable to any request that reaches it without passing that check: an internal caller, a second ingress, a change to the proxy configuration, a route that moves the value into a query parameter, or a layer that decodes twice. The proxy is a mitigation for one form of the input. Record it as one, and fix the code.

Framework routers add another layer between the proxy and the handler. We did not measure any, because no web framework was installed on the test machine. In general, a route parameter that matches a single path segment cannot capture a slash, so ../../etc/passwd never reaches it as one value, while a catch-all or wildcard parameter usually can. Whether the router decodes %2f before or after matching is framework-specific. Check the documentation for yours, and test the deployed route rather than assuming.

Encodings, and which layer decodes them

Each encoding in a traversal payload list is a bet that one layer checks the input and a different layer decodes it. These are the ones we measured, against routes that read a query parameter.

Depth works asymmetrically. On a POSIX system, .. at the root stays at the root, so too many is harmless: os.path.normpath turned /var/app/files/../../../../../../etc/passwd into /etc/passwd, and nine ../ against our files directory, which is four levels below the root, returned the file. Too few fails: three returned 404. That is why scanners send long runs of ../, and why a 404 for a short payload is not a negative result.

Why "join, then open" is unsafe

Most traversal bugs are a join followed by an open, with nothing in between. The standard libraries make that easy to get wrong in different ways.

Python. The os.path.join docstring states the rule: "If any component is an absolute path, all previous path components will be discarded." os.path.join('/var/app/files', '/etc/passwd') returned /etc/passwd. The pathlib operator behaves the same: Path('/var/app/files') / '/etc/passwd' returned /etc/passwd. That is why our /download route served the file for an absolute path with no ../ in it.

Node.js. path.join does the opposite. path.join('/var/app/files', '/etc/passwd') returned /var/app/files/etc/passwd, because join concatenates and then normalises. path.resolve treats an absolute argument the way Python's join does, and returned /etc/passwd. Both of them resolve .. segments: path.join('/var/app/files', '../../../etc/passwd') returned /etc/passwd. On our Node.js test route, which reads path.join(BASE, file), ../../../../etc/passwd returned the file and /etc/passwd returned 404. A reviewer who learned the bug on Python and checks Node.js code for absolute paths is looking for the wrong bug.

String normalisation and the kernel give different answers. Opening files/nosuchdir/../report.txt returned 404 on our /download route, because the kernel walks the path one component at a time and fails at the directory that does not exist. os.path.normpath would have removed nosuchdir/.. as text and found the file. A check that runs on a normalised string while the open runs on the raw string is checking a different path from the one that gets opened. The difference is also useful during confirmation, as described below.

The check that works

  1. Resolve the path, following symlinks. Python's os.path.realpath is documented to "Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path." pathlib's resolve says it will "Make the path absolute, resolving all symlinks on the way and also normalizing it." In Node.js, fs.realpathSync does this: given link/hostname under our files directory, it returned /etc/hostname. Resolve the base directory the same way.
  2. Check containment by path components, not by string prefix. In Python, os.path.commonpath([base, full]) == base. In Node.js, path.relative(base, full) must not start with .. and must not be absolute. For the resolved symlink above it returned ../../../../etc/hostname, which that test rejects. (A stricter version compares the first component with .. exactly, so that a file legitimately named ..data is not refused.)
  3. Open the path you checked, not the original input.

Our /safe route does exactly this. It served report.txt and refused the password file, a sibling directory and a symlink. The routes that got one step wrong failed in measurable ways.

The best fix is not to accept a path. Accept an identifier, look up the file it maps to on the server, and the user never supplies a string that reaches the filesystem. Python's own static file server takes a third approach, working on the URL rather than on the filesystem. translate_path in http.server decodes the URL path and runs posixpath.normpath over it, so .. is resolved inside the URL, where it cannot climb above /. It then skips any component that is still . or .. or contains a directory part, under the comment "Ignore components that are not a simple file/directory name", and joins what is left onto the served directory. Its docstring says "Components that mean special things to the local file system (e.g. drive or directory names) are ignored." With /srv/www as the directory, /../../etc/passwd, /a/%2e%2e/%2e%2e/etc/passwd and /..%2f..%2fetc/passwd all became /srv/www/etc/passwd, inside the served directory. Backslashes were left as part of a filename, which is safe on Linux and is exactly the platform assumption the previous section warned about.

What each kind of DAST evidence proves

A dynamic scanner infers a file read from the response. Four kinds of observation come up, and they are not equally strong.

File content signatures

The strongest evidence is content in the response that has the structure of the target file and that the request did not contain. root:x:0:0: is the start of the first line of a Unix /etc/passwd file. The request contains the text "etc/passwd", but not that structure, so neither a reflection of the payload nor a block page that echoes the URL can produce it. On Windows targets, scanners commonly look for the [fonts] section header of win.ini. We had no Windows host and did not measure that.

A signature shows that the response contains text with that structure. It does not show where the text came from. Our /basename route takes the last component of the parameter and serves that file from its own directory, and the directory contains a help article called passwd with a sample /etc/passwd line in it. file=../../../../etc/passwd returned 200 and root:x:0:0:. file=passwd, with no traversal at all, returned the identical 104 bytes, and file=../../../../etc/hostname returned 404. The application served its own file, which happened to match the signature. Documentation pages, tutorials, code browsers and log viewers can all contain the signature legitimately.

Where the file came from also matters for severity. In a container, /etc/passwd is the image's copy. Reading it proves that the path left the application's directory, not that it left the container. That does not make the finding minor. An application container usually holds what the application needs: its source, its configuration files, mounted secrets, and in Kubernetes typically a service account token under /var/run/secrets/kubernetes.io/serviceaccount/. /proc/self/environ exposes the process's environment variables, which often hold credentials. Severity follows from what that process can read, so establish that from the deployment, not by reading those files during the test. None of this was measured here.

The payload came back

Three of our routes returned the payload without reading anything. The /echo route answered 404 with File not found: ../../../../etc/passwd. The /waf route answered 403 with Request blocked by policy: /waf?file=../../../../etc/passwd. The /errleak route checks the extension and never opens anything, and answered 400 with Invalid file type for followed by the full joined path, .../app/files/../../../../etc/passwd. A matcher that looks for the word etc/passwd fires on all three. A matcher that looks for root:x:0:0: fires on none. The Nuclei post measured the same split from the template side.

The error message deserves a second look, not because it shows a file read, which it does not, but for two other reasons. It is a separate finding, a disclosure of the server's directory layout. And it is useful for confirmation: it gives the base directory and its depth, which is what depth probing and the out-and-back test below need. In the second hypothetical finding, the message also showed that the path was joined without being normalised, which is the code shape of the bug.

Differential responses

When the file's content never comes back, the evidence is a difference between responses. Our /blind route opens the file, discards the content and answers processed. ../../../../etc/passwd returned 200, and a random name in the same directory, ../../../../etc/qz8Rk2vT, returned 404. The route is an existence oracle: the path left the base directory and the kernel looked for the file. That is a real traversal, and its impact depends on what the application does with the content it read. A file that is parsed, rendered into a document or used as configuration can do more than a file that is only checked for existence.

Differentials also produce false positives. Our /spa route returns the same 124-byte HTML shell for every path, as a single-page application's server does, so a traversal payload and a random path got identical 200s. Any status-only signal on such a route is noise. A WAF that blocks ../ produces a 403-versus-200 difference that is caused by the WAF. And in Python and Node.js, a %00 payload produces a 500 that is caused by the runtime refusing a NUL character.

The strongest differentials are pairs of requests that should give identical answers only if the application resolved ... On our /download route, report.txt and ../files/report.txt, which goes up out of the files directory and back into it, returned identical 44-byte bodies. That proves traversal without reading anything outside the application's own directory. nosuchdir/../report.txt returned 404, because the kernel resolved the missing directory. On the /basename route, the same request returned the report, because basename threw everything else away. Three requests distinguish three mechanisms.

False negatives

A scan that reports no traversal has only shown that its observations did not match. These are the ways a real traversal stayed hidden in our lab, plus some we did not measure.

Confirming a finding by hand

A path traversal test reads files on someone's server. The procedure below is general practice, the measurements behind each step come from our lab, and it belongs on staging wherever possible. The aim is to prove that the path left its directory while reading as little as possible.

  1. Replay with a client that sends the path raw. curl --path-as-is for path segments, and the same method, headers and Host as the scan. If you can see the server's access log, check what arrived.
  2. Take a baseline. A random filename in the same parameter, and a known file inside the root if you can find one. Our routes answered 404 and 200, and each later result is compared with these two.
  3. Send the last component alone. If name=passwd returns the same body as name=../../../../etc/passwd, the application is looking up names, not resolving paths, as our /basename route did.
  4. Go out and back in. ../<directory name>/<known file> should return exactly what the known file returns if the application resolves ... The directory name often comes from an error message, a URL or the application's documentation. This is the cleanest proof, because everything it reads was already public.
  5. Tell textual normalisation from kernel resolution. nosuchdir/../<known file> returns the file if the application normalises the string first, and fails if the kernel resolves the path. This tells you where to look in the code.
  6. Probe depth with a known, non-sensitive target. Add ../ one at a time until a file you know is outside the root appears. The first count that works gives the depth, and every larger count also works on POSIX systems.
  7. Read something you know must differ. On staging, put a file outside the root containing a random token, and read it. Its content can only come back through a traversal, which makes it the strongest evidence available. Without one, choose a file whose structure is predictable and whose content is not sensitive, such as /etc/os-release, whose lines take the form NAME= and VERSION_ID=. Do not read credentials, private keys, /proc/self/environ or anything under a secrets mount to prove the point. Their existence is part of the severity argument, and reading them turns a test into an incident.
  8. Try the encodings in order, literal, %2e%2e%2f, ..%2f, then %252e%252e%252f, and note which layer each one got past. A double-encoded hit means some layer decodes twice.
  9. Find the sink in the code. Read, include or write. The response cannot tell you which, and the severity depends on it.
  10. Establish what the process can reach. Its user, whether it runs in a container, what is mounted and what is in its environment, from the deployment configuration.
  11. Keep the evidence. The exact requests, the raw request target as received, the responses and the baselines, so the fix can be retested the same way.

The static side: sanitisers for the wrong sink

Static analysis models the same bug as taint. A request value is the source. open, readFile, sendFile, include or a template loader is the sink. A sanitiser is any transformation that makes the value safe for that particular sink. The SAST false positive post covers how this goes wrong in general, and the reachability post makes the point that a sanitiser only counts for a specific sink class. Path traversal shows this clearly.

A confirmed DAST finding tells you that a reachable request read a file outside a directory. It cannot tell you which line built the path. A SAST finding tells you that request data reaches a file sink without a containment check. It cannot tell you whether a deployed route sends it there, or whether a proxy in front refuses the path form. Each one answers the other's open question.

A triage checklist for a DAST path traversal finding

  1. Identify the evidence class. File content signature, echoed payload, differential response or error message. Each is a different strength of evidence.
  2. For a signature, check where the content came from. Send the last component alone and request a different file outside the root. An identical response to the bare name means the application served its own file.
  3. For an echoed payload, check whether a file was read at all. A word matcher on etc/passwd is satisfied by error messages and block pages. Treat a path in an error message as a separate disclosure finding, and use it.
  4. For a differential, rule out the shell and the filter. Single-page application shells, WAF blocks and runtime errors on %00 all produce differences with no file read behind them.
  5. Check whether the payload arrived as sent. Path-segment payloads are normalised by curl's default and by fetch. Replay with --path-as-is, and check the access log where you can.
  6. Name what sits in front. A proxy that refuses paths above the root, or forwards a normalised path, is a mitigation for the path form only. The code is still vulnerable to every other route in.
  7. Record the encoding that worked, and which layer it got past. A double-encoded hit means a layer decodes twice.
  8. Confirm with the least intrusive proof. Out and back in, then a planted canary on staging, then a predictable non-sensitive file. Do not read secrets to prove the point.
  9. Find the sink. Read, include or write. The same payload reaches all three, and the severity differs.
  10. Find the join. Python's join and pathlib discard the base for an absolute path. Node.js's join resolves .., and its resolve discards the base for an absolute path.
  11. Check the containment logic. Resolved with realpath, compared by components rather than by string prefix, with symlinks considered, and the checked path is the one that gets opened.
  12. Establish what the process can reach, including the container's mounts, environment and tokens, from the deployment rather than from the test.
  13. Fix by class. For a read, map identifiers to files, or resolve and check containment. For an include, never include a user-chosen path. For a write, generate the filename on the server.
  14. Retest with the evidence that raised the finding, using the same client settings, and confirm that the scanner reached the application rather than a block page or a proxy error. The scan-passed post covers how that goes wrong.

The hypothetical findings, resolved

Back to the three hypothetical findings.

In the scenario, the /help/article?name= signature was the application's own file. name=passwd returned the identical body, and ../../../../etc/hostname returned 404. The handler took the basename of the parameter and served it from a flat, read-only directory of help articles, one of which explained the format of the Unix password file, with an example line. The matcher was right about the structure and wrong about its origin. The finding was closed as a false positive, with the three requests attached, and a note that basename was a valid sanitiser for that sink only because the directory was flat.

In the scenario, the /reports/download?id= error message was the real finding. It showed the base directory, and that the path was joined without normalisation before an extension check that accepted only .pdf. On staging, a canary file named canary.pdf, placed outside the reports directory, came back through ../../../../tmp/canary.pdf. Reports for each tenant were stored in sibling directories, so ../<other tenant>/<report>.pdf read another tenant's reports. The finding went from informational to high, as a cross-tenant read limited to PDF files. The path disclosure was filed separately at low severity. The fix maps report IDs to files on the server.

In the scenario, the /assets/ finding was real, and production was mitigated, not fixed. The staging environment had no proxy. In production, nginx refused paths that climbed above the root, and the application code behind it was identical. Further testing found no way through the production proxy, but the code was fixed anyway, with a realpath and component containment check, because the protection depended on one location block's configuration and on every caller reaching the application through it. The finding stayed open, recorded as mitigated, until the fix shipped and the original requests were replayed with --path-as-is against staging.

Where AppSecD fits

AppSecD's dynamic and API testing runs Nuclei, Dalfox, SQLMap, Commix, Katana, Arjun, FFuf and Interactsh for out-of-band detection, plus more than 150 native checks and API discovery across more than 50 web frameworks. In its lifecycle this is the runtime stage: DAST and API testing run against the deployed application, because code review cannot see what only appears once the application is assembled and running. Its static analysis includes dataflow taint analysis that traces source to sink across functions. Its findings are deduplicated across scans and tracked through new, reopened and fixed states, and its lifecycle supports maker-checker approval, so a finding marked as a false positive can require a second person to confirm it.

That is the whole claim. This post does not claim whether AppSecD has a dedicated path traversal check, which payloads, encodings, depths, target files or content signatures it uses, whether its HTTP client sends dot segments raw or normalised, whether it tests path segments as well as parameters, how it distinguishes a file signature from an echoed payload or a differential, whether it tests for file inclusion or file write, how it rates the severity of a traversal finding, whether its static rules treat basename, realpath, normalisation or HTML escaping as sanitisers for file sinks, or how accurate its path traversal detection is. The measurements, the confirmation procedure and the checklist above are general practice, not a description of how AppSecD works internally, and they apply to any scanner's output, ours included. The scenario in this post is hypothetical and does not describe any AppSecD deployment, user or finding.

More about AppSecD · All posts