js8086@0.0.0

Vulnerabilities

33 via 45 paths

Dependencies

348

Source

npm

Find, fix and prevent vulnerabilities in your code.

Severity
  • 27
  • 4
  • 2
Status
  • 33
  • 0
  • 0

high severity

Prototype Pollution

  • Vulnerable module: ajv
  • Introduced through: electron-builder@15.6.4

Detailed paths

  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 ajv@5.5.2
    Remediation: Upgrade to electron-builder@19.26.1.

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: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@2.0.17.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Arbitrary Code Execution. Opening a BrowserView with sandbox: true or nativeWindowOpen: true and nodeIntegration: false results in a webContents where window.open() can be called and the newly opened child will have nodeIntegration enabled.

Remediation

Upgrade electron to version 2.0.17, 3.0.15, 3.1.3, 4.0.4, 5.0.0-beta.2 or higher.

If for some reason you are unable to upgrade your Electron version, you can mitigate this issue by disabling all child web contents: view.webContents.on('-add-new-contents', e => e.preventDefault());

References

high severity

Arbitrary Code Execution

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@5.0.0.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Arbitrary Code Execution due to Node being enabled in a webview because the default values of nodeIntegration and webviewTag were set to true when they where undefined by a user. The fix allows users to prevent Node and webview being enabled, when undefined, by setting the default values of nodeIntegration and webviewTag to false.

Remediation

Upgrade electron to version 5.0.0-beta.1 or higher.

References

high severity

Heap Overflow

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Heap Overflow. A Heap buffer overflow exists in the media component of Google Chrome, which also affects chromium.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.1 or higher.

References

high severity

Heap-based Buffer Overflow

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@8.5.3.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Heap-based Buffer Overflow in Freetype.

Remediation

Upgrade electron to version 8.5.3, 9.3.3, 10.1.5 or higher.

References

high severity

Improper Access Control

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Improper Access Control. It has an inappropriate implementation in V8.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.1 or higher.

References

high severity

new

Improper Validation

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@10.1.6.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Improper Validation. The value of a node was accessed without prior HasValue check. With WebAssembly this node is not guaranteed to be a value.

Remediation

Upgrade electron to version 10.1.6 or higher.

References

high severity

Out-of-bounds Read

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Out-of-bounds Read. The input to sctp_load_addresses_from_init is verified by calling sctp_arethere_unrecognized_parameters, however there is a difference in how these functions handle parameter bounds. The function sctp_arethere_unrecognized_parameters does not process a parameter that is partially outside of the limit of the chunk, meanwhile, sctp_load_addresses_from_init will continue processing until a parameter that is entirely outside of the chunk occurs.

This means that the last parameter of a chunk is not always verified, which can lead to parameters with very short plen values being processed by sctp_load_addresses_from_init. This can lead to out-of-bounds reads whenever the plen is subtracted from the header len.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.0 or higher.

References

high severity

Privilege Escalation

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@7.2.4.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Privilege Escalation. This is a context isolation bypass, meaning that code running in the main world context in the renderer can reach into the isolated Electron context and perform privileged actions.

##Note: Only apps using contextIsolation are affected.

Remediation

Upgrade electron to version 7.2.4, 8.2.4 or higher.

References

high severity

Privilege Escalation

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@7.2.4.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Privilege Escalation. This is a context isolation bypass, meaning that code running in the main world context in the renderer can reach into the isolated Electron context and perform privileged actions.

##Note: Only apps using both contextIsolation and contextBridge are affected.

Remediation

Upgrade electron to version 7.2.4, 8.2.4 or higher.

References

high severity

Privilege Escalation

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.11.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Privilege Escalation. This is a context isolation bypass, meaning that code running in the main world context in the renderer can reach into the isolated Electron context and perform privileged actions.

##Note: Only apps using contextIsolation are affected.

Remediation

Upgrade electron to version 6.1.11, 7.2.4, 8.2.4 or higher.

References

high severity

Site Isolation Bypass

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@7.2.2.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Site Isolation Bypass. parent_execution_origin_ is provided from parent's RenderFrameHostImpl::last_committed_origin_ that is set during navigation commit. Worker creation IPC from the renderer to browser could race with navigation commit, and could see the wrong last committed origin.

Remediation

Upgrade electron to version 7.2.2, 8.2.1 or higher.

References

high severity

Type Confusion

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@7.3.1.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Type Confusion in V8.

Remediation

Upgrade electron to version 7.3.1 or higher.

References

high severity

new

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@8.5.4.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free via the site isolation.

Remediation

Upgrade electron to version 8.5.4, 9.3.5, 10.1.6 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@2.0.18.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free via the Chromium FileReader.

Note: This vulnerability affects all software based on Chromium, including Electron.

Remediation

Upgrade electron to version 2.0.18, 3.0.16, 3.1.6, 4.0.8 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free. Multiple user after free vulnerabilities exists in the WebAudio component of chromium.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.1 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free. It allowed a remote attacker to potentially exploit heap corruption via a crafted HTML page.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.1 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free via the audio component. It allowed a remote attacker to potentially exploit heap corruption via a crafted HTML page.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.1 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@7.2.2.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free via the audio component.

Remediation

Upgrade electron to version 8.2.1, 7.2.2 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free. FileChooserImpl can outlive ListenerProxy leading to a crash.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.0 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free. Initialize() could potentially run twice in MojoVideoEncodeAcceleratorService.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.1 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free. It allows a remote attacker to potentially exploit heap corruption via a crafted HTML page.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.0 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free. An AudioContext is considered to have activity if it's not closed. Previously, suspended contexts were considered has having no activity, but that's not quite true since the context can be resumed at any time after. This would allow contexts to be collected prematurely even though the context was resumed. This causes the audio thread to access objects that are possibly deleted.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.0.0-beta.6 or higher.

References

high severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@8.3.1.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free in WebRTC.

Remediation

Upgrade electron to version 8.3.1 or higher.

References

high severity

Prototype Pollution

  • Vulnerable module: node-forge
  • Introduced through: electron-builder@15.6.4

Detailed paths

  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 node-forge@0.7.6
    Remediation: Upgrade to electron-builder@19.7.0.

Overview

node-forge is a JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.

Affected versions of this package are vulnerable to Prototype Pollution via the util.setPath function.

Note: version 0.10.0 is a breaking change removing the vulnerable functions.

POC:

const nodeforge = require('node-forge');
var obj = {};
nodeforge.util.setPath(obj, ['__proto__', 'polluted'], true);
console.log(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 node-forge to version 0.10.0 or higher.

References

high severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: plist
  • Introduced through: electron-builder@15.6.4 and electron-packager@8.7.2

Detailed paths

  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 plist@2.1.0
    Remediation: Upgrade to electron-builder@19.46.0.
  • Introduced through: js8086@0.0.0 electron-packager@8.7.2 plist@2.1.0
    Remediation: Upgrade to electron-packager@13.0.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-macos-sign@1.6.0 plist@2.1.0

Overview

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

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

Disclosure Timeline

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

Details

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

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

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

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

This regular expression accomplishes the following:

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

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

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

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

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

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

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

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

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

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

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

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

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

Remediation

Upgrade plist to version 3.0.1 or higher.

References

high severity

new

Prototype Pollution

  • Vulnerable module: y18n
  • Introduced through: electron-builder@15.6.4

Detailed paths

  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 yargs@7.1.1 y18n@3.2.1
    Remediation: Upgrade to electron-builder@20.16.4.

Overview

y18n is a the bare-bones internationalization library used by yargs

Affected versions of this package are vulnerable to Prototype Pollution. PoC by po6ix:

const y18n = require('y18n')();

y18n.setLocale('__proto__');
y18n.updateLocale({polluted: true});

console.log(polluted); // 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 y18n to version 4.0.1, 5.0.5 or higher.

References

medium severity

Arbitrary File Read

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@7.2.4.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Arbitrary File Read. It allows arbitrary local file read by defining unsafe window options on a child window opened via window.open.

Remediation

Upgrade electron to version 7.2.4, 8.2.4 or higher.

References

medium severity

Buffer Underflow

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Buffer Underflow. Since there may be multiple instance of DWriteFontProxyImpl instantiated for multiple RenderProcessHosts, and DWriteFontProxyImpl::GetUniqueNameLookupTable may access DWriteFontLookupTableBuilder::QueueShareMemoryRegionWhenReady from separate threads, there may be race conditions around the pending_callbacks_ member of DWriteFontLookupTableBuilder.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.0 or higher.

References

medium severity

Use After Free

  • Vulnerable module: electron
  • Introduced through: electron@1.8.8

Detailed paths

  • Introduced through: js8086@0.0.0 electron@1.8.8
    Remediation: Upgrade to electron@6.1.10.

Overview

electron is a framework which lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

Affected versions of this package are vulnerable to Use After Free. The rendering_orphan_handlers_ and deletable_orphan_handlers_ handlers can hold references to the context after BaseAudioContext is destroyed.

Remediation

Upgrade electron to version 6.1.10, 7.2.2, 8.2.1 or higher.

References

medium severity

Arbitrary File Read

  • Vulnerable module: macaddress
  • Introduced through: electron-builder@15.6.4

Detailed paths

  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 uuid-1345@0.99.7 macaddress@0.2.9
    Remediation: Upgrade to electron-builder@19.28.0.

Overview

macaddress is a library that gets the MAC addresses (hardware addresses) of the hosts network interfaces.

Affected versions of this package are vulnerable to Arbitrary File Read. By prepending ../../.. to the "interface" name, this line of code can be asked read a file from anywhere on the filesystem as long as that file is named address.

Note: This is relevant only for Linux OS implementation.

Details

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.

st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.

If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.

curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa

Note %2e is the URL encoded version of . (dot).

  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.

The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:

2018-04-15 22:04:29 .....           19           19  good.txt
2018-04-15 22:04:42 .....           20           20  ../../../../../../root/.ssh/authorized_keys

Remediation

Upgrade macaddress to version 0.4.3 or higher.

References

low severity

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: debug
  • Introduced through: electron-builder@15.6.4

Detailed paths

  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-builder-http@15.6.3 debug@2.6.3
    Remediation: Upgrade to electron-builder@19.7.2.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-builder-util@15.6.3 debug@2.6.3
    Remediation: Upgrade to electron-builder@19.7.2.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-builder-util@15.6.3 electron-builder-http@15.6.3 debug@2.6.3
    Remediation: Upgrade to electron-builder@19.7.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-publish@15.6.3 electron-builder-http@15.6.3 debug@2.6.3
    Remediation: Upgrade to electron-builder@19.7.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-publish@15.6.3 electron-builder-util@15.6.3 debug@2.6.3
    Remediation: Upgrade to electron-builder@19.7.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-publish@15.6.3 electron-builder-util@15.6.3 electron-builder-http@15.6.3 debug@2.6.3
    Remediation: Upgrade to electron-builder@19.7.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: ms
  • Introduced through: electron-builder@15.6.4

Detailed paths

  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-builder-http@15.6.3 debug@2.6.3 ms@0.7.2
    Remediation: Upgrade to electron-builder@17.9.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-builder-util@15.6.3 debug@2.6.3 ms@0.7.2
    Remediation: Upgrade to electron-builder@17.9.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-builder-util@15.6.3 electron-builder-http@15.6.3 debug@2.6.3 ms@0.7.2
    Remediation: Upgrade to electron-builder@17.9.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-publish@15.6.3 electron-builder-http@15.6.3 debug@2.6.3 ms@0.7.2
    Remediation: Upgrade to electron-builder@17.9.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-publish@15.6.3 electron-builder-util@15.6.3 debug@2.6.3 ms@0.7.2
    Remediation: Upgrade to electron-builder@17.9.0.
  • Introduced through: js8086@0.0.0 electron-builder@15.6.4 electron-publish@15.6.3 electron-builder-util@15.6.3 electron-builder-http@15.6.3 debug@2.6.3 ms@0.7.2
    Remediation: Upgrade to electron-builder@17.9.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