i18next-http-middleware has path traversal / SSRF via user-controlled language and namespace parameters

説明

Summary

Versions of i18next-http-middleware prior to 3.9.3 pass the user-controlled lng and ns values from getResourcesHandler directly into i18next.services.backendConnector.load(languages, namespaces, …) without any sanitisation. Depending on which backend is configured, the unvalidated path segments enable one of two attacks:

  • Filesystem path traversal when the middleware is paired with i18next-fs-backend (or any backend that interpolates lng / ns into a filesystem path).
  • Server-Side Request Forgery (SSRF) when the middleware is paired with i18next-http-backend (or any backend that interpolates into an HTTP URL).

Example request:

GET /locales/resources.json?lng=../../etc/passwd&ns=root

with i18next-fs-backend reads the attacker-chosen file from disk; with i18next-http-backend reshapes the outgoing URL to target an internal service.

Impact

  • Arbitrary file read via fs-style backends — any file the Node process can read becomes reachable (source, configuration, .ssh keys, .env, Docker secrets, etc.).
  • SSRF via http-style backends — requests to internal IPs / hostnames not normally reachable from the internet; combined with cloud metadata endpoints this can escalate to credential theft.
  • Unbounded growth of i18next.options.ns — a now-incidental amplification: the pre-patch getResourcesHandler pushed every unique ns value into the shared i18next.options.ns singleton array without validation or bounds, enabling memory exhaustion from repeated unique payloads.

The severity is bounded by the backend in place, but the middleware itself exposed the unsanitised path; this is the "weakest link" layer.

Affected versions

< 3.9.3.

Patch

Fixed in 3.9.3. The patch introduces utils.isSafeIdentifier and applies it in getResourcesHandler before lng and ns reach the backend connector:

languages  = languages.filter(utils.isSafeIdentifier)
namespaces = namespaces.filter(utils.isSafeIdentifier)

isSafeIdentifier uses a denylist approach — it still accepts any legitimate i18next language-code shape (i18next FAQ) — rejecting:

  • .. sequences (relative path traversal)
  • path separators (/, \)
  • control characters (C0/C1)
  • prototype keys (__proto__ / constructor / prototype)
  • empty strings and values longer than 128 characters

Unsafe values are dropped; only safe values reach the backend. The fix is a defence-in-depth layer on top of any sanitisation the backend itself may apply.

Workarounds

No workaround short of upgrading. Front-proxying the middleware with a WAF rule that rejects requests containing .., /, \, or URL-structure characters in lng / ns is a partial mitigation. Upgrading the configured backend (i18next-fs-backend ≥ 2.6.4, i18next-http-backend ≥ 3.0.5) also closes the same attack at the next layer.

Related advisories fixed in the same release

  • GHSA-5fgg-jcpf-8jjw — prototype pollution via setPath and missingKeyHandler. Independently fixable, filed separately per CNA rules.
  • GHSA-c3h8-g69v-pjrg — HTTP response splitting + XSS-filter bypass (CVE-2026-41683).

Credits

Discovered via an internal security audit of the i18next ecosystem.

Resources

基本情報

タイプ
reviewed
深刻度
high
GitHub 上のアドバイザリ
アドバイザリを開く ↗
リポジトリのアドバイザリ
リポジトリのアドバイザリを開く ↗
ソースコード
ソースを見る ↗
公開(アドバイザリ)
2026-04-29 22:26:36 UTC
更新
2026-05-13 13:30:17 UTC
GitHub レビュー済み
2026-04-29 22:26:36 UTC
NVD で公開
2026-05-08

EPSS Score

Score Percentile
0.07% 21.03%

CVSS Scores

Base score Version Severity Vector
8.2 3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N クリックして展開
攻撃ベクター (AV:N)
インターネットなど、ルーティングされたネットワーク越しに遠隔から悪用しうる。端末の前にいる必要はない。
攻撃の複雑さ (AC:L)
攻撃者が条件を満たせば、レース条件や珍しい構成に依存せずに再現しやすい。
必要な権限 (PR:N)
事前のログインや昇格は不要で、匿名アクセスのまま踏み台にしうる。
ユーザーの関与 (UI:N)
メールのリンクを開く、マクロを有効にするなど、被害者の協力がなくても成立しうる。
スコープ (S:U)
影響は脆弱コンポーネントと同一のセキュリティ権限・信頼境界の内側に収まる。
機密性への影響 (C:H)
広範な機微データの読み取りや持ち出しが現実的。
完全性への影響 (I:L)
レコードの一部書き換えや設定の歪みなど、限定的だが検知・復旧が必要な水準。
可用性への影響 (A:N)
業務継続に支障が出るレベルの停止や劣化は想定されない。

Identifiers

CWEs

CWE id Name
CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
CWE-918 Server-Side Request Forgery (SSRF)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
npm i18next-http-middleware < 3.9.3 3.9.3

References

cvelogic Threat Intelligence