Path Traversal
Unsafe path construction lets an identifier escape the directory the developer intended as its boundary.
Frame the problem
Security starts with a concrete asset, attacker capability and trust crossing.
Why the system fails
The application joins an untrusted path and assumes the resulting string remains under the expected root.
The important question is not “what is Path Traversal?” but “which assumption let untrusted data or an over-scoped identity cross external identifier → local filesystem namespace?” Trace the decision at the boundary, then constrain what can happen after the first control fails.
Design the control in layers
Start with the control closest to the interpretation or privilege boundary: Map allowlisted or generated identifiers to files Then add a control that reduces blast radius and telemetry that proves the decision was enforced.
The resulting design is not labelled secure. Record the identified controls, the known failure paths, the remaining exposure, and the evidence you would need during an incident.
| Prevent | Detect | Recover |
|---|---|---|
| Map allowlisted or generated identifiers to files · Resolve and verify containment under a fixed root · Isolate the storage process and permissions | Rejected containment checks · Access to unexpected filesystem prefixes | Contain the affected identity or component, scope impact from audit evidence, and preserve a regression test. |
Key points
- Asset: Files outside the application’s serving or upload directory.
- Boundary: External identifier → local filesystem namespace
- Primary control: Map allowlisted or generated identifiers to files
- Detection signal: Rejected containment checks
- Always ask what limits damage when the primary control fails.
Follow the attack
Safe conceptual simulation: capability → missing control → crossed boundary → asset impact.
- 1Attacker starts with: A caller who controls a filename or object path.
- 2The application joins an untrusted path and assumes the resulting string remains under the expected root.
- 3The weak or missing boundary control is crossed: External identifier → local filesystem namespace
- 4Impact: Unauthorized file reads, overwrites or exposure of configuration and secrets.
- Unauthorized file reads, overwrites or exposure of configuration and secrets.
Defend, detect, recover
One prevention is a single point of security failure. Layer it and make failure observable.
- • Map allowlisted or generated identifiers to files
- • Resolve and verify containment under a fixed root
- • Isolate the storage process and permissions
- • Rejected containment checks
- • Access to unexpected filesystem prefixes
- • Contain the affected identity or component.
- • Scope access from audit evidence.
- • Fix the boundary and add a regression test.
- • Misconfiguration and new access paths can bypass the intended control.
- • A privileged insider or compromised control plane may still reach the asset.