Vulnerabilities

75 via 289 paths

Dependencies

756

Source

GitHub

Commit

5daab250

Find, fix and prevent vulnerabilities in your code.

Severity
  • 4
  • 32
  • 30
  • 9
Status
  • 75
  • 0
  • 0

critical severity

Improper Input Validation

  • Vulnerable module: xmldom
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmldom@0.1.31
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 xcode@0.9.3 simple-plist@0.2.1 plist@2.0.1 xmldom@0.1.31

Overview

xmldom is an A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.

Affected versions of this package are vulnerable to Improper Input Validation due to parsing XML that is not well-formed, and contains multiple top-level elements. All the root nodes are being added to the childNodes collection of the Document, without reporting or throwing any error.

Workarounds

One of the following approaches might help, depending on your use case:

  1. Instead of searching for elements in the whole DOM, only search in the documentElement.

  2. Reject a document with a document that has more than 1 childNode.

PoC

var DOMParser = require('xmldom').DOMParser;
var xmlData = '<?xml version="1.0" encoding="UTF-8"?>\n' +
'<root>\n' +
'  <branch girth="large">\n' +
'    <leaf color="green" />\n' +
'  </branch>\n' +
'</root>\n' +
'<root>\n' +
'  <branch girth="twig">\n' +
'    <leaf color="gold" />\n' +
'  </branch>\n' +
'</root>\n';
var xmlDOM = new DOMParser().parseFromString(xmlData);
console.log(xmlDOM.toString());

This will result with the following output:

<?xml version="1.0" encoding="UTF-8"?><root>
  <branch girth="large">
    <leaf color="green"/>
  </branch>
</root>
<root>
  <branch girth="twig">
    <leaf color="gold"/>
  </branch>
</root>

Remediation

There is no fixed version for xmldom.

References

critical severity

Predictable Value Range from Previous Values

  • Vulnerable module: form-data
  • Introduced through: realm@1.13.0 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 request@2.88.2 form-data@2.3.3
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 request@2.88.2 form-data@2.3.3
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 form-data@2.1.4

Overview

Affected versions of this package are vulnerable to Predictable Value Range from Previous Values via the boundary value, which uses Math.random(). An attacker can manipulate HTTP request boundaries by exploiting predictable values, potentially leading to HTTP parameter pollution.

Remediation

Upgrade form-data to version 2.5.4, 3.0.4, 4.0.4 or higher.

References

critical severity

Incomplete List of Disallowed Inputs

  • Vulnerable module: babel-traverse
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-core@6.26.3 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-core@6.26.3 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-plugin-transform-class-properties@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-core@6.26.3 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-core@6.26.3 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-register@6.26.0 babel-core@6.26.3 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-plugin-transform-class-properties@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-plugin-transform-async-to-generator@6.16.0 babel-helper-remap-async-to-generator@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-core@6.26.3 babel-helpers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-core@6.26.3 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-core@6.26.3 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-register@6.26.0 babel-core@6.26.3 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-plugin-transform-class-properties@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-plugin-transform-async-to-generator@6.16.0 babel-helper-remap-async-to-generator@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-register@6.26.0 babel-core@6.26.3 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-plugin-transform-async-to-generator@6.16.0 babel-helper-remap-async-to-generator@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-block-scoping@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-block-scoping@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-block-scoping@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-classes@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-es2015-node@6.1.1 babel-plugin-transform-es2015-parameters@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-core@6.26.3 babel-helpers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-core@6.26.3 babel-helpers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-register@6.26.0 babel-core@6.26.3 babel-helpers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-register@6.26.0 babel-core@6.26.3 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-plugin-transform-async-to-generator@6.16.0 babel-helper-remap-async-to-generator@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-class-properties@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-class-properties@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-class-properties@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-block-scoping@6.26.0 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-block-scoping@6.26.0 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-block-scoping@6.26.0 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-classes@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-computed-properties@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-computed-properties@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-computed-properties@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-modules-commonjs@6.26.2 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-modules-commonjs@6.26.2 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-es2015-node@6.1.1 babel-plugin-transform-es2015-modules-commonjs@6.26.2 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-modules-commonjs@6.26.2 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-es2015-node@6.1.1 babel-plugin-transform-es2015-parameters@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-class-properties@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-class-properties@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-class-properties@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-function-name@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-function-name@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-es2015-node@6.1.1 babel-plugin-transform-es2015-function-name@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-function-name@6.24.1 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-replace-supers@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-replace-supers@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-replace-supers@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-object-super@6.24.1 babel-helper-replace-supers@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-object-super@6.24.1 babel-helper-replace-supers@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-helper-call-delegate@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-helper-call-delegate@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-es2015-node@6.1.1 babel-plugin-transform-es2015-parameters@6.24.1 babel-helper-call-delegate@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-parameters@6.24.1 babel-helper-call-delegate@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-helpers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-register@6.26.0 babel-core@6.26.3 babel-helpers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-class-properties@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-class-properties@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-class-properties@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-function-name@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-function-name@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-es2015-node@6.1.1 babel-plugin-transform-es2015-function-name@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-function-name@6.24.1 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-replace-supers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-replace-supers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-replace-supers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-object-super@6.24.1 babel-helper-replace-supers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-object-super@6.24.1 babel-helper-replace-supers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-define-map@6.26.0 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-define-map@6.26.0 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-define-map@6.26.0 babel-helper-function-name@6.24.1 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-helpers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 babel-helpers@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-define-map@6.26.0 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-fbjs@2.3.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-define-map@6.26.0 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-preset-react-native@2.1.0 babel-plugin-transform-es2015-classes@6.24.1 babel-helper-define-map@6.26.0 babel-helper-function-name@6.24.1 babel-template@6.26.0 babel-traverse@6.26.0

Overview

Affected versions of this package are vulnerable to Incomplete List of Disallowed Inputs when using plugins that rely on the path.evaluate() or path.evaluateTruthy() internal Babel methods.

Note:

This is only exploitable if the attacker uses known affected plugins such as @babel/plugin-transform-runtime, @babel/preset-env when using its useBuiltIns option, and any "polyfill provider" plugin that depends on @babel/helper-define-polyfill-provider. No other plugins under the @babel/ namespace are impacted, but third-party plugins might be.

Users that only compile trusted code are not impacted.

Workaround

Users who are unable to upgrade the library can upgrade the affected plugins instead, to avoid triggering the vulnerable code path in affected @babel/traverse.

Remediation

There is no fixed version for babel-traverse.

References

critical severity

Authentication Bypass

  • Vulnerable module: hawk
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 hawk@3.1.3
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 hawk@3.1.3

Overview

hawk is a library for the HTTP Hawk Authentication Scheme.

Affected versions of this package are vulnerable to Authentication Bypass. The incoming (client supplied) hash of the payload is trusted by the server and not verified before the signature is calculated.

A malicious actor in the middle can alter the payload and the server side will not identify the modification occurred because it simply uses the client provided value instead of verify the hash provided against the modified payload.

According to the maintainers this issue is to be considered out of scope as "payload hash validation is optional and up to developer to implement".

Remediation

There is no fixed version for hawk.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: cross-spawn
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 cross-spawn@5.1.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 envinfo@3.11.1 clipboardy@1.2.3 execa@0.8.0 cross-spawn@5.1.0
    Remediation: Upgrade to react-native@0.59.0.

Overview

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to improper input sanitization. An attacker can increase the CPU usage and crash the program by crafting a very large and well crafted string.

PoC

const { argument } = require('cross-spawn/lib/util/escape');
var str = "";
for (var i = 0; i < 1000000; i++) {
  str += "\\";
}
str += "◎";

console.log("start")
argument(str)
console.log("end")

// run `npm install cross-spawn` and `node attack.js` 
// then the program will stuck forever with high CPU usage

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade cross-spawn to version 6.0.6, 7.0.5 or higher.

References

high severity

Uninitialized Memory Exposure

  • Vulnerable module: base64-url
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 express-session@1.11.3 uid-safe@2.0.0 base64-url@1.2.1
    Remediation: Upgrade to react-native@0.63.0.

Overview

base64-url Base64 encode, decode, escape and unescape for URL applications.

Affected versions of this package are vulnerable to Uninitialized Memory Exposure. An attacker may extract sensitive data from uninitialized memory or may cause a DoS by passing in a large number, in setups where typed user input can be passed (e.g. from JSON).

Details

The Buffer class on Node.js is a mutable array of binary data, and can be initialized with a string, array or number.

const buf1 = new Buffer([1,2,3]);
// creates a buffer containing [01, 02, 03]
const buf2 = new Buffer('test');
// creates a buffer containing ASCII bytes [74, 65, 73, 74]
const buf3 = new Buffer(10);
// creates a buffer of length 10

The first two variants simply create a binary representation of the value it received. The last one, however, pre-allocates a buffer of the specified size, making it a useful buffer, especially when reading data from a stream. When using the number constructor of Buffer, it will allocate the memory, but will not fill it with zeros. Instead, the allocated buffer will hold whatever was in memory at the time. If the buffer is not zeroed by using buf.fill(0), it may leak sensitive information like keys, source code, and system info.

Remediation

Upgrade base64-url to version 2.0.0 or higher. Note This is vulnerable only for Node <=4

References

high severity

Arbitrary File Write

  • Vulnerable module: tar
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to realm@2.15.2.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 tar@2.2.2

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Arbitrary File Write. node-tar aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created.

This logic was insufficient when extracting tar files that contained both a directory and a symlink with the same name as the directory, where the symlink and directory names in the archive entry used backslashes as a path separator on posix systems. The cache checking logic used both \ and / characters as path separators. However, \ is a valid filename character on posix systems.

By first creating a directory, and then replacing that directory with a symlink, it is possible to bypass node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location. This can lead to extracting arbitrary files into that location, thus allowing arbitrary file creation and overwrite.

Additionally, a similar confusion could arise on case-insensitive filesystems. If a tar archive contained a directory at FOO, followed by a symbolic link named foo, then on case-insensitive file systems, the creation of the symbolic link would remove the directory from the filesystem, but not from the internal directory cache, as it would not be treated as a cache hit. A subsequent file entry within the FOO directory would then be placed in the target of the symbolic link, thinking that the directory had already been created.

Remediation

Upgrade tar to version 6.1.7, 5.0.8, 4.4.16 or higher.

References

high severity

Arbitrary File Write

  • Vulnerable module: tar
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to realm@2.15.2.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 tar@2.2.2

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Arbitrary File Write. node-tar aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created.

This logic is insufficient when extracting tar files that contain two directories and a symlink with names containing unicode values that normalized to the same value. Additionally, on Windows systems, long path portions would resolve to the same file system entities as their 8.3 "short path" counterparts. A specially crafted tar archive can include directories with two forms of the path that resolve to the same file system entity, followed by a symbolic link with a name in the first form, lastly followed by a file using the second form. This leads to bypassing node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and extracting arbitrary files into that location.

Remediation

Upgrade tar to version 6.1.9, 5.0.10, 4.4.18 or higher.

References

high severity

Arbitrary File Write

  • Vulnerable module: tar
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to realm@2.15.2.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 tar@2.2.2

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Arbitrary File Write. node-tar aims to guarantee that any file whose location would be outside of the extraction target directory is not extracted. This is, in part, accomplished by sanitizing absolute paths of entries within the archive, skipping archive entries that contain .. path portions, and resolving the sanitized paths against the extraction target directory.

This logic is insufficient on Windows systems when extracting tar files that contain a path that is not an absolute path, but specify a drive letter different from the extraction target, such as C:some\path. If the drive letter does not match the extraction target, for example D:\extraction\dir, then the result of path.resolve(extractionDirectory, entryPath) resolves against the current working directory on the C: drive, rather than the extraction target directory.

Additionally, a .. portion of the path can occur immediately after the drive letter, such as C:../foo, and is not properly sanitized by the logic that checks for .. within the normalized and split portions of the path.

Note: This only affects users of node-tar on Windows systems.

Remediation

Upgrade tar to version 6.1.9, 5.0.10, 4.4.18 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: xmldom
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmldom@0.1.31
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 xcode@0.9.3 simple-plist@0.2.1 plist@2.0.1 xmldom@0.1.31

Overview

xmldom is an A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.

Affected versions of this package are vulnerable to Prototype Pollution through the copy() function in dom.js. Exploiting this vulnerability is possible via the p variable.

DISPUTED This vulnerability has been disputed by the maintainers of the package. Currently the only viable exploit that has been demonstrated is to pollute the target object (rather then the global object which is generally the case for Prototype Pollution vulnerabilities) and it is yet unclear if this limited attack vector exposes any vulnerability in the context of this package.

See the linked GitHub Issue for full details on the discussion around the legitimacy and potential revocation of this vulnerability.

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

There is no fixed version for xmldom.

References

high severity

Asymmetric Resource Consumption (Amplification)

  • Vulnerable module: body-parser
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 body-parser@1.13.3
    Remediation: Upgrade to react-native@0.63.0.

Overview

Affected versions of this package are vulnerable to Asymmetric Resource Consumption (Amplification) via the extendedparser and urlencoded functions when the URL encoding process is enabled. An attacker can flood the server with a large number of specially crafted requests.

Remediation

Upgrade body-parser to version 1.20.3 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.20.

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Prototype Pollution. The function zipObjectDeep can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects.

PoC

const _ = require('lodash');

_.zipObjectDeep(['__proto__.z'],[123]);

console.log(z); // 123

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade lodash to version 4.17.20 or higher.

References

high severity

Arbitrary File Overwrite

  • Vulnerable module: tar
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to realm@2.15.2.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 tar@2.2.2

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Arbitrary File Overwrite. This is due to insufficient symlink protection. node-tar aims to guarantee that any file whose location would be modified by a symbolic link is not extracted. This is, in part, achieved by ensuring that extracted directories are not symlinks. Additionally, in order to prevent unnecessary stat calls to determine whether a given path is a directory, paths are cached when directories are created.

This logic is insufficient when extracting tar files that contain both a directory and a symlink with the same name as the directory. This order of operations results in the directory being created and added to the node-tar directory cache. When a directory is present in the directory cache, subsequent calls to mkdir for that directory are skipped. However, this is also where node-tar checks for symlinks occur. By first creating a directory, and then replacing that directory with a symlink, it is possible to bypass node-tar symlink checks on directories, essentially allowing an untrusted tar file to symlink into an arbitrary location and subsequently extracting arbitrary files into that location.

Remediation

Upgrade tar to version 3.2.3, 4.4.15, 5.0.7, 6.1.2 or higher.

References

high severity

Arbitrary File Overwrite

  • Vulnerable module: tar
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to realm@2.15.2.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 tar@2.2.2

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Arbitrary File Overwrite. This is due to insufficient absolute path sanitization.

node-tar aims to prevent extraction of absolute file paths by turning absolute paths into relative paths when the preservePaths flag is not set to true. This is achieved by stripping the absolute path root from any absolute file paths contained in a tar file. For example, the path /home/user/.bashrc would turn into home/user/.bashrc.

This logic is insufficient when file paths contain repeated path roots such as ////home/user/.bashrc. node-tar only strips a single path root from such paths. When given an absolute file path with repeating path roots, the resulting path (e.g. ///home/user/.bashrc) still resolves to an absolute path.

Remediation

Upgrade tar to version 3.2.2, 4.4.14, 5.0.6, 6.1.1 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: ajv
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 har-validator@4.2.1 ajv@4.11.8
    Remediation: Upgrade to realm@10.3.0.

Overview

ajv is an Another JSON Schema Validator

Affected versions of this package are vulnerable to Prototype Pollution. A carefully crafted JSON schema could be provided that allows execution of other code by prototype pollution. (While untrusted schemas are recommended against, the worst case of an untrusted schema should be a denial of service, not execution of code.)

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade ajv to version 6.12.3 or higher.

References

high severity

Remote Code Execution (RCE)

  • Vulnerable module: shell-quote
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 shell-quote@1.6.1
    Remediation: Upgrade to react-native@0.60.0.

Overview

shell-quote is a package used to quote and parse shell commands.

Affected versions of this package are vulnerable to Remote Code Execution (RCE). An attacker can inject unescaped shell metacharacters through a regex designed to support Windows drive letters. If the output of this package is passed to a real shell as a quoted argument to a command with exec(), an attacker can inject arbitrary commands. This is because the Windows drive letter regex character class is {A-z] instead of the correct {A-Za-z]. Several shell metacharacters exist in the space between capital letter Z and lower case letter a, such as the backtick character.

Remediation

Upgrade shell-quote to version 1.7.3 or higher.

References

high severity

Improper Verification of Cryptographic Signature

  • Vulnerable module: jsrsasign
  • Introduced through: oidc-client-fetch@1.2.2-fetch1

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 jsrsasign@5.1.0

Overview

jsrsasign is a free pure JavaScript cryptographic library.

Affected versions of this package are vulnerable to Improper Verification of Cryptographic Signature when JWS or JWT signature with non Base64URL encoding special characters or number escaped characters may be validated as valid by mistake.

Workaround:

Validate JWS or JWT signature if it has Base64URL and dot safe string before executing JWS.verify() or JWS.verifyJWT() method.

PoC:

var KJUR = require('jsrsasign');
var rsu = require('jsrsasign-util');

// jsrsasign@10.5.24

//// creating valid hs256 jwt - code used to get valid hs256 jwt.
// var oHeader = {alg: 'HS256', typ: 'JWT'};
// // Payload
// var oPayload = {};
// var tNow = KJUR.jws.IntDate.get('now');
// var tEnd = KJUR.jws.IntDate.get('now + 1year');
// oPayload.iss = "https://urldefense.proofpoint.com/v2/url?u=http-3A__foo.com&d=DwIGAg&c=wwDYKmuffy0jxUGHACmjfA&r=3J3pjDmBp7lIUZbkdHkHLg&m=CP36zULZ4
oa9S7i8rFsa5Rei7n32BgBaGjoG8lCiqO-pm9ZIzxG9adHdbUE4qski&s=eMfp9lSTyBb95UqdO_sO3ukTKlGihPESsUm5F4yotGk&e= ";
// oPayload.sub = "mailto:mike@foo.com";
// oPayload.nbf = tNow;
// oPayload.iat = tNow;
// oPayload.exp = tEnd;
// oPayload.jti = "id123456";
// oPayload.aud = "https://urldefense.proofpoint.com/v2/url?u=http-3A__foo.com_employee&d=DwIGAg&c=wwDYKmuffy0jxUGHACmjfA&r=3J3pjDmBp7lIUZbkdHkHLg&m=C
P36zULZ4oa9S7i8rFsa5Rei7n32BgBaGjoG8lCiqO-pm9ZIzxG9adHdbUE4qski&s=bxlm95BhVv7dbGuy_vRD4JBci6ODNdgOU7Q7bNPkv48&e= ";
// // Sign JWT, password=616161
// var sHeader = JSON.stringify(oHeader);
// var sPayload = JSON.stringify(oPayload);
// var sJWT = KJUR.jws.JWS.sign("HS256", sHeader, sPayload, "616161");


//verifying valid and invalid hs256 jwt
//validjwt
var validJwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vZm9vLmNvbSIsInN1YiI6Im1haWx0bzp
taWtlQGZvby5jb20iLCJuYmYiOjE2NTUyMjk3MjksImlhdCI6MTY1NTIyOTcyOSwiZXhwIjoxNjg2NzY1NzI5LC
JqdGkiOiJpZDEyMzQ1NiIsImF1ZCI6Imh0dHA6Ly9mb28uY29tL2VtcGxveWVlIn0.eqrgPFuchnot7HgslW8S
1xQUkTDBW-_cyhrPgOOFRzI";
//invalid jwt with special signs
var invalidJwt1 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vZm9vLmNvbSIsInN1YiI6Im1haWx0bzp
taWtlQGZvby5jb20iLCJuYmYiOjE2NTUyMjk3MjksImlhdCI6MTY1NTIyOTcyOSwiZXhwIjoxNjg2NzY1NzI5LC
JqdGkiOiJpZDEyMzQ1NiIsImF1ZCI6Imh0dHA6Ly9mb28uY29tL2VtcGxveWVlIn0.eqrgPFuchno!@#$%^&*
()!@#$%^&*()!@#$%^&*()!@#$%^&*()t7HgslW8S1xQUkTDBW-_cyhrPgOOFRzI";
//invalid jwt with additional numbers and signs
var invalidJwt2 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vZm9vLmNvbSIsInN1YiI6Im1haWx0bzp
taWtlQGZvby5jb20iLCJuYmYiOjE2NTUyMjk3MjksImlhdCI6MTY1NTIyOTcyOSwiZXhwIjoxNjg2NzY1NzI5LC
JqdGkiOiJpZDEyMzQ1NiIsImF1ZCI6Imh0dHA6Ly9mb28uY29tL2VtcGxveWVlIn0.eqrgPFuchno\1\1\2\3\4
\2\2\3\2\1\2\222\3\1\1\2\2\2\2\2\2\2\2\2\2\2\2\222\23\2\2\2\2t7HgslW8S1xQUkTDBW-_cyhrPgOOFRzI";


var isValid = KJUR.jws.JWS.verifyJWT(validJwt, "616161", {alg: ['HS256']});
console.log("valid hs256 Jwt: " + isValid); //valid Jwt: true

//verifying invalid  1 hs256 jwt
var isValid = KJUR.jws.JWS.verifyJWT(invalidJwt1, "616161", {alg: ['HS256']});
console.log("invalid hs256  Jwt by special signs: " + isValid); //invalid Jwt  by special signs: true

//verifying invalid 2 hs256 jwt
var isValid = KJUR.jws.JWS.verifyJWT(invalidJwt2, "616161", {alg: ['HS256']});
console.log("invalid hs256  Jwt by additional numbers and slashes: " + isValid); //invalid Jwt by additional numbers and slashes: true

Remediation

Upgrade jsrsasign to version 10.5.25 or higher.

References

high severity

Excessive Platform Resource Consumption within a Loop

  • Vulnerable module: braces
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 micromatch@2.3.11 braces@1.8.5
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 micromatch@3.1.10 braces@2.3.2
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 anymatch@2.0.0 micromatch@3.1.10 braces@2.3.2

Overview

braces is a Bash-like brace expansion, implemented in JavaScript.

Affected versions of this package are vulnerable to Excessive Platform Resource Consumption within a Loop due improper limitation of the number of characters it can handle, through the parse function. An attacker can cause the application to allocate excessive memory and potentially crash by sending imbalanced braces as input.

PoC

const { braces } = require('micromatch');

console.log("Executing payloads...");

const maxRepeats = 10;

for (let repeats = 1; repeats <= maxRepeats; repeats += 1) {
  const payload = '{'.repeat(repeats*90000);

  console.log(`Testing with ${repeats} repeats...`);
  const startTime = Date.now();
  braces(payload);
  const endTime = Date.now();
  const executionTime = endTime - startTime;
  console.log(`Regex executed in ${executionTime / 1000}s.\n`);
} 

Remediation

Upgrade braces to version 3.0.3 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: fresh
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 fresh@0.3.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-favicon@2.3.2 fresh@0.3.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-static@1.10.3 send@0.13.2 fresh@0.3.0
    Remediation: Upgrade to react-native@0.63.0.

Overview

fresh is HTTP response freshness testing.

Affected versions of this package are vulnerable to Regular expression Denial of Service (ReDoS) attacks. A Regular Expression (/ *, */) was used for parsing HTTP headers and take about 2 seconds matching time for 50k characters.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade fresh to version 0.5.2 or higher.

References

high severity

Observable Discrepancy

  • Vulnerable module: jsrsasign
  • Introduced through: oidc-client-fetch@1.2.2-fetch1

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 jsrsasign@5.1.0

Overview

jsrsasign is a free pure JavaScript cryptographic library.

Affected versions of this package are vulnerable to Observable Discrepancy via the RSA PKCS#1.5 or RSAOAEP decryption process. An attacker can decrypt ciphertexts by exploiting the Marvin security flaw. Exploiting this vulnerability requires the attacker to have access to a large number of ciphertexts encrypted with the same key.

Workaround

The vulnerability can be mitigated by finding and replacing RSA and RSAOAEP decryption with another crypto library.

Remediation

Upgrade jsrsasign to version 11.0.0 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.17.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmlbuilder@4.0.0 lodash@3.10.1

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Prototype Pollution through the zipObjectDeep function due to improper user input sanitization in the baseZipObject function.

PoC

lodash.zipobjectdeep:

const zipObjectDeep = require("lodash.zipobjectdeep");

let emptyObject = {};


console.log(`[+] Before prototype pollution : ${emptyObject.polluted}`);
//[+] Before prototype pollution : undefined

zipObjectDeep(["constructor.prototype.polluted"], [true]);
//we inject our malicious attributes in the vulnerable function

console.log(`[+] After prototype pollution : ${emptyObject.polluted}`);
//[+] After prototype pollution : true

lodash:

const test = require("lodash");

let emptyObject = {};


console.log(`[+] Before prototype pollution : ${emptyObject.polluted}`);
//[+] Before prototype pollution : undefined

test.zipObjectDeep(["constructor.prototype.polluted"], [true]);
//we inject our malicious attributes in the vulnerable function

console.log(`[+] After prototype pollution : ${emptyObject.polluted}`);
//[+] After prototype pollution : true

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade lodash to version 4.17.17 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: merge
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 exec-sh@0.2.2 merge@1.2.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 watch@0.18.0 exec-sh@0.2.2 merge@1.2.1

Overview

merge is a library that allows you to merge multiple objects into one, optionally creating a new cloned object. Similar to the jQuery.extend but more flexible. Works in Node.js and the browser.

Affected versions of this package are vulnerable to Prototype Pollution. The 'merge' function already checks for 'proto' keys in an object to prevent prototype pollution, but does not check for 'constructor' or 'prototype' keys.

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade merge to version 2.1.0 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: negotiator
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 compression@1.5.2 accepts@1.2.13 negotiator@0.5.3
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-index@1.7.3 accepts@1.2.13 negotiator@0.5.3
    Remediation: Upgrade to react-native@0.63.0.

Overview

negotiator is an HTTP content negotiator for Node.js.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) when parsing Accept-Language http header.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade negotiator to version 0.6.1 or higher.

References

high severity

Prototype Override Protection Bypass

  • Vulnerable module: qs
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 qs@4.0.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 body-parser@1.13.3 qs@4.0.0
    Remediation: Upgrade to react-native@0.63.0.

Overview

qs is a querystring parser that supports nesting and arrays, with a depth limit.

Affected versions of this package are vulnerable to Prototype Override Protection Bypass. By default qs protects against attacks that attempt to overwrite an object's existing prototype properties, such as toString(), hasOwnProperty(),etc.

From qs documentation:

By default parameters that would overwrite properties on the object prototype are ignored, if you wish to keep the data from those fields either use plainObjects as mentioned above, or set allowPrototypes to true which will allow user input to overwrite those properties. WARNING It is generally a bad idea to enable this option as it can cause problems when attempting to use the properties that have been overwritten. Always be careful with this option.

Overwriting these properties can impact application logic, potentially allowing attackers to work around security controls, modify data, make the application unstable and more.

In versions of the package affected by this vulnerability, it is possible to circumvent this protection and overwrite prototype properties and functions by prefixing the name of the parameter with [ or ]. e.g. qs.parse("]=toString") will return {toString = true}, as a result, calling toString() on the object will throw an exception.

Example:

qs.parse('toString=foo', { allowPrototypes: false })
// {}

qs.parse("]=toString", { allowPrototypes: false })
// {toString = true} <== prototype overwritten

For more information, you can check out our blog.

Disclosure Timeline

  • February 13th, 2017 - Reported the issue to package owner.
  • February 13th, 2017 - Issue acknowledged by package owner.
  • February 16th, 2017 - Partial fix released in versions 6.0.3, 6.1.1, 6.2.2, 6.3.1.
  • March 6th, 2017 - Final fix released in versions 6.4.0,6.3.2, 6.2.3, 6.1.2 and 6.0.4

Remediation

Upgrade qs to version 6.0.4, 6.1.2, 6.2.3, 6.3.2 or higher.

References

high severity

Prototype Poisoning

  • Vulnerable module: qs
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 qs@4.0.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 body-parser@1.13.3 qs@4.0.0
    Remediation: Upgrade to react-native@0.63.0.

Overview

qs is a querystring parser that supports nesting and arrays, with a depth limit.

Affected versions of this package are vulnerable to Prototype Poisoning which allows attackers to cause a Node process to hang, processing an Array object whose prototype has been replaced by one with an excessive length value.

Note: In many typical Express use cases, an unauthenticated remote attacker can place the attack payload in the query string of the URL that is used to visit the application, such as a[__proto__]=b&a[__proto__]&a[length]=100000000.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.

Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.

One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.

When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.

Two common types of DoS vulnerabilities:

  • High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.

  • Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm ws package

Remediation

Upgrade qs to version 6.2.4, 6.3.3, 6.4.1, 6.5.3, 6.6.1, 6.7.3, 6.8.3, 6.9.7, 6.10.3 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: unset-value
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 micromatch@3.1.10 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 micromatch@3.1.10 braces@2.3.2 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 micromatch@3.1.10 extglob@2.0.4 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 micromatch@3.1.10 nanomatch@1.2.13 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 anymatch@2.0.0 micromatch@3.1.10 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 anymatch@2.0.0 micromatch@3.1.10 braces@2.3.2 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 micromatch@3.1.10 extglob@2.0.4 expand-brackets@2.1.4 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 anymatch@2.0.0 micromatch@3.1.10 extglob@2.0.4 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 anymatch@2.0.0 micromatch@3.1.10 nanomatch@1.2.13 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 anymatch@2.0.0 micromatch@3.1.10 extglob@2.0.4 expand-brackets@2.1.4 snapdragon@0.8.2 base@0.11.2 cache-base@1.0.1 unset-value@1.0.0

Overview

Affected versions of this package are vulnerable to Prototype Pollution via the unset function in index.js, because it allows access to object prototype properties.

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade unset-value to version 2.0.1 or higher.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: ws
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 react-devtools-core@2.5.2 ws@2.3.1
    Remediation: Upgrade to react-native@0.62.0.

Overview

ws is a simple to use websocket client, server and console for node.js.

Affected versions of this package are vulnerable to Denial of Service (DoS) when the number of received headers exceed the server.maxHeadersCount or request.maxHeadersCount threshold.

Workaround

This issue can be mitigating by following these steps:

  1. Reduce the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options so that no more headers than the server.maxHeadersCount limit can be sent.

  2. Set server.maxHeadersCount to 0 so that no limit is applied.

PoC


const http = require('http');
const WebSocket = require('ws');

const server = http.createServer();

const wss = new WebSocket.Server({ server });

server.listen(function () {
  const chars = "!#$%&'*+-.0123456789abcdefghijklmnopqrstuvwxyz^_`|~".split('');
  const headers = {};
  let count = 0;

  for (let i = 0; i < chars.length; i++) {
    if (count === 2000) break;

    for (let j = 0; j < chars.length; j++) {
      const key = chars[i] + chars[j];
      headers[key] = 'x';

      if (++count === 2000) break;
    }
  }

  headers.Connection = 'Upgrade';
  headers.Upgrade = 'websocket';
  headers['Sec-WebSocket-Key'] = 'dGhlIHNhbXBsZSBub25jZQ==';
  headers['Sec-WebSocket-Version'] = '13';

  const request = http.request({
    headers: headers,
    host: '127.0.0.1',
    port: server.address().port
  });

  request.end();
});

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.

Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.

One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.

When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.

Two common types of DoS vulnerabilities:

  • High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.

  • Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm ws package

Remediation

Upgrade ws to version 5.2.4, 6.2.3, 7.5.10, 8.17.1 or higher.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: ws
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 react-devtools-core@2.5.2 ws@2.3.1
    Remediation: Upgrade to react-native@0.56.0.

Overview

ws is a simple to use websocket client, server and console for node.js.

Affected versions of this package are vulnerable to Denial of Service (DoS) attacks. A specially crafted value of the Sec-WebSocket-Extensions header that used Object.prototype property names as extension or parameter names could be used to make a ws server crash.

PoC:

const WebSocket = require('ws');
const net = require('net');

const wss = new WebSocket.Server({ port: 3000 }, function () {
  const payload = 'constructor';  // or ',;constructor'

  const request = [
    'GET / HTTP/1.1',
    'Connection: Upgrade',
    'Sec-WebSocket-Key: test',
    'Sec-WebSocket-Version: 8',
    `Sec-WebSocket-Extensions: ${payload}`,
    'Upgrade: websocket',
    '\r\n'
  ].join('\r\n');

  const socket = net.connect(3000, function () {
    socket.resume();
    socket.write(request);
  });
});

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its intended and legitimate users.

Unlike other vulnerabilities, DoS attacks usually do not aim at breaching security. Rather, they are focused on making websites and services unavailable to genuine users resulting in downtime.

One popular Denial of Service vulnerability is DDoS (a Distributed Denial of Service), an attack that attempts to clog network pipes to the system by generating a large volume of traffic from many machines.

When it comes to open source libraries, DoS vulnerabilities allow attackers to trigger such a crash or crippling of the service by using a flaw either in the application code or from the use of open source libraries.

Two common types of DoS vulnerabilities:

  • High CPU/Memory Consumption- An attacker sending crafted requests that could cause the system to take a disproportionate amount of time to process. For example, commons-fileupload:commons-fileupload.

  • Crash - An attacker sending crafted requests that could cause the system to crash. For Example, npm ws package

Remediation

Upgrade ws to version 1.1.5, 3.3.1 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: hawk
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 hawk@3.1.3
    Remediation: Upgrade to realm@10.3.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 hawk@3.1.3
    Remediation: Upgrade to realm@10.3.0.

Overview

hawk is a library for the HTTP Hawk Authentication Scheme.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in header parsing where each added character in the attacker's input increases the computation time exponentially.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade hawk to version 9.0.1 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.12.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmlbuilder@4.0.0 lodash@3.10.1

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Prototype Pollution. The function defaultsDeep could be tricked into adding or modifying properties of Object.prototype using a constructor payload.

PoC by Snyk

const mergeFn = require('lodash').defaultsDeep;
const payload = '{"constructor": {"prototype": {"a0": true}}}'

function check() {
    mergeFn({}, JSON.parse(payload));
    if (({})[`a0`] === true) {
        console.log(`Vulnerable to Prototype Pollution via ${payload}`);
    }
  }

check();

For more information, check out our blog post

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade lodash to version 4.17.12 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.17.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmlbuilder@4.0.0 lodash@3.10.1

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Prototype Pollution via the set and setwith functions due to improper user input sanitization.

PoC

lod = require('lodash')
lod.set({}, "__proto__[test2]", "456")
console.log(Object.prototype)

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade lodash to version 4.17.17 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.11.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmlbuilder@4.0.0 lodash@3.10.1

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Prototype Pollution. The functions merge, mergeWith, and defaultsDeep could be tricked into adding or modifying properties of Object.prototype. This is due to an incomplete fix to CVE-2018-3721.

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade lodash to version 4.17.11 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: merge
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 exec-sh@0.2.2 merge@1.2.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 watch@0.18.0 exec-sh@0.2.2 merge@1.2.1

Overview

merge is a library that allows you to merge multiple objects into one, optionally creating a new cloned object. Similar to the jQuery.extend but more flexible. Works in Node.js and the browser.

Affected versions of this package are vulnerable to Prototype Pollution via _recursiveMerge .

PoC:

const merge = require('merge');

const payload2 = JSON.parse('{"x": {"__proto__":{"polluted":"yes"}}}');

let obj1 = {x: {y:1}};

console.log("Before : " + obj1.polluted);
merge.recursive(obj1, payload2);
console.log("After : " + obj1.polluted);
console.log("After : " + {}.polluted);

Output:

Before : undefined
After : yes
After : yes

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade merge to version 2.1.1 or higher.

References

high severity

Code Injection

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.21.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmlbuilder@4.0.0 lodash@3.10.1

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Code Injection via template.

PoC

var _ = require('lodash');

_.template('', { variable: '){console.log(process.env)}; with(obj' })()

Remediation

Upgrade lodash to version 4.17.21 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: plist
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0
    Remediation: Upgrade to react-native@0.56.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 xcode@0.9.3 simple-plist@0.2.1 plist@2.0.1
    Remediation: Upgrade to react-native@0.59.0.

Overview

plist is a Mac OS X Plist parser/builder for Node.js and browsers

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) attacks due to bundling a vulnerable version of the XMLBuilder package. This can cause an impact of about 10 seconds matching time for data 60 characters long.

Disclosure Timeline

  • Feb 5th, 2018 - Initial Disclosure to package owner
  • Feb 6th, 2018 - Initial Response from package owner
  • Mar 18th, 2018 - Fix issued
  • Apr 15th, 2018 - Vulnerability published

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade plist to version 3.0.1 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: plist
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0
    Remediation: Upgrade to react-native@0.56.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 xcode@0.9.3 simple-plist@0.2.1 plist@2.0.1
    Remediation: Upgrade to react-native@0.59.0.

Overview

plist is a Mac OS X Plist parser/builder for Node.js and browsers.

Affected versions of this package are vulnerable to Prototype Pollution via the .parse(), exploiting this vulnerability may lead to Denial of Service (DoS) and Remote Code Execution.

PoC:

var plist = require('plist');
var xmlPollution = `
<plist version="1.0">
  <dict>
    <key>__proto__</key>
    <dict>
      <key>length</key>
      <string>polluted</string>
    </dict>
  </dict>
</plist>`;
console.log(plist.parse(xmlPollution).length); // polluted

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade plist to version 3.0.4 or higher.

References

medium severity

Observable Timing Discrepancy

  • Vulnerable module: basic-auth-connect
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 basic-auth-connect@1.0.0
    Remediation: Upgrade to react-native@0.63.0.

Overview

basic-auth-connect is a Basic auth middleware for node and connect

Affected versions of this package are vulnerable to Observable Timing Discrepancy due to the use of a timing-unsafe equality comparison. An attacker can infer sensitive data.

Remediation

Upgrade basic-auth-connect to version 1.1.0 or higher.

References

medium severity

Arbitrary Code Injection

  • Vulnerable module: morgan
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 morgan@1.6.1
    Remediation: Upgrade to react-native@0.63.0.

Overview

morgan is a HTTP request logger middleware for node.js.

Affected versions of this package are vulnerable to Arbitrary Code Injection. An attacker could use the format parameter to inject arbitrary commands.

Remediation

Upgrade morgan to version 1.9.1 or higher.

References

medium severity

Symlink Attack

  • Vulnerable module: tmp
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 inquirer@3.3.0 external-editor@2.2.0 tmp@0.0.33

Overview

Affected versions of this package are vulnerable to Symlink Attack via the dir parameter. An attacker can cause files or directories to be written to arbitrary locations by supplying a crafted symbolic link that resolves outside the intended temporary directory.

PoC

const tmp = require('tmp');

const tmpobj = tmp.fileSync({ 'dir': 'evil-dir'});
console.log('File: ', tmpobj.name);

try {
    tmp.fileSync({ 'dir': 'mydir1'});
} catch (err) {
    console.log('test 1:', err.message)
}

try {
    tmp.fileSync({ 'dir': '/foo'});
} catch (err) {
    console.log('test 2:', err.message)
}

try {
    const fs = require('node:fs');
    const resolved = fs.realpathSync('/tmp/evil-dir');
    tmp.fileSync({ 'dir': resolved});
} catch (err) {
    console.log('test 3:', err.message)
}

Remediation

Upgrade tmp to version 0.2.4 or higher.

References

medium severity

Information Exposure

  • Vulnerable module: node-fetch
  • Introduced through: react-native@0.49.3, realm@1.13.0 and others

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 node-fetch@1.7.3
    Remediation: Upgrade to react-native@0.57.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-fetch@1.7.3
    Remediation: Upgrade to realm@10.1.1.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 isomorphic-fetch@2.2.1 node-fetch@1.7.3
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb prop-types@15.6.0 fbjs@0.8.18 isomorphic-fetch@2.2.1 node-fetch@1.7.3
    Remediation: Upgrade to prop-types@15.6.2.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react@16.0.0-beta.5 fbjs@0.8.18 isomorphic-fetch@2.2.1 node-fetch@1.7.3
    Remediation: Upgrade to react@16.5.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs@0.8.14 isomorphic-fetch@2.2.1 node-fetch@1.7.3
    Remediation: Upgrade to react-native@0.64.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 fbjs@0.8.14 isomorphic-fetch@2.2.1 node-fetch@1.7.3

Overview

node-fetch is a light-weight module that brings window.fetch to node.js

Affected versions of this package are vulnerable to Information Exposure when fetching a remote url with Cookie, if it get a Location response header, it will follow that url and try to fetch that url with provided cookie. This can lead to forwarding secure headers to 3th party.

Remediation

Upgrade node-fetch to version 2.6.7, 3.1.1 or higher.

References

medium severity

Improper Authorization

  • Vulnerable module: react-devtools-core
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 react-devtools-core@2.5.2
    Remediation: Upgrade to react-native@0.62.0.

Overview

react-devtools-core is an Use react-devtools outside of the browser

Affected versions of this package are vulnerable to Improper Authorization through the window.addEventListener('message', <listener>) function. By exploiting this vulnerability, an attacker can generate clicks and revenue or initiate a Distributed Denial of Service (DDoS) attack without the victims’ knowledge or consent by sending a message that triggers a fetch request to an arbitrary

PoC


<!DOCTYPE html>
<html>
<head>
  <script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script>
  <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
</head>
<body>

<div id="mydiv"></div>

<script type="text/babel">
  function Hello() {
    return <h1>Hello World!</h1>;
  }

  const container = document.getElementById('mydiv');
  const root = ReactDOM.createRoot(container);
  root.render(<Hello />)
</script>

<script>
  function sendBrowserMsg() {
    let msg = {
      source: 'react-devtools-extension',
      payload: {
        type: 'fetch-file-with-cache',
        url: 'https://www.google.com'
      }
    }
    console.log(`Sending msg from browser: ${JSON.stringify(msg)}`);
    postMessage(msg, "*");
  }
</script>

<form>
  <button type="button" id="submit" onClick="sendBrowserMsg()">Go!</button>
</form>

</body>
</html>

Remediation

Upgrade react-devtools-core to version 4.28.4 or higher.

References

medium severity

Server-side Request Forgery (SSRF)

  • Vulnerable module: request
  • Introduced through: realm@1.13.0 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 request@2.88.2
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 request@2.88.2
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0

Overview

request is a simplified http request client.

Affected versions of this package are vulnerable to Server-side Request Forgery (SSRF) due to insufficient checks in the lib/redirect.js file by allowing insecure redirects in the default configuration, via an attacker-controller server that does a cross-protocol redirect (HTTP to HTTPS, or HTTPS to HTTP).

NOTE: request package has been deprecated, so a fix is not expected. See https://github.com/request/request/issues/3142.

Remediation

A fix was pushed into the master branch but not yet published.

References

medium severity

Uncontrolled Resource Consumption ('Resource Exhaustion')

  • Vulnerable module: tar
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar@2.2.2
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 tar@2.2.2

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Uncontrolled Resource Consumption ('Resource Exhaustion') due to the lack of folders count validation during the folder creation process. An attacker who generates a large number of sub-folders can consume memory on the system running the software and even crash the client within few seconds of running it using a path with too many sub-folders inside.

Remediation

Upgrade tar to version 6.2.1 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: tough-cookie
  • Introduced through: realm@1.13.0 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 request@2.88.2 tough-cookie@2.5.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 request@2.88.2 tough-cookie@2.5.0
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 tough-cookie@2.3.4

Overview

tough-cookie is a RFC6265 Cookies and CookieJar module for Node.js.

Affected versions of this package are vulnerable to Prototype Pollution due to improper handling of Cookies when using CookieJar in rejectPublicSuffixes=false mode. Due to an issue with the manner in which the objects are initialized, an attacker can expose or modify a limited amount of property information on those objects. There is no impact to availability.

PoC

// PoC.js
async function main(){
var tough = require("tough-cookie");
var cookiejar = new tough.CookieJar(undefined,{rejectPublicSuffixes:false});
// Exploit cookie
await cookiejar.setCookie(
  "Slonser=polluted; Domain=__proto__; Path=/notauth",
  "https://__proto__/admin"
);
// normal cookie
var cookie = await cookiejar.setCookie(
  "Auth=Lol; Domain=google.com; Path=/notauth",
  "https://google.com/"
);

//Exploit cookie
var a = {};
console.log(a["/notauth"]["Slonser"])
}
main();

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade tough-cookie to version 4.1.3 or higher.

References

medium severity

Improper Input Validation

  • Vulnerable module: xmldom
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmldom@0.1.31
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 xcode@0.9.3 simple-plist@0.2.1 plist@2.0.1 xmldom@0.1.31

Overview

xmldom is an A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.

Affected versions of this package are vulnerable to Improper Input Validation. It does not correctly escape special characters when serializing elements are removed from their ancestor. This may lead to unexpected syntactic changes during XML processing in some downstream applications.

Note: Customers who use "xmldom" package, should use "@xmldom/xmldom" instead, as "xmldom" is no longer maintained.

Remediation

There is no fixed version for xmldom.

References

medium severity

Prototype Pollution

  • Vulnerable module: json5
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-core@6.26.3 json5@0.5.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-core@6.26.3 json5@0.5.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-core@6.26.3 json5@0.5.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-register@6.26.0 babel-core@6.26.3 json5@0.5.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 json5@0.5.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-register@6.26.0 babel-core@6.26.3 json5@0.5.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs-scripts@0.8.3 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 json5@0.5.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 babel-core@6.26.3 babel-register@6.26.0 babel-core@6.26.3 json5@0.5.1
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 json5@0.4.0

Overview

Affected versions of this package are vulnerable to Prototype Pollution via the parse method , which does not restrict parsing of keys named __proto__, allowing specially crafted strings to pollute the prototype of the resulting object. This pollutes the prototype of the object returned by JSON5.parse and not the global Object prototype (which is the commonly understood definition of Prototype Pollution). Therefore, the actual impact will depend on how applications utilize the returned object and how they filter unwanted keys.

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade json5 to version 1.0.2, 2.2.2 or higher.

References

medium severity

  • Vulnerable module: cookie
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 cookie@0.1.3
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 cookie-parser@1.3.5 cookie@0.1.3
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 csurf@1.8.3 cookie@0.1.3
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 express-session@1.11.3 cookie@0.1.3
    Remediation: Upgrade to react-native@0.63.0.

Overview

Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via the cookie name, path, or domain, which can be used to set unexpected values to other cookie fields.

Workaround

Users who are not able to upgrade to the fixed version should avoid passing untrusted or arbitrary values for the cookie fields and ensure they are set by the application instead of user input.

Details

Cross-site scripting (or XSS) is a code vulnerability that occurs when an attacker “injects” a malicious script into an otherwise trusted website. The injected script gets downloaded and executed by the end user’s browser when the user interacts with the compromised website.

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

Types of attacks

There are a few methods by which XSS can be manipulated:

Type Origin Description
Stored Server The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
Reflected Server The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-based Client The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
Mutated The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.

Affected environments

The following environments are susceptible to an XSS attack:

  • Web servers
  • Application servers
  • Web application environments

How to prevent

This section describes the top best practices designed to specifically protect your code:

  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • Give users the option to disable client-side scripts.
  • Redirect invalid requests.
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.

Remediation

Upgrade cookie to version 0.7.0 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: hoek
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 hawk@3.1.3 hoek@2.16.3
    Remediation: Upgrade to realm@10.3.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 hawk@3.1.3 boom@2.10.1 hoek@2.16.3
    Remediation: Upgrade to realm@10.3.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 hawk@3.1.3 sntp@1.0.9 hoek@2.16.3
    Remediation: Upgrade to realm@10.3.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 hawk@3.1.3 hoek@2.16.3
    Remediation: Upgrade to realm@10.3.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 hawk@3.1.3 cryptiles@2.0.5 boom@2.10.1 hoek@2.16.3
    Remediation: Upgrade to realm@10.3.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 hawk@3.1.3 boom@2.10.1 hoek@2.16.3
    Remediation: Upgrade to realm@10.3.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 hawk@3.1.3 sntp@1.0.9 hoek@2.16.3
    Remediation: Upgrade to realm@10.3.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 request@2.81.0 hawk@3.1.3 cryptiles@2.0.5 boom@2.10.1 hoek@2.16.3
    Remediation: Upgrade to realm@10.3.0.

Overview

hoek is an Utility methods for the hapi ecosystem.

Affected versions of this package are vulnerable to Prototype Pollution. The utilities function allow modification of the Object prototype. If an attacker can control part of the structure passed to this function, they could add or modify an existing property.

PoC by Olivier Arteau (HoLyVieR)

var Hoek = require('hoek');
var malicious_payload = '{"__proto__":{"oops":"It works !"}}';

var a = {};
console.log("Before : " + a.oops);
Hoek.merge({}, JSON.parse(malicious_payload));
console.log("After : " + a.oops);

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade hoek to version 4.2.1, 5.0.3 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.5.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmlbuilder@4.0.0 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Prototype Pollution. The utilities function allow modification of the Object prototype. If an attacker can control part of the structure passed to this function, they could add or modify an existing property.

PoC by Olivier Arteau (HoLyVieR)

var _= require('lodash');
var malicious_payload = '{"__proto__":{"oops":"It works !"}}';

var a = {};
console.log("Before : " + a.oops);
_.merge({}, JSON.parse(malicious_payload));
console.log("After : " + a.oops);

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade lodash to version 4.17.5 or higher.

References

medium severity

Missing Release of Resource after Effective Lifetime

  • Vulnerable module: inflight
  • Introduced through: react-native@0.49.3 and realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 envinfo@3.11.1 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 rimraf@2.7.1 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 rimraf@2.7.1 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 rimraf@2.7.1 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 rimraf@2.7.1 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar@2.2.2 fstream@1.0.12 rimraf@2.7.1 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 fstream@1.0.12 rimraf@2.7.1 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 tar@2.2.2 fstream@1.0.12 rimraf@2.7.1 glob@7.2.3 inflight@1.0.6
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 fstream-ignore@1.0.5 fstream@1.0.12 rimraf@2.7.1 glob@7.2.3 inflight@1.0.6

Overview

Affected versions of this package are vulnerable to Missing Release of Resource after Effective Lifetime via the makeres function due to improperly deleting keys from the reqs object after execution of callbacks. This behavior causes the keys to remain in the reqs object, which leads to resource exhaustion.

Exploiting this vulnerability results in crashing the node process or in the application crash.

Note: This library is not maintained, and currently, there is no fix for this issue. To overcome this vulnerability, several dependent packages have eliminated the use of this library.

To trigger the memory leak, an attacker would need to have the ability to execute or influence the asynchronous operations that use the inflight module within the application. This typically requires access to the internal workings of the server or application, which is not commonly exposed to remote users. Therefore, “Attack vector” is marked as “Local”.

PoC

const inflight = require('inflight');

function testInflight() {
  let i = 0;
  function scheduleNext() {
    let key = `key-${i++}`;
    const callback = () => {
    };
    for (let j = 0; j < 1000000; j++) {
      inflight(key, callback);
    }

    setImmediate(scheduleNext);
  }


  if (i % 100 === 0) {
    console.log(process.memoryUsage());
  }

  scheduleNext();
}

testInflight();

Remediation

There is no fixed version for inflight.

References

medium severity

Cryptographic Weakness

  • Vulnerable module: jsrsasign
  • Introduced through: oidc-client-fetch@1.2.2-fetch1

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 jsrsasign@5.1.0

Overview

jsrsasign is a free pure JavaScript cryptographic library.

Affected versions of this package are vulnerable to Cryptographic Weakness. Invalid RSA PKCS#1 v1.5 signatures are mistakenly recognized to be valid.

Remediation

Upgrade jsrsasign to version 10.1.13 or higher.

References

medium severity

Timing Attack

  • Vulnerable module: jsrsasign
  • Introduced through: oidc-client-fetch@1.2.2-fetch1

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 jsrsasign@5.1.0

Overview

jsrsasign is a free pure JavaScript cryptographic library.

Affected versions of this package are vulnerable to Timing Attack. Practical recovery of the long-term private key generated by the library is possible under certain conditions. Leakage of a bit-length of the scalar during scalar multiplication is possible on an elliptic curve which might allow practical recovery of the long-term private key.

Remediation

Upgrade jsrsasign to version 8.0.13 or higher.

References

medium severity

Denial of Service (DoS)

  • Vulnerable module: node-fetch
  • Introduced through: react-native@0.49.3, realm@1.13.0 and others

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 node-fetch@1.7.3
    Remediation: Upgrade to react-native@0.57.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-fetch@1.7.3
    Remediation: Upgrade to realm@10.1.1.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 isomorphic-fetch@2.2.1 node-fetch@1.7.3
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb prop-types@15.6.0 fbjs@0.8.18 isomorphic-fetch@2.2.1 node-fetch@1.7.3
    Remediation: Upgrade to prop-types@15.6.2.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react@16.0.0-beta.5 fbjs@0.8.18 isomorphic-fetch@2.2.1 node-fetch@1.7.3
    Remediation: Upgrade to react@16.5.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 fbjs@0.8.14 isomorphic-fetch@2.2.1 node-fetch@1.7.3
    Remediation: Upgrade to react-native@0.64.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 fbjs@0.8.14 isomorphic-fetch@2.2.1 node-fetch@1.7.3

Overview

node-fetch is a light-weight module that brings window.fetch to node.js

Affected versions of this package are vulnerable to Denial of Service (DoS). Node Fetch did not honor the size option after following a redirect, which means that when a content size was over the limit, a FetchError would never get thrown and the process would end without failure.

Remediation

Upgrade node-fetch to version 2.6.1, 3.0.0-beta.9 or higher.

References

medium severity

Memory Corruption

  • Vulnerable module: jsrsasign
  • Introduced through: oidc-client-fetch@1.2.2-fetch1

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 jsrsasign@5.1.0

Overview

jsrsasign is a free pure JavaScript cryptographic library.

Affected versions of this package are vulnerable to Memory Corruption. Its RSA PKCS1 v1.5 decryption implementation does not detect ciphertext modification by prepending '\0' bytes to ciphertexts (it decrypts modified ciphertexts without error). An attacker might prepend these bytes with the goal of triggering memory corruption issues.

Remediation

Upgrade jsrsasign to version 8.0.18 or higher.

References

medium severity

Remote Code Execution (RCE)

  • Vulnerable module: jsrsasign
  • Introduced through: oidc-client-fetch@1.2.2-fetch1

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 jsrsasign@5.1.0

Overview

jsrsasign is a free pure JavaScript cryptographic library.

Affected versions of this package are vulnerable to Remote Code Execution (RCE). Its RSASSA-PSS (RSA-PSS) implementation does not detect signature manipulation/modification by prepending '\0' bytes to a signature (it accepts these modified signatures as valid). An attacker can abuse this behavior in an application by creating multiple valid signatures where only one signature should exist. Also, an attacker might prepend these bytes with the goal of triggering memory corruption issues.

Remediation

Upgrade jsrsasign to version 8.0.18 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: minimist
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 optimist@0.6.1 minimist@0.0.10

Overview

minimist is a parse argument options module.

Affected versions of this package are vulnerable to Prototype Pollution. The library could be tricked into adding or modifying properties of Object.prototype using a constructor or __proto__ payload.

PoC by Snyk

require('minimist')('--__proto__.injected0 value0'.split(' '));
console.log(({}).injected0 === 'value0'); // true

require('minimist')('--constructor.prototype.injected1 value1'.split(' '));
console.log(({}).injected1 === 'value1'); // true

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade minimist to version 0.2.1, 1.2.3 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: yargs-parser
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 yargs@6.6.0 yargs-parser@4.2.1
    Remediation: Upgrade to react-native@0.60.0.

Overview

yargs-parser is a mighty option parser used by yargs.

Affected versions of this package are vulnerable to Prototype Pollution. The library could be tricked into adding or modifying properties of Object.prototype using a __proto__ payload.

Our research team checked several attack vectors to verify this vulnerability:

  1. It could be used for privilege escalation.
  2. The library could be used to parse user input received from different sources:
    • terminal emulators
    • system calls from other code bases
    • CLI RPC servers

PoC by Snyk

const parser = require("yargs-parser");
console.log(parser('--foo.__proto__.bar baz'));
console.log(({}).bar);

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade yargs-parser to version 5.0.1, 13.1.2, 15.0.1, 18.1.1 or higher.

References

medium severity

XML External Entity (XXE) Injection

  • Vulnerable module: xmldom
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmldom@0.1.31
    Remediation: Upgrade to react-native@0.56.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 xcode@0.9.3 simple-plist@0.2.1 plist@2.0.1 xmldom@0.1.31
    Remediation: Upgrade to react-native@0.59.0.

Overview

xmldom is an A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.

Affected versions of this package are vulnerable to XML External Entity (XXE) Injection. Does not correctly preserve system identifiers, FPIs or namespaces when repeatedly parsing and serializing maliciously crafted documents.

Details

XXE Injection is a type of attack against an application that parses XML input. XML is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. By default, many XML processors allow specification of an external entity, a URI that is dereferenced and evaluated during XML processing. When an XML document is being parsed, the parser can make a request and include the content at the specified URI inside of the XML document.

Attacks can include disclosing local files, which may contain sensitive data such as passwords or private user data, using file: schemes or relative paths in the system identifier.

For example, below is a sample XML document, containing an XML element- username.

<xml>
<?xml version="1.0" encoding="ISO-8859-1"?>
   <username>John</username>
</xml>

An external XML entity - xxe, is defined using a system identifier and present within a DOCTYPE header. These entities can access local or remote content. For example the below code contains an external XML entity that would fetch the content of /etc/passwd and display it to the user rendered by username.

<xml>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
   <!ENTITY xxe SYSTEM "file:///etc/passwd" >]>
   <username>&xxe;</username>
</xml>

Other XXE Injection attacks can access local resources that may not stop returning data, possibly impacting application availability and leading to Denial of Service.

Remediation

Upgrade xmldom to version 0.5.0 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.21.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmlbuilder@4.0.0 lodash@3.10.1

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the toNumber, trim and trimEnd functions.

POC

var lo = require('lodash');

function build_blank (n) {
var ret = "1"
for (var i = 0; i < n; i++) {
ret += " "
}

return ret + "1";
}

var s = build_blank(50000)
var time0 = Date.now();
lo.trim(s)
var time_cost0 = Date.now() - time0;
console.log("time_cost0: " + time_cost0)

var time1 = Date.now();
lo.toNumber(s)
var time_cost1 = Date.now() - time1;
console.log("time_cost1: " + time_cost1)

var time2 = Date.now();
lo.trimEnd(s)
var time_cost2 = Date.now() - time2;
console.log("time_cost2: " + time_cost2)

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade lodash to version 4.17.21 or higher.

References

medium severity

Inefficient Regular Expression Complexity

  • Vulnerable module: micromatch
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 micromatch@2.3.11
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 micromatch@3.1.10
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 sane@2.5.2 anymatch@2.0.0 micromatch@3.1.10

Overview

Affected versions of this package are vulnerable to Inefficient Regular Expression Complexity due to the use of unsafe pattern configurations that allow greedy matching through the micromatch.braces() function. An attacker can cause the application to hang or slow down by passing a malicious payload that triggers extensive backtracking in regular expression processing.

Remediation

Upgrade micromatch to version 4.0.8 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: ramda
  • Introduced through: reduxsauce@0.7.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb reduxsauce@0.7.0 ramda@0.24.1
    Remediation: Upgrade to reduxsauce@1.2.1.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb reduxsauce@0.7.0 ramdasauce@2.1.3 ramda@0.24.1

Overview

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in source/trim.js within variable ws.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade ramda to version 0.27.2 or higher.

References

medium severity

Information Exposure

  • Vulnerable module: react-native-fast-image
  • Introduced through: react-native-fast-image@2.2.6

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native-fast-image@2.2.6
    Remediation: Upgrade to react-native-fast-image@8.3.0.

Overview

react-native-fast-image is a FastImage, performant React Native image component.

Affected versions of this package are vulnerable to Information Exposure. When an image with source={{uri: "...", headers: { host: "somehost.com", authorization: "..." }} is loaded, all other subsequent images will use the same headers, this can lead to signing credentials or other session tokens being leaked to other servers.

Remediation

Upgrade react-native-fast-image to version 8.3.0 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: uglify-js
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 uglify-js@2.7.5
    Remediation: Upgrade to react-native@0.52.0.

Overview

uglify-js is a JavaScript parser, minifier, compressor and beautifier toolkit.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the string_template and the decode_template functions.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade uglify-js to version 3.14.3 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: ws
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 react-devtools-core@2.5.2 ws@2.3.1
    Remediation: Upgrade to react-native@0.62.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 ws@1.1.5
    Remediation: Upgrade to react-native@0.60.0.

Overview

ws is a simple to use websocket client, server and console for node.js.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server.

##PoC

for (const length of [1000, 2000, 4000, 8000, 16000, 32000]) {
  const value = 'b' + ' '.repeat(length) + 'x';
  const start = process.hrtime.bigint();

  value.trim().split(/ *, */);

  const end = process.hrtime.bigint();

  console.log('length = %d, time = %f ns', length, end - start);
}

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade ws to version 7.4.6, 6.2.2, 5.2.3 or higher.

References

medium severity

Improper Handling of Unexpected Data Type

  • Vulnerable module: on-headers
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 on-headers@1.0.2
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 compression@1.5.2 on-headers@1.0.2
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 connect-timeout@1.6.2 on-headers@1.0.2
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 express-session@1.11.3 on-headers@1.0.2
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 morgan@1.6.1 on-headers@1.0.2
    Remediation: Upgrade to react-native@0.63.0.

Overview

Affected versions of this package are vulnerable to Improper Handling of Unexpected Data Type via the response.writeHead function. An attacker can manipulate HTTP response headers by passing an array to this function, potentially leading to unintended disclosure or modification of header information.

Workaround

This vulnerability can be mitigated by passing an object to response.writeHead() instead of an array.

Remediation

Upgrade on-headers to version 1.1.0 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: lodash
  • Introduced through: lodash@4.17.4 and react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb lodash@4.17.4
    Remediation: Upgrade to lodash@4.17.11.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 plist@1.2.0 xmlbuilder@4.0.0 lodash@3.10.1

Overview

lodash is a modern JavaScript utility library delivering modularity, performance, & extras.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It parses dates using regex strings, which may cause a slowdown of 2 seconds per 50k characters.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade lodash to version 4.17.11 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: braces
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 metro-bundler@0.13.0 jest-haste-map@20.1.0-echo.1 micromatch@2.3.11 braces@1.8.5

Overview

braces is a Bash-like brace expansion, implemented in JavaScript.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It used a regular expression (^\{(,+(?:(\{,+\})*),*|,*(?:(\{,+\})*),+)\}) in order to detects empty braces. This can cause an impact of about 10 seconds matching time for data 50K characters long.

Disclosure Timeline

  • Feb 15th, 2018 - Initial Disclosure to package owner
  • Feb 16th, 2018 - Initial Response from package owner
  • Feb 18th, 2018 - Fix issued
  • Feb 19th, 2018 - Vulnerability published

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade braces to version 2.3.1 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: debug
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 debug@2.2.0
    Remediation: Upgrade to react-native@0.54.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 body-parser@1.13.3 debug@2.2.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 compression@1.5.2 debug@2.2.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 connect-timeout@1.6.2 debug@2.2.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 express-session@1.11.3 debug@2.2.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 finalhandler@0.4.0 debug@2.2.0
    Remediation: Upgrade to react-native@0.54.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 morgan@1.6.1 debug@2.2.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-index@1.7.3 debug@2.2.0
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-static@1.10.3 send@0.13.2 debug@2.2.0
    Remediation: Upgrade to react-native@0.63.0.

Overview

debug is a small debugging utility.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in the function useColors via manipulation of the str argument. The vulnerability can cause a very low impact of about 2 seconds of matching time for data 50k characters long.

Note: CVE-2017-20165 is a duplicate of this vulnerability.

PoC

Use the following regex in the %o formatter.

/\s*\n\s*/

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade debug to version 2.6.9, 3.1.0, 3.2.7, 4.3.1 or higher.

References

low severity

Signature Bypass

  • Vulnerable module: jsrsasign
  • Introduced through: oidc-client-fetch@1.2.2-fetch1

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb oidc-client-fetch@1.2.2-fetch1 jsrsasign@5.1.0

Overview

jsrsasign is a free pure JavaScript cryptographic library.

Affected versions of this package are vulnerable to Signature Bypass. It allows a malleability in ECDSA signatures by not checking overflows in the length of a sequence and '0' characters appended or prepended to an integer. The modified signatures are verified as valid. This could have a security-relevant impact if an application relied on a single canonical signature.

Remediation

Upgrade jsrsasign to version 8.0.18 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: mime
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-static@1.10.3 send@0.13.2 mime@1.3.4
    Remediation: Upgrade to react-native@0.63.0.

Overview

mime is a comprehensive, compact MIME type module.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It uses regex the following regex /.*[\.\/\\]/ in its lookup, which can cause a slowdown of 2 seconds for 50k characters.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade mime to version 1.4.1, 2.0.3 or higher.

References

low severity

Prototype Pollution

  • Vulnerable module: minimist
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 optimist@0.6.1 minimist@0.0.10

Overview

minimist is a parse argument options module.

Affected versions of this package are vulnerable to Prototype Pollution due to a missing handler to Function.prototype.

Notes:

  • This vulnerability is a bypass to CVE-2020-7598

  • The reason for the different CVSS between CVE-2021-44906 to CVE-2020-7598, is that CVE-2020-7598 can pollute objects, while CVE-2021-44906 can pollute only function.

PoC by Snyk

require('minimist')('--_.constructor.constructor.prototype.foo bar'.split(' '));
console.log((function(){}).foo); // bar

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • Property definition by path

Unsafe Object recursive merge

The logic of a vulnerable recursive merge function follows the following high-level model:

merge (target, source)

  foreach property of source

    if property exists and is an object on both the target and the source

      merge(target[property], source[property])

    else

      target[property] = source[property]

When the source object contains a property named __proto__ defined with Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object and the source of Object as defined by the attacker. Properties are then copied on the Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. myValue is then assigned to the prototype of the class of the object.

Types of attacks

There are a few methods by which Prototype Pollution can be manipulated:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
Remote Code Execution Client Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
Property Injection Client The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade minimist to version 0.2.4, 1.2.6 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: ms
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.54.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 connect-timeout@1.6.2 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 body-parser@1.13.3 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 compression@1.5.2 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 connect-timeout@1.6.2 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 express-session@1.11.3 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 finalhandler@0.4.0 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.54.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 morgan@1.6.1 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-index@1.7.3 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-static@1.10.3 send@0.13.2 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-static@1.10.3 send@0.13.2 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to react-native@0.63.0.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-favicon@2.3.2 ms@0.7.2
    Remediation: Upgrade to react-native@0.63.0.

Overview

ms is a tiny millisecond conversion utility.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to an incomplete fix for previously reported vulnerability npm:ms:20151024. The fix limited the length of accepted input string to 10,000 characters, and turned to be insufficient making it possible to block the event loop for 0.3 seconds (on a typical laptop) with a specially crafted string passed to ms() function.

Proof of concept

ms = require('ms');
ms('1'.repeat(9998) + 'Q') // Takes about ~0.3s

Note: Snyk's patch for this vulnerability limits input length to 100 characters. This new limit was deemed to be a breaking change by the author. Based on user feedback, we believe the risk of breakage is very low, while the value to your security is much greater, and therefore opted to still capture this change in a patch for earlier versions as well. Whenever patching security issues, we always suggest to run tests on your code to validate that nothing has been broken.

For more information on Regular Expression Denial of Service (ReDoS) attacks, go to our blog.

Disclosure Timeline

  • Feb 9th, 2017 - Reported the issue to package owner.
  • Feb 11th, 2017 - Issue acknowledged by package owner.
  • April 12th, 2017 - Fix PR opened by Snyk Security Team.
  • May 15th, 2017 - Vulnerability published.
  • May 16th, 2017 - Issue fixed and version 2.0.0 released.
  • May 21th, 2017 - Patches released for versions >=0.7.1, <=1.0.0.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade ms to version 2.0.0 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: tar
  • Introduced through: realm@1.13.0

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to realm@2.15.2.
  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb realm@1.13.0 node-pre-gyp@0.6.39 tar-pack@3.4.1 tar@2.2.2

Overview

tar is a full-featured Tar for Node.js.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). When stripping the trailing slash from files arguments, the f.replace(/\/+$/, '') performance of this function can exponentially degrade when f contains many / characters resulting in ReDoS.

This vulnerability is not likely to be exploitable as it requires that the untrusted input is being passed into the tar.extract() or tar.list() array of entries to parse/extract, which would be unusual.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade tar to version 6.1.4, 5.0.8, 4.4.16 or higher.

References

low severity

Cross-site Scripting

  • Vulnerable module: send
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-static@1.10.3 send@0.13.2
    Remediation: Upgrade to react-native@0.63.0.

Overview

send is a Better streaming static file server with Range and conditional-GET support

Affected versions of this package are vulnerable to Cross-site Scripting due to improper user input sanitization passed to the SendStream.redirect() function, which executes untrusted code. An attacker can execute arbitrary code by manipulating the input parameters to this method.

Note:

Exploiting this vulnerability requires the following:

  1. The attacker needs to control the input to response.redirect()

  2. Express MUST NOT redirect before the template appears

  3. The browser MUST NOT complete redirection before

  4. The user MUST click on the link in the template

Details

Cross-site scripting (or XSS) is a code vulnerability that occurs when an attacker “injects” a malicious script into an otherwise trusted website. The injected script gets downloaded and executed by the end user’s browser when the user interacts with the compromised website.

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

Types of attacks

There are a few methods by which XSS can be manipulated:

Type Origin Description
Stored Server The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
Reflected Server The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-based Client The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
Mutated The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.

Affected environments

The following environments are susceptible to an XSS attack:

  • Web servers
  • Application servers
  • Web application environments

How to prevent

This section describes the top best practices designed to specifically protect your code:

  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • Give users the option to disable client-side scripts.
  • Redirect invalid requests.
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.

Remediation

Upgrade send to version 0.19.0, 1.1.0 or higher.

References

low severity

Cross-site Scripting

  • Vulnerable module: serve-static
  • Introduced through: react-native@0.49.3

Detailed paths

  • Introduced through: OpenCity@city-of-helsinki/open-city-app#5daab250aff340e1af80efde17134ca0ce5bc1bb react-native@0.49.3 connect@2.30.2 serve-static@1.10.3
    Remediation: Upgrade to react-native@0.63.0.

Overview

serve-static is a server.

Affected versions of this package are vulnerable to Cross-site Scripting due to improper sanitization of user input in the redirect function. An attacker can manipulate the redirection process by injecting malicious code into the input.

Note

To exploit this vulnerability, the following conditions are required:

  1. The attacker should be able to control the input to response.redirect()

  2. express must not redirect before the template appears

  3. the browser must not complete redirection before:

  4. the user must click on the link in the template

Details

Cross-site scripting (or XSS) is a code vulnerability that occurs when an attacker “injects” a malicious script into an otherwise trusted website. The injected script gets downloaded and executed by the end user’s browser when the user interacts with the compromised website.

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

Types of attacks

There are a few methods by which XSS can be manipulated:

Type Origin Description
Stored Server The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
Reflected Server The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-based Client The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
Mutated The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.

Affected environments

The following environments are susceptible to an XSS attack:

  • Web servers
  • Application servers
  • Web application environments

How to prevent

This section describes the top best practices designed to specifically protect your code:

  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • Give users the option to disable client-side scripts.
  • Redirect invalid requests.
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.

Remediation

Upgrade serve-static to version 1.16.0, 2.1.0 or higher.

References