Packages / shell-quote / Security

CriticalVulnerabilityGHSA-qg8p-v9q4-gh34CVE-2016-10541Published 18 Feb 2019

Potential Command Injection in shell-quote

Your version

Affected releases · shell-quote

  • 1.x1.0.0 – 1.6.0Fixed in 1.6.1
  • 0.1.x and older0.0.0 – 0.1.1No fix, no longer updated

On 1.x, the newest line:

npm install shell-quote@1.6.1
Every release on a timeline
1.x
  1. Affected

    1.0.0 – 1.6.0

    13 releases

  2. Fixed

    1.6.1 – 1.12.0

    17 releases, latest

0.x
  1. Affected

    0.0.0 – 0.1.1

    4 releases

34 stable releases of shell-quote, oldest to newest, one row per major.

What happens

Affected versions of shell-quote do not properly escape command line arguments, which may result in command injection if the library is used to escape user input destined for use as command line arguments.

Proof of Concept:

The following characters are not escaped properly: >,;,{,}

Bash has a neat but not well known feature known as "Bash Brace Expansion", wherein a sub-command can be executed without spaces by running it between a set of {} and using the , instead of to seperate arguments. Because of this, full command injection is possible even though it was initially thought to be impossible.

   const quote = require('shell-quote').quote;
   console.log(quote(['a;{echo,test,123,234}']));
   // Actual                    "a;{echo,test,123,234}"
   // Expected                  "a\;\{echo,test,123,234\}"
   // Functional Equivalent     "a; echo 'test' '123' '1234'"

Recommendation

Update to version 1.6.1 or later.