Summary
fast-uri performed percent-decoding of path separators and dot segments before running its dot-segment removal logic in the normalize() and equal() functions, causing encoded slashes and .. components to be treated as real path elements.
When applications rely on these helpers to normalize or compare attacker-controlled URLs for path-based access control, an attacker can craft URLs that appear to stay under an allowed prefix but normalize to a different, potentially sensitive location.
Affected context
This vulnerability appears in applications that:
- Use fast-uri (versions ≤ 3.1.0) to normalize or compare URLs
- Make authorization or routing decisions based on a normalized URI path prefix
- Accept some portion of the URL from untrusted or semi-trusted sources (e.g., user input, request parameters, proxy headers)
The risk is elevated where path-based policies are expected to confine requests to a specific namespace (such as /public/ or /tenant/<id>/) and no additional canonicalization or filesystem checks are applied after using fast-uri.
Exploit preconditions
- Attack surface: Any HTTP or application endpoint where:
- A user-controlled URL or path is processed using fast-uri's
normalize()orequal()functions - The result is used to enforce path-based security, multi-tenant isolation, or routing restrictions
- Required access: Ability to supply or influence URL path components or query parameters that are passed through fast-uri.
- Trigger point: Invocation of fast-uri normalization or equality checks on an attacker-crafted URI containing percent-encoded slashes (
%2F) and/or dot segments (./..) designed to alter the normalized path. - Why exploitation is possible: fast-uri decodes percent-encoded path separators and dot segments before performing dot-segment removal, causing different textual inputs to collapse to the same normalized path and allowing encoded parent-directory references to escape the intended path prefix.
Why this happens
The root cause is a URI canonicalization logic flaw aligned with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Conceptually:
- fast-uri's
normalize()andequal()implementations decode percent-encoded characters in the path, including/,.and..-related sequences, before applying the dot-segment removal algorithm. - Because
%2Fand similar encodings are treated as real slashes during normalization, encoded segments such as%2e%2ecan effectively become..and participate in directory traversal during canonicalization. - As a result, two URIs that look different at the raw-text level (one seemingly confined under a safe prefix, another outside it) can normalize to the same canonical path, undermining logic that assumes normalization prevents traversal.
This pattern reflects a class of bugs where normalization, decoding, and policy enforcement are applied in the wrong order, or inconsistently, allowing crafted inputs to bypass prefix checks and directory constraints.
Potential impact
- Bypass of path-based access control rules for web endpoints or API routes
- Unauthorized access to resources outside an intended URL namespace or tenant scope
- Exposure of sensitive data that was assumed to be protected by path prefix checks
- Ability to reach internal admin or debug paths by masquerading as requests to allowed locations
- Confusion in logging, monitoring, and audit trails due to mismatches between apparent and normalized paths
General mitigation guidance
Effective mitigation focuses on correcting URI normalization behavior and hardening path-based policy design:
- Canonicalization order: Ensure that percent-decoding, dot-segment removal, and any other normalization steps are applied in a consistent, standards-aligned order that does not allow encoded traversal sequences to emerge after security checks.
- Defensive prefix checks: When implementing prefix-based authorization, compare against fully canonicalized paths that cannot later change meaning (e.g., post-normalization, with redundant segments removed).
- Additional confinement layers: Where URLs map to filesystem paths or internal routing, combine normalization with:
- Explicit checks rejecting any
..segments after normalization - Directory or namespace whitelisting instead of relying solely on string-prefix checks
- Least privilege in routing: Avoid granting broad access based solely on a path prefix; associate authorization decisions with explicit resources or identifiers rather than raw path strings.
- Input trust reduction: Treat all user-supplied URL components as untrusted, even when they appear encoded or normalized, and validate them against strict patterns or resource maps.
How teams detect issues like this
Detection can leverage both code-focused and behavior-focused approaches:
- Static analysis/code scanning:
- Identify uses of fast-uri's
normalize()andequal()that are directly tied to authorization, tenancy isolation, or path-based routing decisions. - Flag patterns where normalized paths are compared using string-prefix checks (e.g.,
startsWith('/allowed/')) without further validation. - Targeted code review:
- Examine security-sensitive modules (auth middleware, multi-tenant routing, reverse proxies, static file handlers) for reliance on normalized URLs to enforce confinement.
- Review any logic that maps normalized paths to filesystem locations or internal resource identifiers.
- Dynamic testing and fuzzing:
- Construct test cases with percent-encoded slashes and dot segments (e.g., combinations of
%2F,%2e,%2e%2f) to see whether requests can escape intended path boundaries. - Policy enforcement in CI/CD:
- Enforce guidelines that discourage raw string-prefix checks on user-controlled paths and require canonicalization and validation helpers with clearly documented semantics.
Automated SAST/DAST tools can assist by flagging high-risk path handling constructs and verifying behavior under crafted encoded paths.

