<?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-Fs-Backend — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/i18next-fs-backend/</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>Thu, 25 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/i18next-fs-backend/feed.xml" rel="self" type="application/rss+xml"/><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></channel></rss>