GHSA-f2rp-38vg-j3gh

Suggest an improvement
Source
https://github.com/advisories/GHSA-f2rp-38vg-j3gh
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/03/GHSA-f2rp-38vg-j3gh/GHSA-f2rp-38vg-j3gh.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-f2rp-38vg-j3gh
Aliases
Related
Published
2021-03-18T23:47:56Z
Modified
2023-11-08T04:04:43.975119Z
Severity
  • 6.3 (Medium) CVSS_V3 - CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N CVSS Calculator
Summary
Null characters not escaped
Details

Impact

Anyone using Shescape to defend against shell injection may still be vulnerable against shell injection if the attacker manages to insert a null character into the payload. For example (on Windows):

const cp = require("child_process");
const shescape = require("shescape");

const nullChar = String.fromCharCode(0);
const payload = "foo\" && ls -al ${nullChar} && echo \"bar";
console.log(cp.execSync(`echo ${shescape.quote(payload)}`));
// foototal 3
// drwxr-xr-x 1 owner XXXXXX      0 Mar 13 18:44 .
// drwxr-xr-x 1 owner XXXXXX      0 Mar 13 00:09 ..
// drwxr-xr-x 1 owner XXXXXX      0 Mar 13 18:42 folder                                                                 
// -rw-r--r-- 1 owner XXXXXX      0 Mar 13 18:42 file

Patches

The problem has been patched in v1.1.3 which you can upgrade to now. No further changes are required.

Workarounds

Alternatively, null characters can be stripped out manually using e.g. arg.replace(/\u{0}/gu, "")

Database specific
{
    "nvd_published_at": "2021-03-19T00:15:00Z",
    "github_reviewed_at": "2021-03-18T23:43:39Z",
    "severity": "HIGH",
    "github_reviewed": true,
    "cwe_ids": [
        "CWE-88"
    ]
}
References

Affected packages

npm / shescape

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
1.1.3