Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Relative Path Traversal
Cyber Security

Relative Path Traversal

← Back to Glossary
By NHI Mgmt Group Updated October 17, 2026 Domain: Cyber Security

Relative path traversal is a file access flaw where user input lets an attacker move outside the intended directory using relative path elements. It can expose configuration, secrets or code, so defenders normalise paths, enforce allowlists and block input that resolves beyond approved locations.

How Relative Path Traversal Works

Relative path traversal happens when an application treats attacker-controlled input as part of a file path and allows relative segments such as dot-dot separators to escape the intended directory. The flaw is dangerous because the server may resolve the path to configuration files, source code, logs, or other sensitive material that was never meant to be reachable.

Unlike a simple file-read bug, traversal is usually about path resolution rules, not just filename choice. Normalisation, canonicalisation, and access checks must all agree on the same final path, otherwise a string that looks harmless can resolve somewhere sensitive after the filesystem processes it.

Why It Is Dangerous

The impact depends on what sits outside the allowed directory. If the application can read local files, an attacker may expose secrets, application settings, database credentials, source code, or deployment metadata. In some systems, disclosure of code or configuration is enough to reveal additional attack surface, hard-coded trust assumptions, or the locations of other sensitive assets.

Traversal can also become a stepping stone to broader compromise when the exposed file content helps an attacker identify tokens, keys, internal hosts, or privileged automation paths. That is why path traversal is often discussed alongside file inclusion and other web application weaknesses in web application attack patterns, not as a purely cosmetic input-validation issue.

How Organisations Check Exposure

Exposure assessment starts with understanding where user-controlled paths are accepted: download endpoints, image handlers, import features, archive extractors, log viewers, and any route that maps request data to the filesystem. Teams should then confirm whether those paths are constrained to a known base directory and whether the application resolves symbolic links, encoded separators, and platform-specific path quirks in a safe way.

Because traversal is often discovered through unexpected file access, testing should include both application review and deployment review. External guidance such as the OWASP API Security Top 10 is useful where file access is exposed through APIs, while the broader NIST SP 800-53 Rev 5 Security and Privacy Controls catalog helps anchor access control, configuration management, logging, and secure coding expectations around the affected service.

Defensive Controls and Remediation

The safest pattern is to avoid accepting raw paths from users at all. When file selection is required, the application should map user input to an internal identifier, resolve the final target path, and reject anything that escapes the approved directory after normalisation. Allowlisting known filenames or object IDs is stronger than trying to blacklist suspicious characters.

Defense in depth still matters. Restrict the application’s filesystem permissions so a traversal flaw cannot read unrelated files, keep secrets out of web roots, and separate sensitive configuration from content served by the application. For cloud and platform environments, the same principle appears in the NIST Cybersecurity Framework 2.0 through asset protection, configuration discipline, and recovery planning, because a weak file boundary is easier to exploit when the runtime already has broad read access.

Detection and Post-Exposure Review

Detection is most effective when it looks for failed and successful traversal attempts together. Repeated requests containing relative path markers, unusual encoding, abnormal file extensions, and access to sensitive file names can indicate probing. Server logs, file access telemetry, and application traces should be reviewed for requests that resolve outside expected directories or return unexpected file types.

After a confirmed incident, the review should focus on what the file contents may have exposed and whether those contents included secrets, tokens, or configuration values that can be reused elsewhere. If traversal exposed identity material or credentials, the incident should be handled as a broader disclosure event, not merely as a content leak. The OWASP Non-Human Identities Top 10 is relevant whenever exposed files include service credentials, API keys, or other machine-authentication material that could be reused by an attacker.

Risk and Threat Considerations

Relative path traversal is risky because the attacker does not need direct file-system access, only a request path that the application later resolves in an unsafe way. The primary threat is unauthorised disclosure, but the deeper danger is that one exposed file often leads to others by revealing names, credentials, environment details, or internal trust relationships.

Failure mechanism: The application validates the raw string instead of the final resolved path, or it normalises input after access decisions are already made, allowing an attacker to escape the intended directory boundary.

Impact: Confidential files, source code, and secrets may be read, which can enable follow-on compromise, lateral movement, or abuse of downstream services that trust the leaked material.

Standards & Framework Alignment

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

OWASP API Security Top 10 addresses the attack and risk surface, while OWASP ASVS, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP ASVSV1 — Encoding and SanitizationPath traversal often depends on unsafe path handling and encoding interpretation.
Recommendation — Validate and canonicalize path input before using it in file operations.
NIST SP 800-53 Rev 5SI-10 — Information Input ValidationTraversal is enabled by malformed input that bypasses path validation.
AC-3 — Access EnforcementThe flaw becomes damaging when file access is not constrained to intended resources.
Recommendation — Validate file-path input and reject values that resolve outside approved locations. Enforce file access rules so the process cannot read data beyond its approved scope.
CIS Controls v8CIS-16 — Application Software SecuritySecure coding controls address traversal-safe input handling and file access design.
Recommendation — Build traversal-resistant path handling into application security requirements and review.
OWASP API Security Top 10API8 — Security MisconfigurationUnsafe file exposure often stems from misconfigured file-serving or storage exposure.
Recommendation — Harden file-serving configuration to prevent unintended path resolution and exposure.

Practitioner Guidance

Why practitioners should care: Treat path traversal as a boundary problem, not just an input-filtering problem. The control objective is to make the resolved path, not the user-supplied string, the basis for access decisions.

What to watch for: Any feature that accepts filenames, relative paths, archive members, or content references should be reviewed for canonicalisation, allowlisting, and least-privilege filesystem access. If the service can read a file, assume an attacker will try to make it read the wrong one.

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 17, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org