Know every vulnerabilitybefore it knows you.
DevGuard continuously monitors your dependencies and alerts you when CVEs like this one affect your stack — with real-time threat intelligence built for developers.
GHSA-8847-338w-5hcj
No affected components available
Summary
Versions of i18next-fs-backend prior to 2.6.4 interpolate the caller-supplied lng and ns values directly into the configured loadPath and addPath templates with no path-component validation and no sanitisation. When an application exposes the resolved language code to user-controlled input (?lng= query parameter, cookie, request header), a crafted value can break out of the intended locale directory.
Affected call sites in lib/index.js:
read(line 38 pre-patch):const filename = interpolate(loadPath, { lng: language, ns: namespace })removeFile(line 101 pre-patch): same pattern againstaddPathwriteFile(line 127 pre-patch): same pattern againstaddPathfor queued missing-key writes
The helper interpolate in lib/utils.js substitutes raw values with no encoding — unlike the addQueryString helper in i18next-http-backend, there is no equivalent safety for path interpolation.
Impact
- Arbitrary file read. With a
loadPathlike/locales/{{lng}}/{{ns}}.json, an attacker-controlledlng = '../../etc'(and matchingns) causes the backend to read a file outside the locale directory. For parsers that tolerate arbitrary content (YAML's freeform text), the file contents surface as a translation resource. - Arbitrary file overwrite.
addPathis interpolated the same way for missing-key writes (thecreate()code path and the debounced writer inwriteFile). A traversinglng/nscombination can cause the process to write JSON structures to an unintended filesystem location, potentially overwriting application files if the process user has write access. - Chain with
.js/.tseval.i18next-fs-backendsupports loading.jsand.tslocale files byeval-ing their content (intentional feature, documented as requiring trusted sources). Combining traversal with that path — for examplelng = '../../../app/config'againstloadPath: '/locales/{{lng}}/{{ns}}.js'— would cause the backend to execute a server-side file as JavaScript, exfiltrating whatever it can touch (process.env, connected services).
Exploitation requires the application to pass an untrusted lng/ns value through to i18next.t() without its own validation. Many i18next setups do exactly this via i18next-browser-languagedetector (query string / cookie detection).
Affected versions
All versions of i18next-fs-backend prior to 2.6.4.
Patch
Fixed in 2.6.4. lib/utils.js now exports:
isSafePathSegment(v)— returnstrueonly ifvis a non-empty string of ≤ 128 chars that does not contain..,/,\, control characters, or a prototype key (__proto__,constructor,prototype). Legitimate i18next language-code shapes (BCP-47,en_US,zh-Hant-HK,pirate-speak,my-custom.ns,+-joined multi-language values) all pass.interpolatePath(template, data)— substitutes variables like the existinginterpolatebut refuses the whole result if any segment failsisSafePathSegment. Callers bail out with an error (read) or silently drop the queued write (writeFile,removeFile).
The .js / .ts eval behaviour is intentionally retained — dynamic expressions in locale files are a documented feature of this backend, and safe replacements like dynamic import() are async-only and incompatible with this backend's sync-capable code path. The README has a new "Security considerations" section that spells out the trust model: .js/.ts locale files must be treated as code.
Workarounds
No workaround short of upgrading. If you cannot upgrade immediately, sanitise lng / ns at your application boundary before passing them to i18next — reject values containing .., /, \, control characters, and cap the length.
Credits
Discovered via an internal security audit of the i18next ecosystem.
The vulnerability can be exploited over the network without needing physical access. It is easy for an attacker to exploit this vulnerability. An attacker does not need any special privileges or access rights. No user interaction is needed for the attacker to exploit this vulnerability. The impact is confined to the system where the vulnerability exists. There is a high impact on the confidentiality of the information. There is a low impact on the integrity of the data.
Exploitation activity has been observed. Apply available patches or mitigations urgently.
The exploit probability is very low. The vulnerability is unlikely to be exploited in the next 30 days.
We did not find any exploit available. Neither in GitHub repositories nor in the Exploit-Database.
Browse More
Continuously monitor your dependencies and get alerted when vulnerabilities like this one affect your stack.
Checkout DevGuard