Summary
i18next-http-middleware versions prior to 3.9.3 pass user-controlled language (lng) and namespace (ns) parameters directly into the i18next backend loader without validation.
Depending on the configured backend, this can allow attackers to traverse file system paths or trigger server-side requests to arbitrary URLs, turning simple localization requests into a high-impact attack surface.
Affected context
This vulnerability affects Node.js and Deno applications that:
- Use
i18next-http-middlewarewith frameworks like Express, Fastify, or similar - Expose endpoints that rely on
getResourcesHandleror similar middleware to resolve translations - Configure backends that load translation resources from the file system, HTTP(S) endpoints, or other dynamic locations
The risk materializes when user input (e.g., query parameters or headers specifying lng and ns) is allowed to flow into the backend loader without constraints on allowed values or locations.
Exploit preconditions
- Attack surface: HTTP endpoints where
i18next-http-middlewareprocesses requests and callsgetResourcesHandler. - Required access: Network access to the vulnerable endpoint (typically unauthenticated, depending on the application).
- Trigger point: Supplying crafted
lngand/ornsparameters that are passed directly intoi18next.services.backendConnector.load(languages, namespaces, …). - Why exploitation is possible: The middleware does not sanitize or constrain
lngandns, allowing an attacker to influence backend paths or URLs. Backends that derive file paths or remote URLs from these values can be coerced into path traversal or server-side HTTP requests.
Why this happens
The core issue is a lack of input validation and normalization on parameters that are treated as trusted configuration for resource loading.
i18next-http-middleware passes user-controlled lng and ns values directly into backendConnector.load, which in turn may construct file system paths or remote URLs. When these values are not constrained to a known-safe set (e.g., whitelisted languages and namespaces) and are combined with resource backends that interact with the file system or network, attackers can:
- Inject directory traversal segments (e.g.,
../) leading to CWE-22: Path Traversal - Inject arbitrary URLs or hostnames, resulting in CWE-918: Server-Side Request Forgery (SSRF)
This pattern reflects a broader class of bugs where user input controls low-level resource locators without proper validation or scoping.
Potential impact
- Read access to unintended files within the server's file system, depending on backend behavior and permissions
- Potential exposure of configuration files, secrets, or source code if the backend reads arbitrary paths
- Server-Side Request Forgery, allowing the application to make HTTP requests to internal services or metadata endpoints
- Use of the server as a pivot point to scan internal networks or interact with protected APIs
- Degradation of service availability due to forced requests to slow or non-responsive endpoints
General mitigation guidance
Effective mitigation focuses on constraining and validating all user-controlled parameters that influence resource loading:
- Enforce strict allowlists for supported
lng(language codes) andns(namespaces), rejecting or defaulting any unrecognized values. - Normalize and validate values before they reach backend loaders; avoid directly concatenating user input into file paths or URLs.
- Configure i18next backends to operate within fixed, known-safe directories and disallow resolution outside these roots.
- For HTTP-based backends, restrict outbound requests to trusted hosts or use a network egress policy that prevents arbitrary destinations.
- Apply the principle of least privilege to the process: limit filesystem permissions and network reach so that a compromise yields minimal access.
How teams detect issues like this
Detection typically involves a combination of code-level and runtime analysis:
- Static analysis: Look for flows where
lngornsare read from request objects (query, headers, cookies) and passed intoi18nextbackend loaders without validation or mapping through a whitelist. - Code review cues: Flag middleware or route handlers that use
getResourcesHandleror similar helpers without explicit checks on accepted languages and namespaces. - Configuration review: Examine i18next backend configuration for dynamic path or URL construction influenced by request parameters.
- Runtime monitoring: Use application logs, WAFs, or API gateways to detect suspicious patterns like
../segments in language/namespace parameters or unusual outbound HTTP destinations originating from translation requests. - Automated security scanning tools that model data flow can be configured to treat backendConnector usages as sensitive sinks for untrusted input.

