GHSA-cmh5-qc8w-xvcq

Suggest an improvement
Source
https://github.com/advisories/GHSA-cmh5-qc8w-xvcq
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2018/07/GHSA-cmh5-qc8w-xvcq/GHSA-cmh5-qc8w-xvcq.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-cmh5-qc8w-xvcq
Aliases
Published
2018-07-24T19:58:33Z
Modified
2023-11-08T03:58:59.586536Z
Severity
  • 6.1 (Medium) CVSS_V3 - CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N CVSS Calculator
Summary
Cross-Site Scripting in i18next
Details

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:

<script>alert(1)</script> 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.

Database specific
{
    "nvd_published_at": null,
    "cwe_ids": [
        "CWE-79"
    ],
    "severity": "MODERATE",
    "github_reviewed": true,
    "github_reviewed_at": "2020-06-16T21:31:57Z"
}
References

Affected packages

npm / i18next

Package

Affected ranges

Type
SEMVER
Events
Introduced
2.0.0
Fixed
3.4.4