Summary
@fastify/static before version 10.1.3 can mishandle non-canonical URL paths when route-based guards protect files beneath a static root. An unauthenticated attacker may use alternate path representations to bypass the guarded route and disclose protected file contents when the application relies on route-based protection.
Affected context
The issue occurs in applications that use @fastify/static to serve files and apply authorization through route-based guards covering part of the static directory. It is relevant when pathname variations such as dot segments, repeated slashes, encoded dots, or backslashes are matched before consistent canonicalization. Applications that rely on the allowedPath option for access control are not affected in the same way.
Exploit preconditions
- Attack surface: An HTTP-accessible static file route
- Required access: No authentication may be required to send requests to the static handler
- Protected resource: A sensitive file or subtree protected by a route-based guard
- Trigger point: Request processing before routing and static-file delegation use the same canonical pathname
- Why exploitation is possible: A non-canonical path can miss the guarded route while resolving to a protected file in the static serving layer
Why this happens
The underlying bug is inconsistent path normalization across routing and file serving. The handler rejected some parent-directory traversal patterns but did not canonicalize other equivalent pathname forms, including dot segments, duplicate separators, encoded dots, and backslashes, before route matching and delegation.
This maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because alternate path representations can escape the intended authorization boundary. It also relates to CWE-436: Interpretation Conflict, where different components interpret the same input differently.
Potential impact
- Protected file contents may be disclosed to unauthenticated users
- Route-based authorization boundaries could be bypassed
- Application secrets, configuration data, or internal assets may be exposed
- Disclosed files could support follow-on attacks against the application or hosting environment
General mitigation guidance
Mitigation generally focuses on making authorization and file resolution operate on one consistently canonicalized pathname.
Common defensive patterns include:
- Canonicalizing pathnames before route matching, authorization, and static-file resolution
- Rejecting ambiguous separators, backslashes, encoded dot segments, and other non-canonical forms
- Applying authorization after normalization and before file access
- Prefering dedicated allow-list path checks such as an allowedPath-style control for protected content
- Keeping sensitive files outside publicly served static roots
- Running the application with least-privilege filesystem permissions
- Using a vendor-supported release containing the complete path-canonicalization fix
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis and code review checks for route authorization that differs from filesystem path resolution
- Tests covering dot segments, repeated slashes, encoded separators or dots, and backslashes
- Request logging and alerting for unusual path normalization patterns targeting protected resources
- Policy checks requiring canonicalization before authorization and file-serving operations
- Integration tests that verify every equivalent pathname representation receives the same authorization decision
Automated security review tools may help identify inconsistent path handling, but behavioral tests are important because the issue depends on interactions between routing and file resolution.

