Summary
A server-side request forgery flaw in Starlette's StaticFiles on Windows allows outbound SMB connections to attacker-controlled UNC paths during path resolution.
If an attacker can make the application resolve a UNC path, the server may leak the service account's NTLMv2 credentials for offline cracking or relay, even though the HTTP response is only a 404.
Affected context
This vulnerability appears in Starlette-based applications (including frameworks like FastAPI) running on Windows where StaticFiles is used with the default follow_symlink=False setting.
It is triggered when user-controlled paths are interpreted as UNC locations (e.g., \\attacker.com\share) and passed through os.path.realpath, which attempts to resolve the network location.
POSIX deployments and configurations explicitly using follow_symlink=True are not impacted in the same way, but Windows default scenarios remain at risk whenever untrusted paths can reach StaticFiles.
Exploit preconditions
- Attack surface: HTTP endpoints served through Starlette's StaticFiles (or wrappers in dependent frameworks) on Windows.
- Required access: Ability to send HTTP requests that cause StaticFiles to resolve a filesystem path (including crafted UNC paths).
- Trigger point: Path normalization via
os.path.realpathon a UNC-style input such as\\attacker.com\share. - Why exploitation is possible: On Windows, resolving UNC paths implicitly initiates an outbound SMB connection prior to StaticFiles rejecting the path and returning a 404, exposing NTLMv2 credentials despite the failure response.
Why this happens
The underlying issue is that the file-serving component performs path normalization using OS-level filesystem APIs (os.path.realpath) on attacker-controlled input without considering side effects on network paths.
On Windows, UNC paths are treated as network locations, so resolving them can automatically trigger outbound SMB connections as part of the OS path resolution process.
This maps to CWE-918: Server-Side Request Forgery, where internal or external network requests are implicitly made on behalf of the server due to unvalidated, attacker-supplied resource identifiers (in this case, filesystem-like paths interpreted as network resources).
Potential impact
- Exposure of the service account's NTLMv2 hash for offline cracking.
- Use of leaked NTLMv2 credentials in relay attacks against other internal services.
- Lateral movement within a Windows domain environment if the compromised account has elevated privileges.
- Increased risk of broader compromise when combined with other weaknesses (e.g., weak passwords, lack of SMB signing).
General mitigation guidance
Mitigation efforts should focus on preventing untrusted paths from triggering network-based path resolution and reducing the power of any account that could be exposed.
Consider these general defensive patterns:
- Avoid calling filesystem APIs that implicitly resolve network locations on untrusted input, especially on Windows.
- Introduce strict allowlists for StaticFiles roots and reject any paths that resemble UNC or network paths before invoking OS-level path resolution.
- Run application services under minimally privileged accounts that have limited access to network resources and domain assets.
- Where possible, disable or tightly control outbound SMB traffic from application hosts using host-based firewalls or network segmentation.
- Apply defense-in-depth by logging and monitoring unexpected outbound SMB connections from application servers.
How teams detect issues like this
High-level detection and assurance strategies include:
- Static analysis rules to flag usage of path resolution functions (e.g.,
os.path.realpath) on untrusted inputs, particularly in file-serving code on Windows. - Code reviews focusing on StaticFiles configuration, ensuring that path sanitization, UNC path rejection, and trust boundaries around file paths are clearly documented and enforced.
- Runtime monitoring for unusual outbound SMB traffic originating from web application hosts, especially connections to untrusted or internet-accessible hosts.
- Integration of security linters and automated review tools in CI pipelines to identify SSRF-like patterns involving filesystem and network APIs.

