CWE-22 is the Common Weakness Enumeration entry for path traversal. It describes failures to properly restrict a pathname to a safe directory boundary. Security teams use it to classify, triage, and track flaws where untrusted input can escape the intended file system scope.
What CWE-22 Means in Practice
CWE-22, path traversal, is dangerous because it lets attacker-controlled input break out of the intended directory boundary and reach files or paths the application should never expose. That often turns a simple file-handling bug into unauthorized read, write, or execution impact, depending on how the path is later used.
For defenders, the key idea is not just “user input touched a path”, but whether the application normalises, resolves, and constrains that path against a trusted base directory. The weakness includes classic dot-dot traversal, but also alternate encodings, separator confusion, and path equivalence tricks that can defeat naïve validation.
Where Path Traversal Flaws Usually Come From
Path traversal typically appears when an application builds file paths by concatenating request parameters, upload names, archive entries, template names, or download targets without enforcing a safe root. The bug may sit in a web handler, API endpoint, background job, build pipeline, or tooling integration, because any component that opens files on behalf of untrusted input can become the exposure point.
These flaws are especially common where developers rely on string checks instead of filesystem-aware resolution. A path that “looks” safe may still resolve outside the intended directory after decoding, normalisation, symlink resolution, or platform-specific filename handling.
NHIMG’s Path Traversal Guide goes deeper on archive extraction, safe file APIs, and rollout patterns for preventing traversal in real systems.
Why CWE-22 Is More Than a File Bug
Path traversal matters because file systems often hold configuration, source code, credentials, session material, logs, backups, and operational data. When an application can step outside its intended scope, the consequence may be disclosure of secrets, tampering with application state, or overwriting files that influence execution or availability.
It is also a common root cause pattern in related weaknesses such as local file inclusion, insecure archive extraction, and unsafe file upload handling. That is why CWE-22 is useful for triage: it describes the control failure at the root, even when the visible symptom is a different exploit path.
NHIMG’s CWE Top 25 Guide places path traversal in the wider context of dangerous software weaknesses and shows how it relates to other high-impact coding failures.
How Teams Validate Exposure and Reduce the Blast Radius
Exposure checks should start with asset and code inventory, then move to every entry point that touches filenames, extraction paths, temporary files, or user-supplied archive content. Internet-facing download handlers, upload services, document converters, and CI or build tooling deserve special attention because they often process untrusted path data at scale.
Remediation usually means canonicalising the path, enforcing a strict directory allowlist, rejecting traversal after full resolution, and using file APIs that operate relative to an approved root rather than raw string concatenation. When a fix cannot be deployed immediately, compensating controls include reducing exposed functionality, isolating the process, tightening filesystem permissions, and monitoring for attempts to escape the expected directory tree.
NHIMG’s CVE, CWE and CPE Guide helps teams connect a weakness label like CWE-22 to vulnerability tracking, remediation workflow, and broader inventory discipline.
Risk and Threat Considerations
Path traversal is attractive to attackers because it can expose information or alter files without needing a full application compromise first. In real environments, the main risk is not the traversal string itself, but the trust boundary it crosses: once an input can escape the intended directory, the attacker may reach sensitive content or place files where downstream systems will trust them.
Failure mechanism: The application accepts path-bearing input, resolves it unsafely, and uses it to read or write outside the authorised directory boundary, often after encoding, normalisation, or symlink tricks.
Impact: Successful exploitation can lead to confidential file disclosure, configuration tampering, destructive overwrite, secret exposure, or a pivot into broader code execution or persistence depending on what the path controls.
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.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V5 — File Handling | CWE-22 is a file-path handling weakness that ASVS verification should catch. |
| Recommendation — Verify file access stays inside approved roots and reject traversal before any filesystem operation. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Path traversal is a software weakness that CIS secure-development safeguards should prevent. |
| CIS-3 — Data Protection | Traversal can expose sensitive files and secrets stored on disk. | |
| Recommendation — Build secure coding checks and testing into development to catch traversal before release. Restrict and protect sensitive files so a traversal flaw yields less usable data. | ||
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | Traversal stems from failing to validate pathname input before use. |
| AC-3 — Access Enforcement | Traversal bypasses intended directory access boundaries enforced by the application. | |
| Recommendation — Validate and constrain path input before it is resolved or passed to the filesystem. Enforce directory access decisions so untrusted input cannot reach unauthorized files. | ||
Practitioner Guidance
What to watch for: Review any feature that takes a filename, relative path, archive entry, template name, or download target, especially when the value is stored, decoded, or reused across multiple components. The safest implementations make the intended directory explicit and treat any resolved escape from that boundary as a hard failure.
Governance implication: Treat CWE-22 as a secure-coding and verification requirement, not just a one-off bug class. It belongs in code review checklists, secure file-handling standards, and test cases that exercise traversal, encoding variants, and filesystem edge cases.
Related resources from NHI Mgmt Group
- What is the difference between changing port 22 and real SSH hardening?
- What do teams get wrong when they rely on top CWE rankings alone?
- Why do repeat CWE classes keep causing breaches even when teams know about them?
- How should security teams use the CWE Top 25 and OWASP Top 10 together without duplicating work?
Deepen Your Knowledge
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.
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org