Path traversal is a flaw where crafted input changes a file path so an application accesses data outside its intended directory. Attackers often use sequences such as ../ or encoded variants to move “up” the filesystem tree and reach files the app should never expose, modify, or delete. The risk is not limited to reading secrets: if the vulnerable code performs writes or deletes, the same bug can damage application data, configuration, or stored content.
In real attacks, path traversal is used to steal credentials, overwrite files, remove directories, or plant malicious content. It becomes especially dangerous in systems that manage user uploads, document stores, backup folders, or knowledge bases. Defenses include strict allowlists for filenames, canonicalizing paths before use, rejecting separators and traversal sequences, and verifying that the final resolved path stays inside an approved base directory. Least-privilege filesystem permissions add another layer of protection if validation fails.


