<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>I18next-Http-Middleware — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/i18next-http-middleware/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Fri, 26 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/i18next-http-middleware/feed.xml" rel="self" type="application/rss+xml"/><item><title>i18next-http-middleware Prototype Pollution and Path Traversal Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2024-01-i18next-http-middleware-vuln/</link><pubDate>Fri, 26 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-i18next-http-middleware-vuln/</guid><description>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.</description><content:encoded><![CDATA[<p>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 <code>lng</code> (language) and <code>ns</code> (namespace) parameters passed via HTTP requests to the <code>getResourcesHandler</code> and the <code>missingKeyHandler</code>. 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.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>The attacker crafts an HTTP GET request to the <code>/locales/resources.json</code> endpoint, targeting the <code>getResourcesHandler</code>.</li>
<li>The request includes malicious <code>lng</code> and <code>ns</code> query parameters, such as <code>lng=__proto__&amp;ns=isAdmin</code>, or <code>ns=../../etc/passwd</code>.</li>
<li>The <code>getResourcesHandler</code> extracts the <code>lng</code> and <code>ns</code> parameters without sufficient validation.</li>
<li>The <code>lng</code> and <code>ns</code> values are passed to <code>utils.setPath(resources, [lng, ns], ...)</code> which allows writing to the Object prototype if <code>lng</code> is <code>__proto__</code>.</li>
<li>The <code>lng</code> and <code>ns</code> values are passed to <code>i18next.services.backendConnector.load(languages, namespaces, ...)</code> to load resource bundles. With filesystem or HTTP backends, this can enable path traversal or SSRF if <code>ns</code> or <code>lng</code> contain malicious path segments.</li>
<li>Alternatively, the attacker sends a POST request with a body containing a malicious <code>__proto__</code> key to <code>missingKeyHandler</code>, for example <code>{&quot;__proto__&quot;: {&quot;isAdmin&quot;: true}}</code>.</li>
<li>The <code>missingKeyHandler</code> iterates over the request body using <code>for...in</code>, including inherited prototype properties, and forwards the malicious data into <code>saveMissing</code>.</li>
<li>Successful exploitation leads to prototype pollution, arbitrary file access, SSRF, or denial of service.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation can have significant consequences. Prototype pollution allows attackers to manipulate object properties globally, leading to broken authorization checks (e.g., bypassing <code>if (user.isAdmin)</code>), 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 <code>i18next.options.ns</code> 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.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to <code>i18next-http-middleware</code> version 3.9.3 or later to address the vulnerabilities.</li>
<li>Deploy the Sigma rules provided below to detect exploitation attempts targeting the <code>getResourcesHandler</code> and <code>missingKeyHandler</code> endpoints.</li>
<li>If upgrading is not immediately feasible, implement a WAF rule as a partial mitigation to block requests containing <code>__proto__</code>, <code>constructor</code>, <code>prototype</code>, <code>..</code>, or control characters in <code>lng</code>/<code>ns</code> query parameters or body keys as suggested in the advisory.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>prototype-pollution</category><category>path-traversal</category><category>ssrf</category><category>denial-of-service</category><category>i18next</category></item><item><title>i18next-http-middleware HTTP Response Splitting and DoS Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2024-01-i18next-http-middleware-crlf/</link><pubDate>Wed, 03 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-i18next-http-middleware-crlf/</guid><description>i18next-http-middleware versions before 3.9.3 are vulnerable to HTTP response splitting and denial-of-service attacks due to unsanitized Content-Language headers, potentially leading to session fixation, cache poisoning, reflected XSS, or complete service disruption depending on the Node.js version.</description><content:encoded><![CDATA[<p>The <code>i18next-http-middleware</code> library, in versions prior to 3.9.3, exhibits a vulnerability stemming from insufficient sanitization of user-controlled language values. These values are written into the <code>Content-Language</code> HTTP response header. The <code>utils.escape()</code> function, employed for sanitization, performs HTML-entity encoding but fails to strip critical characters like carriage return and line feed. When the application uses an older <code>i18next</code> (&lt; 19.5.0) or produces raw detected values, CRLF sequences within the <code>lng</code> parameter reach <code>res.setHeader('Content-Language', ...)</code> without proper escaping. This flaw can result in HTTP response splitting (Node.js &lt; 14.6.0) or a denial-of-service condition (Node.js &gt;= 14.6.0), impacting all concurrent users of the affected process.  The same vulnerability is triggered multiple times per request. This issue is resolved in version 3.9.3.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>The attacker crafts a malicious HTTP request targeting an application using a vulnerable version of <code>i18next-http-middleware</code>. The request includes a <code>lng</code> parameter with a payload containing CRLF sequences (e.g., <code>%0d%0a</code>).</li>
<li>The <code>i18next-http-middleware</code> receives the request and extracts the language value from the <code>lng</code> parameter.</li>
<li>The extracted language value is passed through <code>utils.escape()</code>, which performs HTML-entity encoding but does not remove CRLF sequences.</li>
<li>The middleware attempts to set the <code>Content-Language</code> header using <code>res.setHeader()</code>, incorporating the unsanitized language value.</li>
<li>If the Node.js version is less than 14.6.0, the <code>res.setHeader()</code> function processes the CRLF sequences, resulting in HTTP response splitting. This allows the attacker to inject arbitrary headers and control parts of the response body.</li>
<li>If the Node.js version is 14.6.0 or greater, <code>res.setHeader()</code> throws an <code>ERR_INVALID_CHAR</code> error because the value contains CRLF sequences.</li>
<li>The middleware fails to catch this error, and the exception propagates, leading to an unhandled exception.</li>
<li>The unhandled exception causes the Node.js process to terminate or become unresponsive, resulting in a denial-of-service condition for all concurrent users sharing that process.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation allows attackers to inject arbitrary HTTP headers, leading to session fixation, cache poisoning, or reflected XSS attacks. In Node.js versions 14.6.0 and later, exploitation leads to a denial-of-service condition, potentially impacting all users of an application instance. This can result in significant disruption of service availability and potential data compromise. The number of affected applications is unknown, but any application using a vulnerable version of <code>i18next-http-middleware</code> is at risk.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade <code>i18next-http-middleware</code> to version 3.9.3 or later to address the vulnerability by patching the <code>utils.sanitizeHeaderValue()</code> function, as described in the advisory.</li>
<li>Deploy the Sigma rule <code>Detect i18next-http-middleware CRLF Injection Attempt</code> to monitor for exploitation attempts by detecting suspicious URL-encoded characters in HTTP requests.</li>
<li>Implement a Web Application Firewall (WAF) rule to reject requests containing <code>\r</code> or <code>\n</code> characters in query parameters, cookies, and path segments as a partial mitigation, as suggested in the advisory.</li>
<li>Enable web server logging to ensure events related to potential exploits are captured for analysis.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>crlf-injection</category><category>http-response-splitting</category><category>denial-of-service</category><category>i18next</category></item></channel></rss>