CVE-2022-24725: Shescape Exposure Of Home Directory Through Vulnerability
MODERATECVE-2022-24725 is a MODERATE (CVSS 5.5) exposure of home directory through vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Shescape libraries in the npm ecosystem. The issue involves exposure of home directory through shescape on unix with bash. Remediation is available by upgrading affected packages to version 1.5.1.
CVE-2022-24725 at a Glance
Security Impact
CVSS: 5.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2022-24725
To remediate this vulnerability, upgrade all affected Shescape dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install shescape@1.5.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls shescape
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-24725, inspect your project dependencies using npm:
npm ls shescape
Analyze the terminal output to locate any version of Shescape in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.1), your application is affected.
Note: The npm ls shescape command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Shescape, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-24725 Affected Shescape Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
shescape
|
npm |
≥ 1.4.0
< 1.5.1
|
1.5.1
|
References
Frequently Asked Questions
What is CVE-2022-24725?
Which Shescape versions are affected?
What version fixes CVE-2022-24725?
Is shescape affected?
What is the CVSS score of CVE-2022-24725?
What CWE is associated with CVE-2022-24725?
How can I check npm dependencies for CVE-2022-24725?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-446w-rrm4-r47f",
"modified" : "2022-03-18T20:06:07Z",
"published" : "2022-03-03T19:26:11Z",
"aliases" : [ "CVE-2022-24725" ],
"summary" : "Exposure of home directory through shescape on Unix with Bash",
"details" : "### Impact\n\nThe issue allows for exposure of the home directory on Unix systems when using Bash with the `escape` or `escapeAll` functions from the _shescape_ API with the `interpolation` option set to `true`. Other tested shells, Dash and Zsh, are not affected.\n\n```javascript\nconst cp = require(\"child_process\");\nconst shescape = require(\"shescape\");\n\nconst payload = \"home_directory=~\";\nconst options = { interpolation: true };\nconsole.log(cp.execSync(`echo ${shescape.escape(payload, options)}`));\n// home_directory=/home/user\n```\n\nDepending on how the output of _shescape_ is used, directory traversal may be possible in the application using _shescape_.\n\n### Patches\n\nThe issue was patched in `v1.5.1`.\n\n### Workarounds\n\nManually escape all instances of the tilde character (`~`) using `arg.replace(/~/g, \"\\\\~\")`.\n\n### References\n\nSee GitHub issue https://github.com/ericcornelissen/shescape/issues/169.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "shescape"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.4.0"
}, {
"fixed" : "1.5.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/ericcornelissen/shescape/security/advisories/GHSA-446w-rrm4-r47f"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24725"
}, {
"type" : "WEB",
"url" : "https://github.com/ericcornelissen/shescape/issues/169"
}, {
"type" : "WEB",
"url" : "https://github.com/ericcornelissen/shescape/pull/170"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/ericcornelissen/shescape"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-200", "CWE-78" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-03-03T19:26:11Z",
"nvd_published_at" : "2022-03-03T22:15:00Z"
}
}