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

Canonical Path

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

A canonical path is the final resolved file location after symbolic links, traversal sequences, and relative components have been removed. Security teams use canonical comparison to verify that the requested file still sits inside an approved directory before the application reads or writes it.

What canonical path comparison actually does

Canonical path comparison is a defensive file-handling check, not a naming convenience. The application resolves the path to its final location, then compares that resolved location against an approved directory before it opens, reads, or writes the file. That removes ambiguity created by symbolic links, .. traversal, and other relative components.

The security value is straightforward: the check answers the question, “where will the filesystem actually land after resolution?” rather than “what string did the user submit?” That distinction matters whenever the path comes from a request parameter, upload target, export location, or any other user-influenced input.

Why resolution matters for file access control

A raw path string can look safe while still resolving to a sensitive location. A link inside an allowed directory can point somewhere else, and a relative segment can move the request outside the intended boundary. Canonicalisation closes those gaps by normalising the filesystem view before the application makes its access decision.

That makes canonical path checks a boundary control for local file access. The control is most valuable when the application uses path input to decide whether to open configuration files, write uploads, serve documents, or create output files. The comparison should be done after resolution and before any file operation that would act on the untrusted path.

Common failure modes and false assumptions

Canonical comparison fails when teams validate the original string but later act on a different resolved path, or when they compare against an approved directory without resolving both sides consistently. It also fails when the check is performed once and the file is used later, because the target can change between validation and use in some environments.

Another common mistake is assuming that path sanitisation alone is enough. Removing obvious traversal tokens is useful, but it does not fully address link-based redirection, mount boundaries, or edge cases created by platform-specific path semantics. Canonical comparison is the stronger control because it measures the actual resolved destination, not just the syntax of the request.

Where canonical paths sit in a secure file workflow

Canonical path validation is usually one layer in a broader file-handling workflow. It works best with explicit allowlists for directories, least-privilege filesystem permissions, and careful handling of uploads, archives, and file-serving endpoints. The check helps ensure that the application’s intended scope and the filesystem’s actual behaviour stay aligned.

For security engineering, the key point is that the path comparison should be treated as an authorization decision for a filesystem target. If the resolved path is outside the permitted area, the application should deny the operation rather than try to “fix” the path and continue. That keeps the control predictable and easier to reason about during review and testing.

Risk and Threat Considerations

Canonical path mistakes can turn a routine file operation into a traversal, overwrite, or disclosure issue. Attackers look for places where the application trusts the submitted path string more than the filesystem’s resolved location, because that mismatch can let them reach files outside the intended directory.

Failure mechanism: The application validates a user-controlled path before resolution, or resolves it inconsistently, then performs the file operation on a different target than the one it approved.

Impact: Sensitive files may be read, modified, or created outside the intended boundary, which can expose secrets, damage configuration, or enable follow-on compromise.

Standards & Framework Alignment

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

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 ASVSV5 — File HandlingCanonical path checks are a core file-handling defense against path traversal.
V13 — ConfigurationSafe canonical path handling depends on secure configuration of file locations and runtime paths.
Recommendation — Validate resolved file paths before file access and reject paths outside approved directories. Harden path handling settings so applications cannot be redirected to unsafe filesystem locations.
NIST SP 800-53 Rev 5AC-3 — Access EnforcementPath-based file access decisions enforce whether a request may reach a file target.
CM-5 — Access Restrictions for ChangeProtecting file writes requires restricting where changes can be made on the filesystem.
Recommendation — Enforce directory boundaries so file operations only reach approved resources. Restrict write locations to approved paths and deny modification outside controlled areas.
CIS Controls v8CIS-16 — Application Software SecuritySecure application file handling is an application security control area directly affected by traversal defenses.
Recommendation — Build path validation into application security testing and code review.

Practitioner Guidance

Why practitioners should care: Canonical path checks are one of the few practical ways to make file-boundary decisions match the filesystem’s real behaviour. They are especially important anywhere untrusted input can influence a path, because string-based checks alone are easy to bypass.

What to watch for: Review any code path that accepts relative paths, upload destinations, archive extraction targets, or user-supplied filenames. The safest pattern is to resolve first, compare against an approved base directory, and only then perform the file action.

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