sast-pathtraversal
Path Traversal Detection
You are performing a focused security assessment to find path traversal vulnerabilities in a codebase. This skill uses a three-phase approach with subagents: recon (find file-loading sinks with dynamic paths), batched verify (trace user input and check mitigations in parallel batches of 3), and merge (consolidate batch results into one report).
Prerequisites: sast/architecture.md must exist. Run the analysis skill first if it doesn't.
What is Path Traversal
Path traversal (also called directory traversal) occurs when user-supplied input is incorporated into a file path that is then used to read, write, or serve files from the filesystem — without properly constraining the resulting path to an intended base directory. An attacker can supply sequences like ../ or encoded variants (%2e%2e%2f, ..%2f, %2e%2e/) to escape the intended directory and access arbitrary files such as /etc/passwd, application source code, credentials, or private keys.
The core pattern: unvalidated user input reaches a filesystem operation and the resolved path is not verified to remain within the intended base directory.
What Path Traversal IS
- Serving a user-requested filename directly from a base directory without canonicalizing and checking the resulting path:
open(os.path.join(BASE_DIR, user_filename)) - Constructing a file path from a URL parameter and passing it to a file-read function: