express@3.0.6

Fast, unopinionated, minimalist web framework.

Known vulnerabilities8
Vulnerable paths11
Dependencies17

Directory Traversal

high severity
  • Vulnerable module: send
  • Introduced through: send@0.1.0 and connect@2.7.2

Detailed paths

  • Introduced through: express@3.0.6 send@0.1.0
  • Introduced through: express@3.0.6 connect@2.7.2 send@0.1.0

Overview

When relying on the root option to restrict file access it may be possible for an application consumer to escape out of the restricted directory and access files in a similarly named directory. For example, static(_dirname + '/public') would allow access to _dirname + '/public-restricted'.

Source: Node Security Project

Remediation

Upgrade to a version greater than or equal to 0.8.4.

References

Prototype Override Protection Bypass

high severity
  • Vulnerable module: qs
  • Introduced through: connect@2.7.2

Detailed paths

  • Introduced through: express@3.0.6 connect@2.7.2 qs@0.5.1

Overview

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

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
            

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.4.0 or higher. Note: The fix was backported to the following versions 6.3.2, 6.2.3, 6.1.2, 6.0.4.

References

Cross-Site Scripting (XSS)

medium severity
  • Vulnerable module: express
  • Introduced through: express@3.0.6

Detailed paths

  • Introduced through: express@3.0.6

Overview

express is a minimalist web framework.

Vulnerable versions of this package do not enforce the user's browser to set a specific charset in the content-type header content-type header while displaying 400 level response messages. This could be used by remote attackers to perform a cross-site scripting attack, by using non-standard encodings like UTF-7.

Recommendations

Update express to 3.11.0 or higher for the 3.x versions or 4.5.0 or higher for the 4.x versions.

References

Denial of Service (Event Loop Blocking)

medium severity
  • Vulnerable module: qs
  • Introduced through: connect@2.7.2

Detailed paths

  • Introduced through: express@3.0.6 connect@2.7.2 qs@0.5.1

Overview

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

Remediation

Update qs to version 1.0.0 or higher. In these versions, qs enforces a max object depth (along with other limits), limiting the event loop length and thus preventing such an attack.

References

https://nodesecurity.io/advisories/28

Denial of Service (Memory Exhaustion)

medium severity
  • Vulnerable module: qs
  • Introduced through: connect@2.7.2

Detailed paths

  • Introduced through: express@3.0.6 connect@2.7.2 qs@0.5.1

Overview

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

Remediation

Upgrade qs to version 1.0.0 or greater. In these versions, qs introduced a low limit on the index value, preventing such an attack

References

Non-Constant Time String Comparison

medium severity
  • Vulnerable module: cookie-signature
  • Introduced through: cookie-signature@0.0.1 and connect@2.7.2

Detailed paths

  • Introduced through: express@3.0.6 cookie-signature@0.0.1
  • Introduced through: express@3.0.6 connect@2.7.2 cookie-signature@0.0.1

Overview

'cookie-signature' is a library for signing cookies.

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

Details

You can read more about timing attacks in Node.js on the Snyk blog: https://snyk.io/blog/node-js-timing-attack-ccc-ctf/

Remediation

Upgrade to 1.0.4 or greater.

References

Root Path Disclosure

medium severity
  • Vulnerable module: send
  • Introduced through: send@0.1.0 and connect@2.7.2

Detailed paths

  • Introduced through: express@3.0.6 send@0.1.0
  • Introduced through: express@3.0.6 connect@2.7.2 send@0.1.0

Overview

Send is a library for streaming files from the file system as an http response. It supports partial responses (Ranges), conditional-GET negotiation, high test coverage, and granular events which may be leveraged to take appropriate actions in your application or framework.

A root path disclosure vulnerability exists in send versions prior to 0.11.1.

Remediation

Upgrade send to version 0.11.1. or greater.

If a direct dependency update is not possible, use snyk wizard to patch this vulnerability.

References

methodOverride Middleware Reflected Cross-Site Scripting

medium severity
  • Vulnerable module: connect
  • Introduced through: connect@2.7.2

Detailed paths

  • Introduced through: express@3.0.6 connect@2.7.2

Overview

Connect is a stack of middleware that is executed in order in each request.

The "methodOverride" middleware allows the http post to override the method of the request with the value of the _method post key or with the header "x-http-method-override".

Because the user post input was not checked, req.method could contain any kind of value. Because the req.method did not match any common method VERB, connect answered with a 404 page containing the "Cannot [method] [url]" content. The method was not properly encoded for output in the browser.

Source: Node Security Project

Details

Example

~ curl "localhost:3000" -d "_method=<script src=http://nodesecurity.io/xss.js></script>"
            Cannot <SCRIPT SRC=HTTP://NODESECURITY.IO/XSS.JS></SCRIPT> /
            

Mitigation factors

Update to the newest version of Connect or disable methodOverride. It is not possible to avoid the vulnerability if you have enabled this middleware in the top of your stack.

History