i18next-http-middleware Prototype Pollution and Path Traversal Vulnerability
Versions of i18next-http-middleware before 3.9.3 are vulnerable to prototype pollution, path traversal, and server-side request forgery (SSRF) due to improper validation of user-controlled language and namespace parameters, potentially leading to denial of service or remote code execution.
i18next-http-middleware versions prior to 3.9.3 are susceptible to prototype pollution, path traversal, and SSRF attacks. The vulnerability stems from the insufficient validation of the lng (language) and ns (namespace) parameters passed via HTTP requests to the getResourcesHandler and the missingKeyHandler. These handlers, intended to serve localization resources, expose attack surface because they process user-controlled input without proper sanitization. This allows attackers to manipulate object properties, access unintended files or internal services, and cause denial-of-service conditions. The vulnerability was discovered via an internal security audit. Defenders should upgrade to version 3.9.3 to remediate the risks.
Attack Chain
- The attacker crafts an HTTP GET request to the
/locales/resources.jsonendpoint, targeting thegetResourcesHandler. - The request includes malicious
lngandnsquery parameters, such aslng=__proto__&ns=isAdmin, orns=../../etc/passwd. - The
getResourcesHandlerextracts thelngandnsparameters without sufficient validation. - The
lngandnsvalues are passed toutils.setPath(resources, [lng, ns], ...)which allows writing to the Object prototype iflngis__proto__. - The
lngandnsvalues are passed toi18next.services.backendConnector.load(languages, namespaces, ...)to load resource bundles. With filesystem or HTTP backends, this can enable path traversal or SSRF ifnsorlngcontain malicious path segments. - Alternatively, the attacker sends a POST request with a body containing a malicious
__proto__key tomissingKeyHandler, for example{"__proto__": {"isAdmin": true}}. - The
missingKeyHandleriterates over the request body usingfor...in, including inherited prototype properties, and forwards the malicious data intosaveMissing. - Successful exploitation leads to prototype pollution, arbitrary file access, SSRF, or denial of service.
Impact
Successful exploitation can have significant consequences. Prototype pollution allows attackers to manipulate object properties globally, leading to broken authorization checks (e.g., bypassing if (user.isAdmin)), type confusion errors, or potentially remote code execution. Path traversal enables access to sensitive files on the server, like configuration files or password databases, while SSRF allows attackers to interact with internal services. Finally, the unbounded growth of the i18next.options.ns list and repeated backend load calls can lead to denial of service due to memory and CPU exhaustion. This can impact availability of the service and potentially other services on the same host.
Recommendation
- Upgrade to
i18next-http-middlewareversion 3.9.3 or later to address the vulnerabilities. - Deploy the Sigma rules provided below to detect exploitation attempts targeting the
getResourcesHandlerandmissingKeyHandlerendpoints. - If upgrading is not immediately feasible, implement a WAF rule as a partial mitigation to block requests containing
__proto__,constructor,prototype,.., or control characters inlng/nsquery parameters or body keys as suggested in the advisory.
Detection coverage 2
Detect Prototype Pollution Attempt via i18next HTTP Middleware
criticalDetects attempts to exploit the prototype pollution vulnerability in i18next-http-middleware by checking for `__proto__`, `constructor`, or `prototype` in the `lng` or `ns` parameters.
Detect Path Traversal Attempt via i18next HTTP Middleware
highDetects attempts to exploit path traversal vulnerability in i18next-http-middleware by checking for directory traversal sequences in the `lng` or `ns` parameters.
Detection queries are kept inside the platform. Get full rules →