Skip to content

Cross-Site Scripting in i18next

Moderate severity GitHub Reviewed Published Jul 24, 2018 to the GitHub Advisory Database • Updated Sep 8, 2023

Package

npm i18next (npm)

Affected versions

>= 2.0.0, < 3.4.4

Patched versions

3.4.4

Description

Affected versions of i18next may fail to sanitize user input when certain configuration options are used. When using the .init method, passing interpolation options without passing an escapeValue will default to undefined rather than the assumed true.

Proof of Concept

var init = i18n.init({
  interpolation: {
    prefix: "__",
    suffix: "__",
    escapeValue: true
  }
}, function(){
  var test = i18n.t('__firstName__ __lastName__', {
        firstName: 'Bob',
        lastName: '["foo","bar"]',
  });
  console.log(test);
});

When escapeValue is explicitly passed, the result of test is:

&lt;script&gt;alert(1)&lt;&#x2F;script&gt; Johnson

This is supposed to be the default. However, if escapeValue is not included, the result is the unescaped string:

<script>alert(1)</script> Johnson

Recommendation

Update to version 3.4.4 or later.

References

Published to the GitHub Advisory Database Jul 24, 2018
Reviewed Jun 16, 2020
Last updated Sep 8, 2023

Severity

Moderate
6.1
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None
CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Weaknesses

CVE ID

CVE-2017-16010

GHSA ID

GHSA-cmh5-qc8w-xvcq

Source code

No known source code
Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.