gladys@2.1.9

Vulnerabilities

80 via 1023 paths

Dependencies

713

Source

npm

Find, fix and prevent vulnerabilities in your code.

Severity
  • 1
  • 41
  • 30
  • 8
Status
  • 80
  • 0
  • 0

critical severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

Overview

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

Affected versions of this package are vulnerable to Prototype Pollution in zipObjectDeep due to an incomplete fix for CVE-2020-8203.

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

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

Uninitialized Memory Exposure

  • Vulnerable module: base64-url
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 uid-safe@1.1.0 base64-url@1.2.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 express-session@1.11.3 uid-safe@2.0.0 base64-url@1.2.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 express-session@1.11.3 uid-safe@2.0.0 base64-url@1.2.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 express-session@1.11.3 uid-safe@2.0.0 base64-url@1.2.1
    Remediation: Upgrade to gladys@3.0.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: serialport@2.1.2

Detailed paths

  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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: serialport@2.1.2

Detailed paths

  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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: serialport@2.1.2

Detailed paths

  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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

Broken CORS

  • Vulnerable module: sails
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5
    Remediation: Upgrade to gladys@3.0.0.

Overview

sails is API-driven framework for building realtime apps, using MVC conventions (based on Express and Socket.io).

Sails version 0.12.6 and lower allowed the default CORS settings to be very permissive, letting the attacker to bypass the Same Origin Policy.

Remediation

Upgrade sails to version 0.12.7 or higher.

References

high severity

Arbitrary File Overwrite

  • Vulnerable module: tar
  • Introduced through: serialport@2.1.2

Detailed paths

  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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: serialport@2.1.2

Detailed paths

  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 tar@2.2.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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

SQL Injection

  • Vulnerable module: waterline-sequel
  • Introduced through: sails-mysql@0.10.12

Detailed paths

  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0
    Remediation: Upgrade to gladys@3.0.0.

Overview

'waterline-sequel' is a helper library for generating SQL queries from the Waterline Query Language.

waterline-sequel version 0.5.0 is vulnerable to SQL Injection via like, contains, startsWith or endsWith methods.

Remediation

Upgrade waterline-sequel to version 0.5.1 or greater

References

high severity

Prototype Pollution

  • Vulnerable module: ajv
  • Introduced through: serialport@2.1.2

Detailed paths

  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 request@2.81.0 har-validator@4.2.1 ajv@4.11.8
    Remediation: Upgrade to gladys@3.0.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

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

Arbitrary Code Execution

  • Vulnerable module: ejs
  • Introduced through: ejs@0.8.8 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 ejs@0.8.8
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 ejs@0.8.8
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 ejs-locals@1.0.2 ejs@0.8.8

Overview

ejs is a popular JavaScript templating engine. Affected versions of the package are vulnerable to Remote Code Execution by letting the attacker under certain conditions control the source folder from which the engine renders include files. You can read more about this vulnerability on the Snyk blog.

There's also a Cross-site Scripting & Denial of Service vulnerabilities caused by the same behaviour.

Details

ejs provides a few different options for you to render a template, two being very similar: ejs.render() and ejs.renderFile(). The only difference being that render expects a string to be used for the template and renderFile expects a path to a template file.

Both functions can be invoked in two ways. The first is calling them with template, data, and options:

ejs.render(str, data, options);

ejs.renderFile(filename, data, options, callback)

The second way would be by calling only the template and data, while ejs lets the options be passed as part of the data:

ejs.render(str, dataAndOptions);

ejs.renderFile(filename, dataAndOptions, callback)

If used with a variable list supplied by the user (e.g. by reading it from the URI with qs or equivalent), an attacker can control ejs options. This includes the root option, which allows changing the project root for includes with an absolute path.

ejs.renderFile('my-template', {root:'/bad/root/'}, callback);

By passing along the root directive in the line above, any includes would now be pulled from /bad/root instead of the path intended. This allows the attacker to take control of the root directory for included scripts and divert it to a library under his control, thus leading to remote code execution.

The fix introduced in version 2.5.3 blacklisted root options from options passed via the data object.

Disclosure Timeline

  • November 27th, 2016 - Reported the issue to package owner.
  • November 27th, 2016 - Issue acknowledged by package owner.
  • November 28th, 2016 - Issue fixed and version 2.5.3 released.

Remediation

The vulnerability can be resolved by either using the GitHub integration to generate a pull-request from your dashboard or by running snyk wizard from the command-line interface. Otherwise, Upgrade ejs to version 2.5.3 or higher.

References

high severity

Arbitrary Code Execution

  • Vulnerable module: js-yaml
  • Introduced through: grunt@0.4.5 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 grunt@0.4.5 js-yaml@2.0.5
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 js-yaml@2.0.5
    Remediation: Upgrade to sails@1.0.0.

Overview

js-yaml is a human-friendly data serialization language.

Affected versions of this package are vulnerable to Arbitrary Code Execution. When an object with an executable toString() property used as a map key, it will execute that function. This happens only for load(), which should not be used with untrusted data anyway. safeLoad() is not affected because it can't parse functions.

Remediation

Upgrade js-yaml to version 3.13.1 or higher.

References

high severity

Arbitrary Code Injection

  • Vulnerable module: xmlhttprequest-ssl
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 engine.io-client@1.6.11 xmlhttprequest-ssl@1.5.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 engine.io-client@1.6.11 xmlhttprequest-ssl@1.5.1
    Remediation: Upgrade to sails@1.0.0.

Overview

xmlhttprequest-ssl is a fork of xmlhttprequest.

Affected versions of this package are vulnerable to Arbitrary Code Injection. Provided requests are sent synchronously (async=False on xhr.open), malicious user input flowing into xhr.send could result in arbitrary code being injected and run.

POC

const { XMLHttpRequest } = require("xmlhttprequest")

const xhr = new XMLHttpRequest()
xhr.open("POST", "http://localhost.invalid/", false /* use synchronize request */)
xhr.send("\\');require(\"fs\").writeFileSync(\"/tmp/aaaaa.txt\", \"poc-20210306\");req.end();//")

Remediation

Upgrade xmlhttprequest-ssl to version 1.6.2 or higher.

References

high severity

Remote Memory Exposure

  • Vulnerable module: bl
  • Introduced through: request@2.45.0 and pushbullet@1.4.3

Detailed paths

  • Introduced through: gladys@2.1.9 request@2.45.0 bl@0.9.5
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0 bl@0.9.5

Overview

bl is a library that allows you to collect buffers and access with a standard readable buffer interface.

Affected versions of this package are vulnerable to Remote Memory Exposure. If user input ends up in consume() argument and can become negative, BufferList state can be corrupted, tricking it into exposing uninitialized memory via regular .slice() calls.

PoC by chalker

const { BufferList } = require('bl')
const secret = require('crypto').randomBytes(256)
for (let i = 0; i < 1e6; i++) {
  const clone = Buffer.from(secret)
  const bl = new BufferList()
  bl.append(Buffer.from('a'))
  bl.consume(-1024)
  const buf = bl.slice(1)
  if (buf.indexOf(clone) !== -1) {
    console.error(`Match (at ${i})`, buf)
  }
}

Remediation

Upgrade bl to version 2.2.1, 3.0.1, 4.0.3, 1.2.3 or higher.

References

high severity

Insecure Encryption

  • Vulnerable module: bcrypt
  • Introduced through: bcrypt@0.8.7

Detailed paths

  • Introduced through: gladys@2.1.9 bcrypt@0.8.7
    Remediation: Upgrade to bcrypt@5.0.0.

Overview

bcrypt is an A library to help you hash passwords.

Affected versions of this package are vulnerable to Insecure Encryption. Data is truncated wrong when its length is greater than 255 bytes.

Remediation

Upgrade bcrypt to version 5.0.0 or higher.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: engine.io
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 engine.io@1.6.11

Overview

engine.io is a realtime engine behind Socket.IO. It provides the foundation of a bidirectional connection between client and server

Affected versions of this package are vulnerable to Denial of Service (DoS) via a POST request to the long polling transport.

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 engine.io to version 4.0.0 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: fresh
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 fresh@0.3.0
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 fresh@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 serve-favicon@2.3.2 fresh@0.3.0
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 fresh@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 fresh@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 send@0.13.0 fresh@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 serve-favicon@2.3.2 fresh@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 serve-favicon@2.3.2 fresh@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 serve-static@1.10.3 send@0.13.2 fresh@0.3.0
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 serve-static@1.10.3 send@0.13.2 fresh@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 serve-static@1.10.3 send@0.13.2 fresh@0.3.0
    Remediation: Upgrade to gladys@3.0.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

Prototype Pollution

  • Vulnerable module: getobject
  • Introduced through: grunt@0.4.5 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 grunt@0.4.5 getobject@0.1.0
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 getobject@0.1.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 getobject@0.1.0
    Remediation: Upgrade to sails@1.0.0.

Overview

Affected versions of this package are vulnerable to Prototype Pollution. It allows an attacker to cause a denial of service and may lead to remote code execution.

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

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 getobject to version 1.0.0 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: minimatch
  • Introduced through: sails@0.11.5, grunt@0.4.5 and others

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 glob@3.1.21 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 glob@3.1.21 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 glob@3.1.21 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 glob@3.1.21 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.

Overview

minimatch is a minimal matching utility.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via complicated and illegal regexes.

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 minimatch to version 3.0.2 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: minimatch
  • Introduced through: sails@0.11.5, grunt@0.4.5 and others

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 glob@3.2.11 minimatch@0.3.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 glob@3.1.21 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 glob@3.1.21 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 glob@3.1.21 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 glob@3.1.21 minimatch@0.2.14
    Remediation: Upgrade to gladys@3.0.0.

Overview

minimatch is a minimal matching utility.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS).

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 minimatch to version 3.0.2 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: negotiator
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 compression@1.5.2 accepts@1.2.13 negotiator@0.5.3
    Remediation: Open PR to patch negotiator@0.5.3.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 serve-index@1.7.3 accepts@1.2.13 negotiator@0.5.3
    Remediation: Open PR to patch negotiator@0.5.3.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 compression@1.5.2 accepts@1.2.13 negotiator@0.5.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 compression@1.5.2 accepts@1.2.13 negotiator@0.5.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 serve-index@1.7.3 accepts@1.2.13 negotiator@0.5.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 serve-index@1.7.3 accepts@1.2.13 negotiator@0.5.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 engine.io@1.6.11 accepts@1.1.4 negotiator@0.4.9
    Remediation: Upgrade to gladys@3.0.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

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: parsejson
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 engine.io-client@1.6.11 parsejson@0.0.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 engine.io-client@1.6.11 parsejson@0.0.1

Overview

parsejson is a method that parses a JSON string and returns a JSON object.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) attacks. An attacker may pass a specially crafted JSON data, causing the server to hang.

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

There is no fixed version for parsejson.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: qs
  • Introduced through: grunt-contrib-watch@0.5.3 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 tiny-lr@0.0.4 qs@0.5.6
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 tiny-lr-fork@0.0.5 qs@0.5.6
    Remediation: Open PR to patch qs@0.5.6.

Overview

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

Affected versions of this package are vulnerable to Denial of Service (DoS). During parsing, the qs module may create a sparse area (an array where no elements are filled), and grow that array to the necessary size based on the indices used on it. An attacker can specify a high index value in a query string, thus making the server allocate a respectively big array. Truly large values can cause the server to run out of memory and cause it to crash - thus enabling a Denial-of-Service attack.

Remediation

Upgrade qs to version 1.0.0 or higher.

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

References

high severity

Prototype Override Protection Bypass

  • Vulnerable module: qs
  • Introduced through: googleapis@1.0.19, grunt-contrib-less@0.11.1 and others

Detailed paths

  • Introduced through: gladys@2.1.9 googleapis@1.0.19 request@2.40.0 qs@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 qs@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 qs@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 tiny-lr@0.0.4 qs@0.5.6
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 tiny-lr-fork@0.0.5 qs@0.5.6
  • Introduced through: gladys@2.1.9 request@2.45.0 qs@1.2.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0 qs@1.2.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 body-parser@1.13.3 qs@4.0.0
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 qs@4.0.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 qs@4.0.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 body-parser@1.13.3 qs@4.0.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 body-parser@1.13.3 qs@4.0.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 qs@2.4.2

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

  • GitHub Commit
  • GitHub Issue

high severity

Denial of Service (DoS)

  • Vulnerable module: rrule
  • Introduced through: ical@0.8.0

Detailed paths

  • Introduced through: gladys@2.1.9 ical@0.8.0 rrule@2.4.1

Overview

rrule is a JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.

Affected versions of this package are vulnerable to Denial of Service (DoS). When the interval is set to 0, the page might crash due to an infinite loop.

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 rrule to version 2.6.0 or higher.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: sails
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5
    Remediation: Upgrade to gladys@3.0.0.

Overview

sails is API-driven framework for building realtime apps, using MVC conventions (based on Express and Socket.io). Affected versions of the package are vulnerable to a Denial of Service (DoS) attack by sending an OPTIONS request for an undefined route, emitted on the socket.io REST interface. This causes sails to become unresponsive.

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 sails to version 0.12.0-rc4 or higher.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: sails-hook-sockets
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3
    Remediation: Upgrade to sails@1.0.0.

Overview

sails-hook-sockets is an Implements socket.io support in Sails

Affected versions of this package are vulnerable to Denial of Service (DoS). It allows attackers to cause a denial of service with a single request because there is no error handler to handle an empty pathname in a WebSocket 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 sails-hook-sockets to version 1.5.5 or higher.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: socket.io-parser
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-adapter@0.4.0 socket.io-parser@2.2.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 socket.io-parser@2.2.6
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-parser@2.2.6
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 socket.io-parser@2.2.6
    Remediation: Upgrade to sails@1.0.0.

Overview

socket.io-parser is a socket.io protocol parser

Affected versions of this package are vulnerable to Denial of Service (DoS) via a large packet because a concatenation approach is used.

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 socket.io-parser to version 3.3.2, 3.4.1 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: trim
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 @mapbox/geojsonhint@2.0.1 vfile-reporter@3.0.0 trim@0.0.1

Overview

trim is a Trim string whitespace

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via trim().

PoC by Liyuan Chen:


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

return ret + "1";
}
var time = Date.now();
trim(build_attack(50000))
var time_cost = Date.now() - time;
console.log("time_cost: " + time_cost)```

## 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:
```js
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 trim to version 0.0.3 or higher.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: ws
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 engine.io@1.6.11 ws@1.1.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 engine.io-client@1.6.11 ws@1.0.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 engine.io-client@1.6.11 ws@1.0.1
    Remediation: Upgrade to gladys@3.0.0.

Overview

ws is a WebSocket client and server implementation.

Affected versions of this package did not limit the size of an incoming payload before it was processed by default. As a result, a very large payload (over 256MB in size) could lead to a failed allocation and crash the node process - enabling a Denial of Service attack.

While 256MB may seem excessive, note that the attack is likely to be sent from another server, not an end-user computer, using data-center connection speeds. In those speeds, a payload of this size can be transmitted in seconds.

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

Update to version 1.1.1 or greater, which sets a default maxPayload of 100MB. If you cannot upgrade, apply a Snyk patch, or provide ws with options setting the maxPayload to an appropriate size that is smaller than 256MB.

References

high severity

Denial of Service (DoS)

  • Vulnerable module: ws
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 engine.io@1.6.11 ws@1.1.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 engine.io-client@1.6.11 ws@1.0.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 engine.io-client@1.6.11 ws@1.0.1
    Remediation: Upgrade to sails@1.0.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

Prototype Pollution

  • Vulnerable module: deep-extend
  • Introduced through: rc@0.5.5 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 rc@0.5.5 deep-extend@0.2.11
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 rc@0.5.5 deep-extend@0.2.11
    Remediation: Upgrade to sails@1.2.1.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 rc@0.3.5 deep-extend@0.2.11
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 rc@0.3.5 deep-extend@0.2.11
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 rc@0.3.5 deep-extend@0.2.11
    Remediation: Upgrade to sails@1.0.0.

Overview

deep-extend is a library for Recursive object extending.

Affected versions of this package are vulnerable to Prototype Pollution. Utilities function in all the listed modules can be tricked into modifying the prototype of "Object" when the attacker control part of the structure passed to these function. This can let an attacker add or modify existing property that will exist on all object.

PoC by HoLyVieR

var merge = require('deep-extend');
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

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 deep-extend to version 0.5.1 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: handlebars
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 express-handlebars@2.0.1 handlebars@3.0.8
    Remediation: Upgrade to gladys@3.0.0.

Overview

handlebars is an extension to the Mustache templating language.

Affected versions of this package are vulnerable to Prototype Pollution. Templates may alter an Objects' prototype, thus allowing an attacker to execute arbitrary code on the server.

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

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 handlebars to version 4.0.14, 4.1.2 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: handlebars
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 express-handlebars@2.0.1 handlebars@3.0.8
    Remediation: Upgrade to gladys@3.0.0.

Overview

handlebars is a extension to the Mustache templating language.

Affected versions of this package are vulnerable to Prototype Pollution. Templates may alter an Object's __proto__ and __defineGetter__ properties, which may allow an attacker to execute arbitrary code on the server through crafted payloads.

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

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 handlebars to version 4.3.0, 3.8.0 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: ini
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 rc@0.3.5 ini@1.1.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 rc@0.3.5 ini@1.1.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 rc@0.3.5 ini@1.1.0
    Remediation: Upgrade to sails@1.0.0.

Overview

ini is an An ini encoder/decoder for node

Affected versions of this package are vulnerable to Prototype Pollution. If an attacker submits a malicious INI file to an application that parses it with ini.parse, they will pollute the prototype on the application. This can be exploited further depending on the context.

PoC by Eugene Lim

payload.ini

[__proto__]
polluted = "polluted"

poc.js:

var fs = require('fs')
var ini = require('ini')

var parsed = ini.parse(fs.readFileSync('./payload.ini', 'utf-8'))
console.log(parsed)
console.log(parsed.__proto__)
console.log(polluted)
> node poc.js
{}
{ polluted: 'polluted' }
{ polluted: 'polluted' }
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

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 ini to version 1.3.6 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

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

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: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

Overview

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

Affected versions of this package are vulnerable to Prototype Pollution via the setWith and set functions.

PoC by awarau

  • Create a JS file with this contents:
    lod = require('lodash')
    lod.setWith({}, "__proto__[test]", "123")
    lod.set({}, "__proto__[test2]", "456")
    console.log(Object.prototype)
    
  • Execute it with node
  • Observe that test and test2 is now in the 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

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: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

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

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

Access Restriction Bypass

  • Vulnerable module: xmlhttprequest-ssl
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 engine.io-client@1.6.11 xmlhttprequest-ssl@1.5.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 engine.io-client@1.6.11 xmlhttprequest-ssl@1.5.1
    Remediation: Upgrade to sails@1.0.0.

Overview

xmlhttprequest-ssl is a fork of xmlhttprequest.

Affected versions of this package are vulnerable to Access Restriction Bypass. The package disables SSL certificate validation by default, because rejectUnauthorized (when the property exists but is undefined) is considered to be false within the https.request function of Node.js. In other words, no certificate is ever rejected.

PoC

const XMLHttpRequest = require('xmlhttprequest-ssl');

var xhr = new XMLHttpRequest();        /* pass empty object in version 1.5.4 to work around bug */

xhr.open("GET", "https://self-signed.badssl.com/");
xhr.addEventListener('readystatechange', () => console.log('ready state:', xhr.status));
xhr.addEventListener('loadend', loadend);

function loadend()
{
  console.log('loadend:', xhr);
  if (xhr.status === 0 && xhr.statusText.code === 'DEPTH_ZERO_SELF_SIGNED_CERT')
    console.log('test passed: self-signed cert rejected');
  else
    console.log('*** test failed: self-signed cert used to retrieve content');
}

xhr.send();

Remediation

Upgrade xmlhttprequest-ssl to version 1.6.1 or higher.

References

high severity

Command Injection

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

Overview

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

Affected versions of this package are vulnerable to Command 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

Uninitialized Memory Exposure

  • Vulnerable module: base64url
  • Introduced through: googleapis@1.0.19

Detailed paths

  • Introduced through: gladys@2.1.9 googleapis@1.0.19 gapitoken@0.1.5 jws@3.0.0 base64url@1.0.6
  • Introduced through: gladys@2.1.9 googleapis@1.0.19 gapitoken@0.1.5 jws@3.0.0 jwa@1.0.2 base64url@0.0.6

Overview

base64url Converting to, and from, base64url.

Affected versions of this package are vulnerable to Uninitialized Memory Exposure. An attacker could extract sensitive data from uninitialized memory or may cause a Denial of Service (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 base64url to version 3.0.0 or higher. Note This is vulnerable only for Node <=4

References

high severity

Arbitrary Code Execution

  • Vulnerable module: grunt
  • Introduced through: grunt@0.4.5 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 grunt@0.4.5
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2
    Remediation: Upgrade to sails@1.0.0.

Overview

grunt is a JavaScript task runner.

Affected versions of this package are vulnerable to Arbitrary Code Execution due to the default usage of the function load() instead of its secure replacement safeLoad() of the package js-yaml inside grunt.file.readYAML.

Remediation

Upgrade grunt to version 1.3.0 or higher.

References

medium severity

Arbitrary Code Injection

  • Vulnerable module: morgan
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 morgan@1.6.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 morgan@1.6.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 morgan@1.6.1
    Remediation: Upgrade to gladys@3.0.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

Prototype Pollution

  • Vulnerable module: handlebars
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 express-handlebars@2.0.1 handlebars@3.0.8
    Remediation: Upgrade to gladys@3.0.0.

Overview

handlebars is an extension to the Mustache templating language.

Affected versions of this package are vulnerable to Prototype Pollution. Prototype access to the template engine allows for potential code execution.

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 handlebars to version 4.6.0 or higher.

References

medium severity

Timing Attack

  • Vulnerable module: http-signature
  • Introduced through: request@2.45.0, googleapis@1.0.19 and others

Detailed paths

  • Introduced through: gladys@2.1.9 request@2.45.0 http-signature@0.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 googleapis@1.0.19 request@2.40.0 http-signature@0.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0 http-signature@0.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 http-signature@0.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 http-signature@0.10.1
    Remediation: Upgrade to gladys@3.0.0.

Overview

http-signature is a reference implementation of Joyent's HTTP Signature scheme.

Affected versions of the package are vulnerable to Timing Attacks due to time-variable comparison of signatures.

The library implemented a character to character comparison, similar to the built-in string comparison mechanism, ===, and not a time constant string comparison. As a result, the comparison will fail faster when the first characters in the signature are incorrect. An attacker can use this difference to perform a timing attack, essentially allowing them to guess the signature one character at a time.

You can read more about timing attacks in Node.js on the Snyk blog.

Remediation

Upgrade http-signature to version 1.0.0 or higher.

References

medium severity

Denial of Service (DoS)

  • Vulnerable module: qs
  • Introduced through: grunt-contrib-watch@0.5.3 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 tiny-lr@0.0.4 qs@0.5.6
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 tiny-lr-fork@0.0.5 qs@0.5.6
    Remediation: Open PR to patch qs@0.5.6.

Overview

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

Affected versions of this package are vulnerable to Denial of Service (DoS). When parsing a string representing a deeply nested object, qs will block the event loop for long periods of time. Such a delay may hold up the server's resources, keeping it from processing other requests in the meantime, thus enabling a Denial-of-Service attack.

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 qs to version 1.0.0 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: @sailshq/lodash
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-stringfile@0.3.3 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 skipper-disk@0.5.12 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 switchback@2.0.5 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-frontend@0.11.7 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-generator@0.10.11 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 merge-defaults@0.2.2 @sailshq/lodash@3.10.4

Overview

@sailshq/lodash is a fork of Lodash 3.10.x with ongoing maintenance from the Sails core team.

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

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 @sailshq/lodash.

References

medium severity

Prototype Pollution

  • Vulnerable module: hoek
  • Introduced through: request@2.45.0, googleapis@1.0.19 and others

Detailed paths

  • Introduced through: gladys@2.1.9 request@2.45.0 hawk@1.1.1 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 request@2.45.0 hawk@1.1.1 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 request@2.45.0 hawk@1.1.1 sntp@0.2.4 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 googleapis@1.0.19 request@2.40.0 hawk@1.1.1 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0 hawk@1.1.1 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 request@2.45.0 hawk@1.1.1 cryptiles@0.2.2 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 googleapis@1.0.19 request@2.40.0 hawk@1.1.1 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0 hawk@1.1.1 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 googleapis@1.0.19 request@2.40.0 hawk@1.1.1 sntp@0.2.4 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0 hawk@1.1.1 sntp@0.2.4 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 hawk@1.1.1 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 googleapis@1.0.19 request@2.40.0 hawk@1.1.1 cryptiles@0.2.2 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0 hawk@1.1.1 cryptiles@0.2.2 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 hawk@1.1.1 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 hawk@1.1.1 sntp@0.2.4 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 hawk@1.1.1 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 hawk@1.1.1 cryptiles@0.2.2 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 hawk@1.1.1 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 hawk@1.1.1 sntp@0.2.4 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 hawk@1.1.1 cryptiles@0.2.2 boom@0.4.2 hoek@0.9.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 hawk@3.1.3 hoek@2.16.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 hawk@3.1.3 boom@2.10.1 hoek@2.16.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 hawk@3.1.3 sntp@1.0.9 hoek@2.16.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 node-pre-gyp@0.6.39 request@2.81.0 hawk@3.1.3 hoek@2.16.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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 gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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 gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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 gladys@3.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 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 gladys@3.0.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: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

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

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.16 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

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

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

Cryptographic Issues

  • Vulnerable module: bcrypt
  • Introduced through: bcrypt@0.8.7

Detailed paths

  • Introduced through: gladys@2.1.9 bcrypt@0.8.7
    Remediation: Upgrade to bcrypt@5.0.0.

Overview

bcrypt is an A library to help you hash passwords.

Affected versions of this package are vulnerable to Cryptographic Issues. When hashing a password containing an ASCII NUL character, that character acts as the string terminator. Any following characters are ignored.

Remediation

Upgrade bcrypt to version 5.0.0 or higher.

References

medium severity

Cross-site Scripting (XSS)

  • Vulnerable module: ejs
  • Introduced through: ejs@0.8.8 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 ejs@0.8.8
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 ejs@0.8.8
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 ejs-locals@1.0.2 ejs@0.8.8

Overview

ejs is a popular JavaScript templating engine. Affected versions of the package are vulnerable to Cross-site Scripting by letting the attacker under certain conditions control and override the filename option causing it to render the value as is, without escaping it. You can read more about this vulnerability on the Snyk blog.

There's also a Remote Code Execution & Denial of Service vulnerabilities caused by the same behaviour.

Details

ejs provides a few different options for you to render a template, two being very similar: ejs.render() and ejs.renderFile(). The only difference being that render expects a string to be used for the template and renderFile expects a path to a template file.

Both functions can be invoked in two ways. The first is calling them with template, data, and options:

ejs.render(str, data, options);

ejs.renderFile(filename, data, options, callback)

The second way would be by calling only the template and data, while ejs lets the options be passed as part of the data:

ejs.render(str, dataAndOptions);

ejs.renderFile(filename, dataAndOptions, callback)

If used with a variable list supplied by the user (e.g. by reading it from the URI with qs or equivalent), an attacker can control ejs options. This includes the filename option, which will be rendered as is when an error occurs during rendering.

ejs.renderFile('my-template', {filename:'<script>alert(1)</script>'}, callback);

The fix introduced in version 2.5.3 blacklisted root options from options passed via the data object.

Disclosure Timeline

  • November 28th, 2016 - Reported the issue to package owner.
  • November 28th, 2016 - Issue acknowledged by package owner.
  • December 06th, 2016 - Issue fixed and version 2.5.5 released.

Remediation

The vulnerability can be resolved by either using the GitHub integration to generate a pull-request from your dashboard or by running snyk wizard from the command-line interface. Otherwise, Upgrade ejs to version 2.5.5 or higher.

References

medium severity

Denial of Service (DoS)

  • Vulnerable module: ejs
  • Introduced through: ejs@0.8.8 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 ejs@0.8.8
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 ejs@0.8.8
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 ejs-locals@1.0.2 ejs@0.8.8

Overview

ejs is a popular JavaScript templating engine. Affected versions of the package are vulnerable to Denial of Service by letting the attacker under certain conditions control and override the localNames option causing it to crash. You can read more about this vulnerability on the Snyk blog.

There's also a Remote Code Execution & Cross-site Scripting vulnerabilities caused by the same behaviour.

Details

ejs provides a few different options for you to render a template, two being very similar: ejs.render() and ejs.renderFile(). The only difference being that render expects a string to be used for the template and renderFile expects a path to a template file.

Both functions can be invoked in two ways. The first is calling them with template, data, and options:

ejs.render(str, data, options);

ejs.renderFile(filename, data, options, callback)

The second way would be by calling only the template and data, while ejs lets the options be passed as part of the data:

ejs.render(str, dataAndOptions);

ejs.renderFile(filename, dataAndOptions, callback)

If used with a variable list supplied by the user (e.g. by reading it from the URI with qs or equivalent), an attacker can control ejs options. This includes the localNames option, which will cause the renderer to crash.

ejs.renderFile('my-template', {localNames:'try'}, callback);

The fix introduced in version 2.5.3 blacklisted root options from options passed via the data object.

Disclosure Timeline

  • November 28th, 2016 - Reported the issue to package owner.
  • November 28th, 2016 - Issue acknowledged by package owner.
  • December 06th, 2016 - Issue fixed and version 2.5.5 released.

Remediation

The vulnerability can be resolved by either using the GitHub integration to generate a pull-request from your dashboard or by running snyk wizard from the command-line interface. Otherwise, Upgrade ejs to version 2.5.5 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: handlebars
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 express-handlebars@2.0.1 handlebars@3.0.8
    Remediation: Upgrade to gladys@3.0.0.

Overview

handlebars is an extension to the Mustache templating language.

Affected versions of this package are vulnerable to Prototype Pollution when selecting certain compiling options to compile templates coming from an untrusted source.

POC

<script src="https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js"></script> 
<script> 
// compile the template 

var s2 = `{{'a/.") || alert("Vulnerable Handlebars JS when compiling in compat mode'}}`; 
var template = Handlebars.compile(s2, { 
compat: true 
}); 
// execute the compiled template and print the output to the console console.log(template({})); 
</script>

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

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 handlebars to version 4.7.7 or higher.

References

medium severity

Remote Code Execution (RCE)

  • Vulnerable module: handlebars
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 express-handlebars@2.0.1 handlebars@3.0.8
    Remediation: Upgrade to gladys@3.0.0.

Overview

handlebars is an extension to the Mustache templating language.

Affected versions of this package are vulnerable to Remote Code Execution (RCE) when selecting certain compiling options to compile templates coming from an untrusted source.

POC

<script src="https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js"></script> 
<script> 
// compile the template 
var s = ` 
{{#with (__lookupGetter__ "__proto__")}} 
{{#with (./constructor.getOwnPropertyDescriptor . "valueOf")}} 
{{#with ../constructor.prototype}} 
{{../../constructor.defineProperty . "hasOwnProperty" ..}} 
{{/with}} 
{{/with}} 
{{/with}} 
{{#with "constructor"}} 
{{#with split}} 
{{pop (push "alert('Vulnerable Handlebars JS when compiling in strict mode');")}} 
{{#with .}} 
{{#with (concat (lookup join (slice 0 1)))}} 
{{#each (slice 2 3)}} 
{{#with (apply 0 ../..)}} 
{{.}} 
{{/with}} 
{{/each}} 
{{/with}} 
{{/with}} 
{{/with}} 
{{/with}} 
`;
var template = Handlebars.compile(s, { 
strict: true 
}); 
// execute the compiled template and print the output to the console console.log(template({})); 
</script>

Remediation

Upgrade handlebars to version 4.7.7 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: minimist
  • Introduced through: rc@0.5.5, sails@0.11.5 and others

Detailed paths

  • Introduced through: gladys@2.1.9 rc@0.5.5 minimist@0.0.10
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 rc@0.5.5 minimist@0.0.10
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 serialport@2.1.2 optimist@0.6.1 minimist@0.0.10
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 rc@0.3.5 minimist@0.0.10
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 optimist@0.6.1 minimist@0.0.10
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 optimist@0.6.1 minimist@0.0.10
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 rc@0.3.5 minimist@0.0.10
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express-handlebars@2.0.1 handlebars@3.0.8 optimist@0.6.1 minimist@0.0.10
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 rc@0.3.5 minimist@0.0.10
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 geojsonhint@1.2.1 minimist@1.1.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 mkdirp@0.5.1 minimist@0.0.8
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 @mapbox/geojsonhint@2.0.1 minimist@1.2.0

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

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

Arbitrary Code Injection

  • Vulnerable module: underscore
  • Introduced through: grunt@0.4.5, sails@0.11.5 and others

Detailed paths

  • Introduced through: gladys@2.1.9 grunt@0.4.5 js-yaml@2.0.5 argparse@0.1.16 underscore@1.7.0
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 js-yaml@2.0.5 argparse@0.1.16 underscore@1.7.0
  • Introduced through: gladys@2.1.9 player@0.6.1 underscore@1.6.0
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 geojsonhint@1.2.1 jsonlint-lines@1.7.1 nomnom@1.8.1 underscore@1.6.0
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 @mapbox/geojsonhint@2.0.1 jsonlint-lines@1.7.1 nomnom@1.8.1 underscore@1.6.0

Overview

underscore is a JavaScript's functional programming helper library.

Affected versions of this package are vulnerable to Arbitrary Code Injection via the template function, particularly when the variable option is taken from _.templateSettings as it is not sanitized.

PoC

const _ = require('underscore');
_.templateSettings.variable = "a = this.process.mainModule.require('child_process').execSync('touch HELLO')";
const t = _.template("")();

Remediation

Upgrade underscore to version 1.13.0-2, 1.12.1 or higher.

References

medium severity

Cross-site Scripting (XSS)

  • Vulnerable module: handlebars
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 express-handlebars@2.0.1 handlebars@3.0.8
    Remediation: Upgrade to gladys@3.0.0.

Overview

handlebars provides the power necessary to let you build semantic templates.

When using attributes without quotes in a handlebars template, an attacker can manipulate the input to introduce additional attributes, potentially executing code. This may lead to a Cross-site Scripting (XSS) vulnerability, assuming an attacker can influence the value entered into the template. If the handlebars template is used to render user-generated content, this vulnerability may escalate to a persistent XSS vulnerability.

Details

Cross-Site Scripting (XSS) attacks occur when an attacker tricks a user’s browser to execute malicious JavaScript code in the context of a victim’s domain. Such scripts can steal the user’s session cookies for the domain, scrape or modify its content, and perform or modify actions on the user’s behalf, actions typically blocked by the browser’s Same Origin Policy.

These attacks are possible by escaping the context of the web application and injecting malicious scripts in an otherwise trusted website. These scripts can introduce additional attributes (say, a "new" option in a dropdown list or a new link to a malicious site) and can potentially execute code on the clients side, unbeknown to the victim. This occurs when characters like < > " ' are not escaped properly.

There are a few types of XSS:

  • Persistent XSS is an attack in which the malicious code persists into the web app’s database.
  • Reflected XSS is an which the website echoes back a portion of the request. The attacker needs to trick the user into clicking a malicious link (for instance through a phishing email or malicious JS on another page), which triggers the XSS attack.
  • DOM-based XSS is an that occurs purely in the browser when client-side JavaScript echoes back a portion of the URL onto the page. DOM-Based XSS is notoriously hard to detect, as the server never gets a chance to see the attack taking place.

Example:

Assume handlebars was used to display user comments and avatar, using the following template: <img src={{avatarUrl}}><pre>{{comment}}</pre>

If an attacker spoofed their avatar URL and provided the following value: http://evil.org/avatar.png onload=alert(document.cookie)

The resulting HTML would be the following, triggering the script once the image loads: <img src=http://evil.org/avatar.png onload=alert(document.cookie)><pre>Gotcha!</pre>

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

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

Insecure Defaults

  • Vulnerable module: socket.io
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8
    Remediation: Upgrade to sails@1.0.0.

Overview

socket.io is a node.js realtime framework server.

Affected versions of this package are vulnerable to Insecure Defaults due to CORS Misconfiguration. All domains are whitelisted by default.

Remediation

Upgrade socket.io to version 2.4.0 or higher.

References

medium severity

Buffer Overflow

  • Vulnerable module: validator
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 validator@3.41.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 validator@4.4.0
    Remediation: Upgrade to gladys@3.0.0.

Overview

validator is a library of string validators and sanitizers.

Affected versions of this package are vulnerable to Buffer Overflow. It used a regular expression (/^(?:[A-Z0-9+\/]{4})*(?:[A-Z0-9+\/]{2}==|[A-Z0-9+\/]{3}=|[A-Z0-9+\/]{4})$/i) in order to validate Base64 strings.

Remediation

Upgrade validator to version 5.0.0 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: validator
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 validator@3.41.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 validator@4.4.0

Overview

validator is an A library of string validators and sanitizers.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the isSlug function

PoC

var validator = require("validator")
function build_attack(n) {
    var ret = "111"
    for (var i = 0; i < n; i++) {
        ret += "a"
    }

    return ret+"_";
}
for(var i = 1; i <= 50000; i++) {
    if (i % 10000 == 0) {
        var time = Date.now();
        var attack_str = build_attack(i)
       validator.isSlug(attack_str)
        var time_cost = Date.now() - time;
        console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
   }
}

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 validator to version 13.6.0 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: validator
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 validator@3.41.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 validator@4.4.0

Overview

validator is an A library of string validators and sanitizers.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the rtrim function.

PoC

var validator = require("validator")
function build_attack(n) {
    var ret = ""
    for (var i = 0; i < n; i++) {
        ret += " "
    }

    return ret+"◎";
}
for(var i = 1; i <= 50000; i++) {
    if (i % 10000 == 0) {
        var time = Date.now();
        var attack_str = build_attack(i)
       validator.rtrim(attack_str)
        var time_cost = Date.now() - time;
        console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
   }

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 validator to version 13.6.0 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: validator
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 validator@3.41.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 validator@4.4.0

Overview

validator is an A library of string validators and sanitizers.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the isHSL function.

PoC

var validator = require("validator")
function build_attack(n) {
    var ret = "hsla(0"
    for (var i = 0; i < n; i++) {
        ret += " "
    }

    return ret+"◎";
}
for(var i = 1; i <= 50000; i++) {
    if (i % 1000 == 0) {
        var time = Date.now();
        var attack_str = build_attack(i)
       validator.isHSL(attack_str)
        var time_cost = Date.now() - time;
        console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
   }
}

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 validator to version 13.6.0 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: validator
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 validator@3.41.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 anchor@0.11.6 validator@4.4.0

Overview

validator is an A library of string validators and sanitizers.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the isEmail function.

PoC

var validator = require("validator")
function build_attack(n) {
    var ret = ""
    for (var i = 0; i < n; i++) {
        ret += "<"
    }

    return ret+"";
}
for(var i = 1; i <= 50000; i++) {
    if (i % 10000 == 0) {
        var time = Date.now();
        var attack_str = build_attack(i)
        validator.isEmail(attack_str,{ allow_display_name: true })
        var time_cost = Date.now() - time;
        console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
   }
}

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 validator to version 13.6.0 or higher.

References

medium severity

Insecure Randomness

  • Vulnerable module: ws
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 engine.io@1.6.11 ws@1.1.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 engine.io-client@1.6.11 ws@1.0.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 engine.io-client@1.6.11 ws@1.0.1
    Remediation: Upgrade to gladys@3.0.0.

Overview

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

Affected versions of the package use the cryptographically insecure Math.random() which can produce predictable values and should not be used in security-sensitive context.

Details

Computers are deterministic machines, and as such are unable to produce true randomness. Pseudo-Random Number Generators (PRNGs) approximate randomness algorithmically, starting with a seed from which subsequent values are calculated.

There are two types of PRNGs: statistical and cryptographic. Statistical PRNGs provide useful statistical properties, but their output is highly predictable and forms an easy to reproduce numeric stream that is unsuitable for use in cases where security depends on generated values being unpredictable. Cryptographic PRNGs address this problem by generating output that is more difficult to predict. For a value to be cryptographically secure, it must be impossible or highly improbable for an attacker to distinguish between it and a truly random value. In general, if a PRNG algorithm is not advertised as being cryptographically secure, then it is probably a statistical PRNG and should not be used in security-sensitive contexts.

You can read more about node's insecure Math.random() in Mike Malone's post.

Remediation

Upgrade ws to version 1.1.2 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: ws
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 engine.io@1.6.11 ws@1.1.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 engine.io-client@1.6.11 ws@1.0.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 engine.io-client@1.6.11 ws@1.0.1
    Remediation: Upgrade to sails@1.0.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

Remote Memory Exposure

  • Vulnerable module: request
  • Introduced through: googleapis@1.0.19, grunt-contrib-less@0.11.1 and others

Detailed paths

  • Introduced through: gladys@2.1.9 googleapis@1.0.19 request@2.40.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 googlemaps@0.1.20 request@2.2.9
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 request@2.45.0
    Remediation: Upgrade to gladys@3.0.0.

Overview

request is a simplified http request client.

Affected versions of this package are vulnerable to Remote Memory Exposure. A potential remote memory exposure vulnerability exists in request. If a request uses a multipart attachment and the body type option is number with value X, then X bytes of uninitialized memory will be sent in the body of the request.

Note that while the impact of this vulnerability is high (memory exposure), exploiting it is likely difficult, as the attacker needs to somehow control the body type of the request. One potential exploit scenario is when a request is composed based on JSON input, including the body type, allowing a malicious JSON to trigger the memory leak.

Details

Constructing a Buffer class with integer N creates a Buffer of length N with non zero-ed out memory. Example:

var x = new Buffer(100); // uninitialized Buffer of length 100
// vs
var x = new Buffer('100'); // initialized Buffer with value of '100'

Initializing a multipart body in such manner will cause uninitialized memory to be sent in the body of the request.

Proof of concept

var http = require('http')
var request = require('request')

http.createServer(function (req, res) {
  var data = ''
  req.setEncoding('utf8')
  req.on('data', function (chunk) {
    console.log('data')
    data += chunk
  })
  req.on('end', function () {
    // this will print uninitialized memory from the client
    console.log('Client sent:\n', data)
  })
  res.end()
}).listen(8000)

request({
  method: 'POST',
  uri: 'http://localhost:8000',
  multipart: [{ body: 1000 }]
},
function (err, res, body) {
  if (err) return console.error('upload failed:', err)
  console.log('sent')
})

Remediation

Upgrade request to version 2.68.0 or higher.

References

medium severity

Uninitialized Memory Exposure

  • Vulnerable module: tunnel-agent
  • Introduced through: request@2.45.0, googleapis@1.0.19 and others

Detailed paths

  • Introduced through: gladys@2.1.9 request@2.45.0 tunnel-agent@0.4.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 googleapis@1.0.19 request@2.40.0 tunnel-agent@0.4.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 pushbullet@1.4.3 request@2.44.0 tunnel-agent@0.4.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 tunnel-agent@0.4.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 request@2.40.0 tunnel-agent@0.4.3
    Remediation: Upgrade to gladys@3.0.0.

Overview

tunnel-agent is HTTP proxy tunneling agent. Affected versions of the package are vulnerable to Uninitialized Memory Exposure.

A possible memory disclosure vulnerability exists when a value of type number is used to set the proxy.auth option of a request request and results in a possible uninitialized memory exposures in the request body.

This is a result of unobstructed use of the Buffer constructor, whose insecure default constructor increases the odds of memory leakage.

Details

Constructing a Buffer class with integer N creates a Buffer of length N with raw (not "zero-ed") memory.

In the following example, the first call would allocate 100 bytes of memory, while the second example will allocate the memory needed for the string "100":

// uninitialized Buffer of length 100
x = new Buffer(100);
// initialized Buffer with value of '100'
x = new Buffer('100');

tunnel-agent's request construction uses the default Buffer constructor as-is, making it easy to append uninitialized memory to an existing list. If the value of the buffer list is exposed to users, it may expose raw server side memory, potentially holding secrets, private data and code. This is a similar vulnerability to the infamous Heartbleed flaw in OpenSSL.

Proof of concept by ChALkeR

require('request')({
  method: 'GET',
  uri: 'http://www.example.com',
  tunnel: true,
  proxy:{
      protocol: 'http:',
      host:"127.0.0.1",
      port:8080,
      auth:80
  }
});

You can read more about the insecure Buffer behavior on our blog.

Similar vulnerabilities were discovered in request, mongoose, ws and sequelize.

Remediation

Upgrade tunnel-agent to version 0.6.0 or higher. Note This is vulnerable only for Node <=4

References

medium severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, sails-disk@0.10.10 and others

Detailed paths

  • Introduced through: gladys@2.1.9 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-schema@0.1.20 lodash@3.10.1
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-coffee@0.10.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-jst@0.6.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-hook-hookloader@0.2.0 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@2.1.9 sails-memory@0.10.7 waterline-cursor@0.0.6 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-cli@0.1.13 findup-sync@0.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 findup-sync@0.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-log@0.1.3 grunt-legacy-log-utils@0.1.1 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@2.1.9 grunt@0.4.5 lodash@0.9.2
    Remediation: Upgrade to grunt@1.0.0.
  • Introduced through: gladys@2.1.9 grunt@0.4.5 grunt-legacy-util@0.2.0 lodash@0.9.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt@0.4.2 lodash@0.9.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-watch@0.5.3 gaze@0.4.3 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-watch@0.6.1 gaze@0.5.2 globule@0.1.0 lodash@1.0.2
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 waterline@0.10.31 lodash@3.9.3
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@2.1.9 sails@0.11.5 captains-log@0.11.11 lodash@2.4.1
  • Introduced through: gladys@2.1.9 sails@0.11.5 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-generate@0.12.4 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 lodash@3.8.0
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@2.1.9 sails-mysql@0.10.12 waterline-sequel@0.4.0 lodash@3.8.0

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

medium severity

Denial of Service (DoS)

  • Vulnerable module: rrule
  • Introduced through: ical@0.8.0

Detailed paths

  • Introduced through: gladys@2.1.9 ical@0.8.0 rrule@2.4.1

Overview

rrule is a JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.

Affected versions of this package are vulnerable to Denial of Service (DoS). An attacker trigger an infinite loop, causing the system to stop responding.

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 rrule to version 2.5.6 or higher.

References

medium severity

Arbitrary Code Injection

  • Vulnerable module: ejs
  • Introduced through: ejs@0.8.8 and sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 ejs@0.8.8
    Remediation: Upgrade to ejs@3.1.6.
  • Introduced through: gladys@2.1.9 sails@0.11.5 ejs@0.8.8
  • Introduced through: gladys@2.1.9 sails@0.11.5 ejs-locals@1.0.2 ejs@0.8.8

Overview

ejs is a popular JavaScript templating engine.

Affected versions of this package are vulnerable to Arbitrary Code Injection via the render and renderFile. If external input is flowing into the options parameter, an attacker is able run arbitrary code. This include the filename, compileDebug, and client option.

POC

let ejs = require('ejs')
ejs.render('./views/test.ejs',{
    filename:'/etc/passwd\nfinally { this.global.process.mainModule.require(\'child_process\').execSync(\'touch EJS_HACKED\') }',
    compileDebug: true,
    message: 'test',
    client: true
})

Remediation

Upgrade ejs to version 3.1.6 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: clean-css
  • Introduced through: grunt-contrib-cssmin@0.9.0, sails@0.11.5 and others

Detailed paths

  • Introduced through: gladys@2.1.9 grunt-contrib-cssmin@0.9.0 clean-css@2.1.8
    Remediation: Upgrade to grunt-contrib-cssmin@2.2.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-cssmin@0.9.0 clean-css@2.1.8
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 grunt-contrib-less@0.11.1 less@1.7.5 clean-css@2.2.23
  • Introduced through: gladys@2.1.9 sails@0.11.5 grunt-contrib-less@0.11.1 less@1.7.5 clean-css@2.2.23

Overview

clean-css is a fast and efficient CSS optimizer for Node.js platform and any modern browser.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). attacks. This can cause an impact of about 10 seconds matching time for data 70k characters long.

Disclosure Timeline

  • Feb 15th, 2018 - Initial Disclosure to package owner
  • Feb 20th, 2018 - Initial Response from package owner
  • Mar 6th, 2018 - Fix issued
  • Mar 7th, 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 clean-css to version 4.1.11 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: debug
  • Introduced through: sails@0.11.5

Detailed paths

  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 body-parser@1.13.3 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 compression@1.5.2 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 connect-timeout@1.6.2 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 express-session@1.11.3 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 finalhandler@0.4.0 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 morgan@1.6.1 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 serve-index@1.7.3 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 send@0.13.0 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 body-parser@1.13.3 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 body-parser@1.13.3 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 compression@1.5.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 compression@1.5.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 connect-timeout@1.6.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 connect-timeout@1.6.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 express-session@1.11.3 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 express-session@1.11.3 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 finalhandler@0.4.0 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 finalhandler@0.4.0 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 morgan@1.6.1 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 morgan@1.6.1 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 serve-index@1.7.3 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 serve-index@1.7.3 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 connect@2.30.0 serve-static@1.10.3 send@0.13.2 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 engine.io@1.6.11 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-adapter@0.4.0 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 engine.io-client@1.6.11 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io-client@1.4.8 socket.io-parser@2.2.6 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-parser@2.2.6 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 express@3.21.2 connect@2.30.2 serve-static@1.10.3 send@0.13.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 skipper@0.5.9 connect@2.30.2 serve-static@1.10.3 send@0.13.2 debug@2.2.0
    Remediation: Upgrade to gladys@3.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 engine.io-client@1.6.11 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@2.1.9 sails@0.11.5 sails-hook-sockets@0.12.3 socket.io@1.4.8 socket.io-client@1.4.8 socket.io-parser@2.2.6 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.

Overview

debug is a JavaScript debugging utility modelled after Node.js core's debugging technique..

debug uses printf-style formatting. Affected versions of this package are vulnerable to Regular expression Denial of Service (ReDoS) attacks via the the %o formatter (Pretty-print an Object all on a single line). It used a regular expression (/\s*\n\s*/g) in order to strip whitespaces and replace newlines with spaces, in order to join the data into a single line. This can cause a very low impact of about 2 seconds matching time for data 50k characters long.

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 us