Read a sample: 1. The File Path Testing Mindset
A web application can make a file available with an ordinary-looking request. A user chooses a document, the browser sends an identifier, and the application returns the appropriate content. Behind that simple interaction, however, the application must decide which file to open, whose permissions apply, and whether the selected file is part of the intended feature.
Those decisions form the subject of this book. File path testing examines what happens when an application uses request data to locate or select a file. Sometimes the application treats an external value as a path more directly than its designers intended. Sometimes it chooses a file to include in a page or another part of the application without adequately restricting the choice. In either case, the important question is not whether a request looks suspicious. It is whether the application crosses a boundary it was supposed to enforce.
Consider a fictional document portal. An employee selects a policy named leave-policy.pdf, and the application retrieves it from a designated document directory. A secure design must do more than find a file with the requested name. It must also ensure that the file belongs to the permitted collection and that this particular employee is allowed to access it. If a modified request causes the application to retrieve a different file outside that collection, the result may indicate path traversal. If the application instead uses the supplied value to select a file for inclusion in its own output or processing, the concern may be unsafe file inclusion.
These are related problems, but they are not interchangeable labels. This chapter establishes the distinctions, the web concepts you need, and the habits that make testing useful. The exercises throughout the book assume a controlled, authorized environment. They are designed to build a method: establish what should happen, make a deliberate change, observe what actually happens, and report only what the evidence supports.
Path traversal occurs when a file path is interpreted in a way that allows access outside an intended directory or other permitted location. The familiar notation .. means a parent directory in many file-system contexts. If an application combines an untrusted value with a directory path and the resulting path is not properly constrained, parent-directory references can change where the application looks.
The existence of that notation is not itself a vulnerability. Applications routinely handle paths, and some legitimate workflows require navigation among directories. The security issue is the failure to enforce an intended boundary when selecting a resource. That boundary might be a particular document directory, a tenant’s storage area, or a set of files associated with a user’s account.
A useful way to frame a test is therefore:
> Can a value I am permitted to supply influence file selection beyond the resources this feature is supposed to expose?
The wording matters. It keeps attention on the application’s intended behavior and the tester’s authorization rather than on a favorite string. A test input may be rejected, normalized, ignored, logged, or treated as literal text. It may also be accepted by one layer and interpreted differently by another. A meaningful assessment follows the input through the observable behavior instead of assuming that a particular character sequence has a predetermined effect.
Unsafe file inclusion concerns a related but different decision: the application selects a file to incorporate into a page, template, or other processing flow, and an untrusted value has too much influence over that selection. The included content may appear in a response, affect how a page is assembled, or be handled according to the application’s runtime and configuration. Inclusion does not automatically mean that code executed, and seeing text in a response does not automatically prove that an inclusion mechanism was used.
For example, imagine a help page that chooses one of several local content files based on a request value. If the application permits selection of an unintended benign lab file and incorporates its distinctive marker into the page, that is evidence of unintended file selection. Whether it proves inclusion, rather than ordinary file reading or some other behavior, depends on what else is known about the application and the response. Chapter 8 will examine that distinction in a controlled setting.
The consequences of a file-handling weakness depend on the application, the accessible files, the privileges of the running process, and the behavior actually demonstrated. An unintended file read could disclose internal documents, configuration details, source material, or data belonging to another user. An inclusion weakness can create different risks depending on how the selected file is processed. In some environments, the impact may be more serious than content disclosure; in others, the attempted selection may be blocked or the process may lack access to anything sensitive.
Those possibilities are reasons to investigate carefully, not reasons to claim the worst outcome. A tester who observes a harmless marker file outside the intended directory can report that boundary crossing. The tester should not automatically report access to every file on the host, exposure of credentials, or code execution. Each of those claims would require its own supporting evidence and an authorized basis for obtaining it.
File-path controls are also only one part of the security picture. An application might restrict requests to a document directory yet still allow one user to retrieve another user’s document. Conversely, a resource may be associated with the correct user but selected through a path-building process that permits escape…