<?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 — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/i18next/</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/tags/i18next/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-fs-backend Path Traversal Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2024-01-25-i18next-fs-backend-path-traversal/</link><pubDate>Thu, 25 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-25-i18next-fs-backend-path-traversal/</guid><description>i18next-fs-backend versions before 2.6.4 are vulnerable to path traversal due to insufficient sanitization of the lng and ns values, potentially allowing attackers to read arbitrary files, overwrite files, or execute code if .js or .ts locale files are in use.</description><content:encoded><![CDATA[<p>The i18next-fs-backend library, a file system backend for the i18next internationalization framework, is vulnerable to a path traversal attack in versions prior to 2.6.4. This vulnerability arises from the unsanitized use of the <code>lng</code> (language) and <code>ns</code> (namespace) parameters when constructing file paths for loading and writing locale files. If an application exposes the language code to user input, an attacker can craft a malicious <code>lng</code> or <code>ns</code> value containing directory traversal sequences (e.g., <code>../</code>) to escape the intended locale directory. Successful exploitation can lead to arbitrary file read, arbitrary file overwrite, and, if <code>.js</code> or <code>.ts</code> files are used for localization, arbitrary code execution. This vulnerability highlights the importance of input validation, especially when constructing file paths from user-controlled data. The vulnerability was patched in version 2.6.4.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker identifies an application using a vulnerable version of <code>i18next-fs-backend</code> (versions prior to 2.6.4) and exposes the language code to user input via query parameters (e.g., <code>?lng=</code>), cookies, or request headers.</li>
<li>The attacker crafts a malicious <code>lng</code> value containing directory traversal sequences, such as <code>../../../../etc</code>, to target sensitive files outside the intended locale directory.</li>
<li>The attacker sends a request to the application with the crafted <code>lng</code> parameter.</li>
<li>The application passes the unsanitized <code>lng</code> value to the <code>i18next.t()</code> function.</li>
<li>The <code>i18next-fs-backend</code> library interpolates the malicious <code>lng</code> value into the <code>loadPath</code> configuration option, without proper validation.  For example, <code>loadPath: '/locales/{{lng}}/{{ns}}.json'</code> becomes <code>/locales/../../../../etc/{{ns}}.json</code>.</li>
<li>The backend attempts to read the file specified by the crafted path (e.g., <code>/etc/passwd</code>).</li>
<li>If successful, the contents of the targeted file are returned as a translation resource, potentially exposing sensitive information. If the attacker crafted the <code>lng</code> or <code>ns</code> value to point to a <code>.js</code> or <code>.ts</code> file containing malicious code, the backend will execute the file using <code>eval()</code>, leading to arbitrary code execution on the server.</li>
<li>Alternatively, if the application attempts to write a missing translation key using the crafted path (via <code>addPath</code>), the attacker could overwrite arbitrary files on the system, potentially leading to application compromise.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability can have severe consequences. Arbitrary file read allows attackers to access sensitive data, such as configuration files, database credentials, or application source code. Arbitrary file overwrite can lead to application malfunction or complete compromise. If the application uses <code>.js</code> or <code>.ts</code> files for localization and the attacker is able to inject malicious code into those files through path traversal, arbitrary code execution can result, potentially allowing the attacker to gain full control of the server. The number of victims depends on the popularity and configuration of applications using the vulnerable <code>i18next-fs-backend</code> library.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to <code>i18next-fs-backend</code> version 2.6.4 or later to patch the path traversal vulnerability as this version introduces the <code>isSafePathSegment</code> and <code>interpolatePath</code> functions to sanitize the path.</li>
<li>If upgrading is not immediately feasible, sanitize the <code>lng</code> and <code>ns</code> values at the application boundary before passing them to <code>i18next</code>. Reject values containing <code>..</code>, <code>/</code>, <code>\</code>, control characters, and limit the length to prevent path traversal as mentioned in the advisory.</li>
<li>If using <code>.js</code> or <code>.ts</code> locale files, carefully review them for any suspicious or unexpected code. The advisory highlights that these files must be treated as trusted code.</li>
<li>Monitor web server logs for suspicious requests containing directory traversal sequences in the <code>lng</code> or <code>ns</code> parameters. Deploy the first Sigma rule for this purpose.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>path-traversal</category><category>i18next</category><category>arbitrary-file-read</category><category>arbitrary-file-write</category><category>code-execution</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>