gladys@3.6.0

Vulnerabilities

68 via 757 paths

Dependencies

817

Source

npm

Find, fix and prevent vulnerabilities in your code.

Severity
  • 1
  • 37
  • 23
  • 7
Status
  • 68
  • 0
  • 0

critical severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 uid-safe@1.1.0 base64-url@1.2.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 express-session@1.11.3 uid-safe@2.0.0 base64-url@1.2.1

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
new

Prototype Pollution

  • Vulnerable module: json-schema
  • Introduced through: request@2.88.2, bcrypt@1.0.3 and others

Detailed paths

  • Introduced through: gladys@3.6.0 request@2.88.2 http-signature@1.2.0 jsprim@1.4.1 json-schema@0.2.3
  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 request@2.88.2 http-signature@1.2.0 jsprim@1.4.1 json-schema@0.2.3
  • Introduced through: gladys@3.6.0 grunt-contrib-less@1.4.1 less@2.7.3 request@2.81.0 http-signature@1.1.1 jsprim@1.4.1 json-schema@0.2.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-less@1.3.0 less@2.6.1 request@2.88.2 http-signature@1.2.0 jsprim@1.4.1 json-schema@0.2.3

Overview

Affected versions of this package are vulnerable to Prototype Pollution via the validate function, which when given a special payload will pollute Object with undesired attributes.

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 json-schema to version 0.4.0 or higher.

References

high severity

Arbitrary File Write

  • Vulnerable module: tar
  • Introduced through: bcrypt@1.0.3

Detailed paths

  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 tar@2.2.2
    Remediation: Upgrade to bcrypt@2.0.0.
  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 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: bcrypt@1.0.3

Detailed paths

  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 tar@2.2.2
    Remediation: Upgrade to bcrypt@2.0.0.
  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 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: bcrypt@1.0.3

Detailed paths

  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 tar@2.2.2
    Remediation: Upgrade to bcrypt@2.0.0.
  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 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

Arbitrary File Overwrite

  • Vulnerable module: tar
  • Introduced through: bcrypt@1.0.3

Detailed paths

  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 tar@2.2.2
    Remediation: Upgrade to bcrypt@2.0.0.
  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 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: bcrypt@1.0.3

Detailed paths

  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 tar@2.2.2
    Remediation: Upgrade to bcrypt@2.0.0.
  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 tar-pack@3.4.1 tar@2.2.2

Overview

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

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

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

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

Remediation

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

References

high severity

Prototype Pollution

  • Vulnerable module: ajv
  • Introduced through: grunt-contrib-less@1.4.1

Detailed paths

  • Introduced through: gladys@3.6.0 grunt-contrib-less@1.4.1 less@2.7.3 request@2.81.0 har-validator@4.2.1 ajv@4.11.8
    Remediation: Upgrade to grunt-contrib-less@2.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: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 ejs@2.3.4
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 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: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 js-yaml@3.5.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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 engine.io-client@1.8.3 xmlhttprequest-ssl@1.5.3
    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

Insecure Encryption

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

Detailed paths

  • Introduced through: gladys@3.6.0 bcrypt@1.0.3
    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

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: chrono-node
  • Introduced through: chrono-node@1.4.8

Detailed paths

  • Introduced through: gladys@3.6.0 chrono-node@1.4.8
    Remediation: Upgrade to chrono-node@2.2.4.

Overview

chrono-node is an A natural language date parser in Javascript

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It hangs on a date-like string with lots of embedded spaces.

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 chrono-node to version 2.2.4 or higher.

References

high severity

Denial of Service (DoS)

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

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 engine.io@1.8.3

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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 fresh@0.3.0
  • Introduced through: gladys@3.6.0 sails@0.12.14 serve-favicon@2.3.0 fresh@0.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 fresh@0.3.0
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 send@0.13.0 fresh@0.3.0
  • Introduced through: gladys@3.6.0 sails@0.12.14 serve-static@1.10.2 send@0.13.1 fresh@0.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-favicon@2.3.2 fresh@0.3.0
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-static@1.10.3 send@0.13.2 fresh@0.3.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: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 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: method-override
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 method-override@2.3.5
    Remediation: Upgrade to sails@1.0.0.

Overview

method-override is a module to override HTTP verbs.

Affected versions of this package are vulnerable to Regular expression Denial of Service (ReDoS). It uses regex the following regex / *, */ in order to split HTTP headers. An attacker may send specially crafted input in the X-HTTP-Method-Override header and cause a significant slowdown.

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 method-override to version 2.3.10 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: minimatch
  • Introduced through: grunt-sync@0.5.2 and sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 glob@4.5.3 minimatch@2.0.10
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 glob@4.5.3 minimatch@2.0.10
    Remediation: Upgrade to sails@1.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: grunt-sync@0.5.2 and sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 glob@4.5.3 minimatch@2.0.10
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 glob@4.5.3 minimatch@2.0.10
    Remediation: Upgrade to sails@1.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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 compression@1.5.2 accepts@1.2.13 negotiator@0.5.3
    Remediation: Open PR to patch negotiator@0.5.3.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-index@1.7.3 accepts@1.2.13 negotiator@0.5.3
    Remediation: Open PR to patch negotiator@0.5.3.

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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 engine.io-client@1.8.3 parsejson@0.0.3

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

Prototype Override Protection Bypass

  • Vulnerable module: qs
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 tiny-lr@0.2.1 body-parser@1.14.2 qs@5.2.0
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 tiny-lr@0.2.1 qs@5.1.0
    Remediation: Upgrade to sails@1.0.0.

Overview

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

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

From qs documentation:

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

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

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

Example:

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

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

For more information, you can check out our blog.

Disclosure Timeline

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

    Remediation

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

    References

  • GitHub Commit
  • GitHub Issue

high severity

Denial of Service (DoS)

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

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14
    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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-parser@2.3.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-adapter@0.5.0 socket.io-parser@2.3.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 socket.io-parser@2.3.1
    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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 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: trim-newlines
  • Introduced through: grunt-contrib-cssmin@1.0.2, grunt-contrib-uglify@2.3.0 and others

Detailed paths

  • Introduced through: gladys@3.6.0 grunt-contrib-cssmin@1.0.2 maxmin@1.1.0 pretty-bytes@1.0.4 meow@3.7.0 trim-newlines@1.0.0
    Remediation: Upgrade to grunt-contrib-cssmin@2.1.0.
  • Introduced through: gladys@3.6.0 grunt-contrib-uglify@2.3.0 maxmin@1.1.0 pretty-bytes@1.0.4 meow@3.7.0 trim-newlines@1.0.0
    Remediation: Upgrade to grunt-contrib-uglify@3.4.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 dateformat@1.0.12 meow@3.7.0 trim-newlines@1.0.0
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-cssmin@1.0.1 maxmin@1.1.0 pretty-bytes@1.0.4 meow@3.7.0 trim-newlines@1.0.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-uglify@1.0.1 maxmin@1.1.0 pretty-bytes@1.0.4 meow@3.7.0 trim-newlines@1.0.0
    Remediation: Upgrade to sails@1.0.0.

Overview

trim-newlines is a Trim newlines from the start and/or end of a string

Affected versions of this package are vulnerable to Denial of Service (DoS) via the end() method.

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 trim-newlines to version 3.0.1, 4.0.1 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: underscore.string
  • Introduced through: grunt@1.4.1 and sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 grunt@1.4.1 grunt-legacy-util@2.0.1 underscore.string@3.3.5
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 underscore.string@3.2.3

Overview

underscore.string is a Javascript lacks complete string manipulation operations.

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

There is no fixed version for underscore.string.

References

high severity

Denial of Service (DoS)

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

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 engine.io@1.8.3 ws@1.1.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 engine.io-client@1.8.3 ws@1.1.2
    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: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 rc@1.0.1 deep-extend@0.2.11
    Remediation: Upgrade to sails@1.2.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 rc@0.3.5 deep-extend@0.2.11
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 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@3.6.0 sails@0.12.14 sails-generate@0.13.0 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: ini
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 rc@0.3.5 ini@1.1.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 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@3.6.0 sails@0.12.14 sails-generate@0.13.0 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

Command Injection

  • Vulnerable module: limdu
  • Introduced through: limdu@0.8.0

Detailed paths

  • Introduced through: gladys@3.6.0 limdu@0.8.0

Overview

limdu is an A machine learning framework for Node.js. Supports multi-level classification and online learning.

Affected versions of this package are vulnerable to Command Injection via the trainBatch function. Clients of the Limdu library are unlikely to be aware of this, so they might unwittingly write code that contains a vulnerability.

Remediation

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

References

high severity

Prototype Pollution

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 engine.io-client@1.8.3 xmlhttprequest-ssl@1.5.3
    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, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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

Arbitrary Code Execution

  • Vulnerable module: grunt
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1
    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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 morgan@1.6.1

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: @sailshq/lodash
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 flaverr@1.10.0 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-stringfile@0.3.3 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 skipper-disk@0.5.12 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-generator@0.10.11 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 merge-defaults@0.2.2 @sailshq/lodash@3.10.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 anchor@0.11.6 @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: jsonwebtoken@7.4.3 and grunt-contrib-less@1.4.1

Detailed paths

  • Introduced through: gladys@3.6.0 jsonwebtoken@7.4.3 joi@6.10.1 hoek@2.16.3
    Remediation: Upgrade to jsonwebtoken@8.0.0.
  • Introduced through: gladys@3.6.0 jsonwebtoken@7.4.3 joi@6.10.1 topo@1.1.0 hoek@2.16.3
    Remediation: Upgrade to jsonwebtoken@8.0.0.
  • Introduced through: gladys@3.6.0 grunt-contrib-less@1.4.1 less@2.7.3 request@2.81.0 hawk@3.1.3 hoek@2.16.3
    Remediation: Upgrade to grunt-contrib-less@2.0.0.
  • Introduced through: gladys@3.6.0 grunt-contrib-less@1.4.1 less@2.7.3 request@2.81.0 hawk@3.1.3 boom@2.10.1 hoek@2.16.3
    Remediation: Upgrade to grunt-contrib-less@2.0.0.
  • Introduced through: gladys@3.6.0 grunt-contrib-less@1.4.1 less@2.7.3 request@2.81.0 hawk@3.1.3 sntp@1.0.9 hoek@2.16.3
    Remediation: Upgrade to grunt-contrib-less@2.0.0.
  • Introduced through: gladys@3.6.0 grunt-contrib-less@1.4.1 less@2.7.3 request@2.81.0 hawk@3.1.3 cryptiles@2.0.5 boom@2.10.1 hoek@2.16.3
    Remediation: Upgrade to grunt-contrib-less@2.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, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
    Remediation: Open PR to patch lodash@3.10.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 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@3.6.0 sails@0.12.14 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@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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@1.0.3

Detailed paths

  • Introduced through: gladys@3.6.0 bcrypt@1.0.3
    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: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 ejs@2.3.4
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 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: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 ejs@2.3.4
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 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

Denial of Service (DoS)

  • Vulnerable module: js-yaml
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 js-yaml@3.5.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 Denial of Service (DoS). The parsing of a specially crafted YAML file may exhaust the system resources.

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 js-yaml to version 3.13.0 or higher.

References

medium severity

Prototype Pollution

  • Vulnerable module: minimist
  • Introduced through: sails@0.12.14 and sails-util-mvcsloader@0.3.2

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 mkdirp@0.5.1 minimist@0.0.8
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 geojsonhint@1.2.1 minimist@1.1.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 rc@1.0.1 minimist@0.0.10
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 rc@0.3.5 minimist@0.0.10
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 optimist@0.6.1 minimist@0.0.10
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 optimist@0.6.1 minimist@0.0.10
  • Introduced through: gladys@3.6.0 sails@0.12.14 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@3.6.0 sails@0.12.14 sails-generate@0.13.0 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@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 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: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 geojsonhint@1.2.1 jsonlint-lines@1.7.1 nomnom@1.8.1 underscore@1.6.0
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 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

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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
new

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: natural
  • Introduced through: natural@0.4.0

Detailed paths

  • Introduced through: gladys@3.6.0 natural@0.4.0
    Remediation: Upgrade to natural@5.1.11.

Overview

natural is a General natural language (tokenizing, stemming (English, Russian, Spanish), part-of-speech tagging, sentiment analysis, classification, inflection, phonetics, tfidf, WordNet, jaro-winkler, Levenshtein distance, Dice's Coefficient) facilities for node.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to using the regex /^\s+|\s+$/g in dice_coefficient.js file.

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 natural to version 5.1.11 or higher.

References

medium severity

Insecure Defaults

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

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3
    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
new

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: uglify-js
  • Introduced through: grunt-contrib-uglify@2.3.0 and sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 grunt-contrib-uglify@2.3.0 uglify-js@2.8.29
    Remediation: Upgrade to grunt-contrib-uglify@4.0.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-uglify@1.0.1 uglify-js@2.6.4
    Remediation: Upgrade to sails@1.0.0.

Overview

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

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

Details

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

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

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

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

This regular expression accomplishes the following:

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

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

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

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

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

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

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

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

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

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

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

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

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

Remediation

Upgrade uglify-js to version 3.14.3 or higher.

References

medium severity

Buffer Overflow

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

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 validator@3.41.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 anchor@0.11.6 validator@4.4.0
    Remediation: Upgrade to sails@1.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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 validator@3.41.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 anchor@0.11.6 validator@4.4.0

Overview

validator is 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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 validator@3.41.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 anchor@0.11.6 validator@4.4.0

Overview

validator is 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.7.0 or higher.

References

medium severity

Regular Expression Denial of Service (ReDoS)

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

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 validator@3.41.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 anchor@0.11.6 validator@4.4.0

Overview

validator is 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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 validator@3.41.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 anchor@0.11.6 validator@4.4.0

Overview

validator is 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

Regular Expression Denial of Service (ReDoS)

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

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 engine.io@1.8.3 ws@1.1.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 engine.io-client@1.8.3 ws@1.1.2
    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

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: lodash
  • Introduced through: barrels@1.6.6, grunt-sync@0.5.2 and others

Detailed paths

  • Introduced through: gladys@3.6.0 barrels@1.6.6 lodash@3.10.1
  • Introduced through: gladys@3.6.0 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to grunt-sync@0.6.2.
  • Introduced through: gladys@3.6.0 include-all@1.0.8 lodash@3.10.1
    Remediation: Upgrade to include-all@3.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 lodash@3.10.1
    Remediation: Upgrade to sails-mysql@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-sync@0.5.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 include-all@1.0.8 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 captains-log@1.0.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 rttc@9.3.3 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 lodash@3.10.1
    Remediation: Upgrade to sails@1.1.0.
  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 waterline-sequel@0.6.4 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-criteria@1.0.1 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-disk@0.10.10 waterline-cursor@0.0.7 lodash@3.10.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-schema@0.2.2 lodash@3.10.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 anchor@0.10.5 lodash@3.9.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-new@0.10.29 lodash@3.9.3
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-coffee@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-util@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt@1.0.1 grunt-legacy-log@1.0.2 grunt-legacy-log-utils@1.0.0 lodash@4.3.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-jst@1.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-build-dictionary@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-util@0.11.0 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails-util-mvcsloader@0.3.2 sails-util@0.10.6 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-adapter@0.10.7 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-backend@0.12.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-controller@0.10.9 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-gruntfile@0.10.11 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-model@0.10.12 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-sails.io.js@0.13.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views@0.10.8 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-views-jade@0.10.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 merge-defaults@0.1.4 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-api@0.10.1 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 switchback@1.1.3 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 merge-defaults@0.1.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 sails-generate-sails.io.js@0.14.0 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 switchback@2.0.0 lodash@2.4.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 waterline-criteria@0.11.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 merge-defaults@0.1.4 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 switchback@1.1.3 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 machinepack-urls@3.1.1 machine@4.1.1 rttc@1.0.2 lodash@2.4.2
  • Introduced through: gladys@3.6.0 sails@0.12.14 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 sails-generate-frontend@0.12.3 lodash@2.4.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-generate@0.13.0 reportback@0.1.9 captains-log@0.11.11 lodash@2.4.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 rttc@9.3.4 lodash@3.8.0
    Remediation: Upgrade to sails@1.0.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

Arbitrary Code Injection

  • Vulnerable module: ejs
  • Introduced through: ejs@2.7.4 and sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 ejs@2.7.4
    Remediation: Upgrade to ejs@3.1.6.
  • Introduced through: gladys@3.6.0 sails@0.12.14 ejs@2.3.4
  • Introduced through: gladys@3.6.0 sails@0.12.14 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@1.0.2 and sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 grunt-contrib-cssmin@1.0.2 clean-css@3.4.28
    Remediation: Upgrade to grunt-contrib-cssmin@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-cssmin@1.0.1 clean-css@3.4.28
    Remediation: Upgrade to sails@1.0.0.

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.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 compression@1.6.2 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 connect@3.4.1 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 express-session@1.14.2 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 method-override@2.3.5 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 send@0.13.0 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 connect@3.4.1 finalhandler@0.4.1 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 tiny-lr@0.2.1 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 serve-static@1.10.2 send@0.13.1 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 @sailshq/body-parser@1.13.4 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 compression@1.5.2 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 connect-timeout@1.6.2 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 express-session@1.11.3 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 finalhandler@0.4.0 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 morgan@1.6.1 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-index@1.7.3 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 tiny-lr@0.2.1 body-parser@1.14.2 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-parser@2.3.1 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 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@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-adapter@0.5.0 socket.io-parser@2.3.1 debug@2.2.0
    Remediation: Open PR to patch debug@2.2.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 socket.io-parser@2.3.1 debug@2.2.0
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 debug@2.3.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 engine.io@1.8.3 debug@2.3.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-adapter@0.5.0 debug@2.3.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 debug@2.3.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 engine.io-client@1.8.3 debug@2.3.3
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 body-parser@1.17.1 debug@2.6.1
    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 user 0.02s system 99% cpu 1.812 total

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

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

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

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

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

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

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

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

Remediation

Upgrade debug to version 2.6.9, 3.1.0 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: mime
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 send@0.13.0 mime@1.3.4
    Remediation: Open PR to patch mime@1.3.4.
  • Introduced through: gladys@3.6.0 sails@0.12.14 serve-static@1.10.2 send@0.13.1 mime@1.3.4
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-static@1.10.3 send@0.13.2 mime@1.3.4
    Remediation: Open PR to patch mime@1.3.4.

Overview

mime is a comprehensive, compact MIME type module.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It uses regex the following regex /.*[\.\/\\]/ in its lookup, which can cause a slowdown of 2 seconds for 50k characters.

Details

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

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

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

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

This regular expression accomplishes the following:

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

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

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

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

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

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

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

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

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

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

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

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

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

Remediation

Upgrade mime to version 1.4.1, 2.0.3 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: ms
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 serve-favicon@2.3.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 compression@1.6.2 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 connect@3.4.1 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 express-session@1.14.2 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 method-override@2.3.5 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 send@0.13.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 serve-static@1.10.2 send@0.13.1 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 send@0.13.0 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 connect@3.4.1 finalhandler@0.4.1 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 tiny-lr@0.2.1 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 serve-static@1.10.2 send@0.13.1 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 connect-timeout@1.6.2 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 @sailshq/body-parser@1.13.4 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 compression@1.5.2 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 connect-timeout@1.6.2 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 express-session@1.11.3 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 finalhandler@0.4.0 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 morgan@1.6.1 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-index@1.7.3 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 grunt-contrib-watch@1.0.0 tiny-lr@0.2.1 body-parser@1.14.2 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-parser@2.3.1 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-static@1.10.3 send@0.13.2 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-static@1.10.3 send@0.13.2 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-adapter@0.5.0 socket.io-parser@2.3.1 debug@2.2.0 ms@0.7.1
    Remediation: Open PR to patch ms@0.7.1.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 socket.io-parser@2.3.1 debug@2.2.0 ms@0.7.1
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 @sailshq/express@3.21.3 @sailshq/connect@2.30.3 serve-favicon@2.3.2 ms@0.7.2
    Remediation: Open PR to patch ms@0.7.2.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 debug@2.3.3 ms@0.7.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 skipper@0.7.6 body-parser@1.17.1 debug@2.6.1 ms@0.7.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 engine.io@1.8.3 debug@2.3.3 ms@0.7.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-adapter@0.5.0 debug@2.3.3 ms@0.7.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 debug@2.3.3 ms@0.7.2
    Remediation: Upgrade to sails@1.0.0.
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-sockets@0.13.14 socket.io@1.7.3 socket.io-client@1.7.3 engine.io-client@1.8.3 debug@2.3.3 ms@0.7.2
    Remediation: Upgrade to sails@1.0.0.

Overview

ms is a tiny millisecond conversion utility.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to an incomplete fix for previously reported vulnerability npm:ms:20151024. The fix limited the length of accepted input string to 10,000 characters, and turned to be insufficient making it possible to block the event loop for 0.3 seconds (on a typical laptop) with a specially crafted string passed to ms() function.

Proof of concept

ms = require('ms');
ms('1'.repeat(9998) + 'Q') // Takes about ~0.3s

Note: Snyk's patch for this vulnerability limits input length to 100 characters. This new limit was deemed to be a breaking change by the author. Based on user feedback, we believe the risk of breakage is very low, while the value to your security is much greater, and therefore opted to still capture this change in a patch for earlier versions as well. Whenever patching security issues, we always suggest to run tests on your code to validate that nothing has been broken.

For more information on Regular Expression Denial of Service (ReDoS) attacks, go to our blog.

Disclosure Timeline

  • Feb 9th, 2017 - Reported the issue to package owner.
  • Feb 11th, 2017 - Issue acknowledged by package owner.
  • April 12th, 2017 - Fix PR opened by Snyk Security Team.
  • May 15th, 2017 - Vulnerability published.
  • May 16th, 2017 - Issue fixed and version 2.0.0 released.
  • May 21th, 2017 - Patches released for versions >=0.7.1, <=1.0.0.

Details

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

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

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

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

This regular expression accomplishes the following:

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

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

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

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

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

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

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

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

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

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

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

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

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

Remediation

Upgrade ms to version 2.0.0 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: tar
  • Introduced through: bcrypt@1.0.3

Detailed paths

  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 tar@2.2.2
    Remediation: Upgrade to bcrypt@2.0.0.
  • Introduced through: gladys@3.6.0 bcrypt@1.0.3 node-pre-gyp@0.6.36 tar-pack@3.4.1 tar@2.2.2

Overview

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

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). When stripping the trailing slash from files arguments, the f.replace(/\/+$/, '') performance of this function can exponentially degrade when f contains many / characters resulting in ReDoS.

This vulnerability is not likely to be exploitable as it requires that the untrusted input is being passed into the tar.extract() or tar.list() array of entries to parse/extract, which would be unusual.

Details

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

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

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

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

This regular expression accomplishes the following:

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

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

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

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

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

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

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

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

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

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

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

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

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

Remediation

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

References

low severity

Uninitialized Memory Exposure

  • Vulnerable module: mysql
  • Introduced through: sails-mysql@0.12.2

Detailed paths

  • Introduced through: gladys@3.6.0 sails-mysql@0.12.2 mysql@2.10.2
    Remediation: Upgrade to sails-mysql@1.0.0.

Overview

mysql is a node.js driver for mysql.

Affected versions of the package are vulnerable due to the unsafe use of the Buffer() method. Uninitialized memory may be exposed when a value of type number is provided to various methods in mysql which require allocation of buffers and results in concatenation of uninitialized memory to the buffer collection.

This vulnerability is unlikely to be exploited, but may be possible if a server-side mysql accepts typed input for passwords from the client even though the user doesn’t control the server-side code (i.e through JSON format).

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');

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

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

Remediation

Upgrade mysql to version 2.14.0 or higher. Note This is vulnerable only for Node <=4

References

low severity

Uninitialized Memory Exposure

  • Vulnerable module: utile
  • Introduced through: sails@0.12.14

Detailed paths

  • Introduced through: gladys@3.6.0 sails@0.12.14 prompt@0.2.14 utile@0.2.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 prompt@0.2.14 utile@0.2.1
  • Introduced through: gladys@3.6.0 sails@0.12.14 sails-hook-orm@1.0.9 waterline@0.11.12 prompt@0.2.14 utile@0.2.1

Overview

utile is a drop-in replacement for util with some additional advantageous functions.

Affected versions of this package are vulnerable to Uninitialized Memory Exposure. A malicious user could extract sensitive data from uninitialized memory or to cause a DoS by passing in a large number, in setups where typed user input can be passed.

Note Uninitialized Memory Exposure impacts only Node.js 6.x or lower, Denial of Service impacts any Node.js version.

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

There is no fix version for utile.

References