Join our Newsletter — 33% off our NHI Course
Home› FAQ› Threats, Abuse & Incident Response› What causes path traversal?
Threats, Abuse & Incident Response

What causes path traversal?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated October 19, 2026 Domain: Threats, Abuse & Incident Response

It is usually caused by software that uses untrusted path input to read or write files without normalising and constraining the path. Attackers add sequences such as directory changes or absolute paths to reach unintended files. Defenders should enforce canonical path checks, allowlists, and least-privilege filesystem access.

What makes path traversal possible?

path traversal becomes possible when an application treats user-supplied path fragments as trusted input and then uses them directly in file read or write operations. The core failure is not the traversal sequence itself, but the lack of normalisation, canonicalisation, and boundary checks before the filesystem sees the path.

In practice, that means the application lets an attacker influence where a file operation lands. If the code does not resolve the final path and compare it to an approved base directory, a request can escape the intended folder and touch sensitive files, configuration data, or other application assets.

A useful way to think about it is that path traversal is a path-construction flaw, not just a filtering flaw. Encoding tricks, alternate separators, repeated traversal segments, and absolute paths all matter because the attacker is trying to reach a location the program never intended to expose. The right defence is to make the final resolved path the decision point, not the raw string.

Why do simple filters and string checks fail?

String-based checks are easy to bypass because filesystems and runtime libraries do not always interpret path text the same way your code does. A filter that rejects one obvious pattern may still allow encoded, mixed-separator, or nested variants that resolve to the same dangerous location after parsing.

That is why naive denylist logic is fragile. Even when developers block obvious directory changes, the application may still accept a path that normalises into an unexpected target. The safer pattern is to canonicalise the input, enforce a fixed root, and validate the resolved result against an allowlist of permitted locations or filenames.

Context matters too. A read-only lookup and a write operation have different consequences, but both can become dangerous if the path is attacker-controlled. If the path is used to open logs, templates, uploads, backups, or configuration files, the risk expands beyond simple file disclosure and can include file overwrite or application behaviour changes.

What does a secure design look like in practice?

Secure handling starts with removing unnecessary path freedom. When the application only needs a known set of files, map user input to an internal identifier rather than accepting a raw filesystem path. When variable paths are unavoidable, resolve the path server-side, compare it to an approved base directory, and reject anything that escapes that boundary.

Filesystem permissions should support the code’s intent, not compensate for it. Least-privilege access helps limit damage if traversal is exploited, especially where the process can read secrets, service configuration, or deployment files. The narrower the process permissions, the less useful a successful traversal becomes to an attacker.

For secure implementation guidance across common web attack patterns, the Web Application Attacks Guide is a useful companion reference, and path traversal fits naturally alongside related file-inclusion and injection issues.

Path traversal also overlaps with broader attack-path thinking in file-access abuse. The OWASP API Security Top 10 is relevant when the vulnerable input is exposed through an API parameter, because the same trust error can turn into broken access to files or internal resources.

Risk and Threat Considerations

Path traversal is risky because it can convert a routine file operation into unintended access, disclosure, or overwrite. If the application runs with broad filesystem permissions, the same flaw can expose credentials, configuration secrets, logs, or deployment artifacts that amplify the initial compromise.

Failure mechanism: The application accepts attacker-controlled path text, resolves it in a way that is not constrained to a trusted directory, and then performs file access on the resolved target.

Impact: Attackers may read sensitive files, tamper with writable files, alter application behaviour, or use exposed contents to deepen access into the environment.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP ASVSV5 — File HandlingPath traversal is a file-handling weakness involving unsafe path resolution.
Recommendation — Validate resolved file paths against an allowlisted base directory.
CIS Controls v8CIS-3 — Data ProtectionTraversal can expose sensitive files, so data protection and access limitation are central.
Recommendation — Restrict access to sensitive files and reduce the data reachable by application processes.
NIST SP 800-53 Rev 5AC-6 — Least PrivilegeLeast privilege limits the impact if traversal reaches unexpected files or writable paths.
SI-10 — Information Input ValidationThe flaw arises when untrusted path input is accepted without sufficient validation and normalization.
Recommendation — Limit file-system permissions so application accounts can access only what they need. Validate and normalize path input before any file operation uses it.

Practitioner Guidance

What to verify: Confirm that file access is decided on the canonical path after resolution, not on the raw request string. Also verify that every file operation, including uploads, downloads, template loading, and log access, is constrained to a permitted root.

Common mistake: Developers often stop at input filtering, but filtering alone is brittle if the runtime or filesystem interprets the path differently. Treat denylist checks as insufficient unless they are backed by normalisation and boundary enforcement.

What good looks like: The application maps user intent to approved resources, rejects any resolved path outside the allowed tree, and runs with permissions that prevent traversal from becoming a broad file exposure event.

Practitioner takeaway: Path traversal is best prevented by constraining the final resolved destination, not by trying to recognise every malicious-looking path string.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 19, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org