{"id":"CVE-2022-31179","aliases":["CVE-2022-31179","GHSA-jjc5-fp7p-6f8w"],"related":[],"kind":"vulnerability","state":"published","title":"Insufficient escaping of line feeds for CMD in shescape","summary":"Shescape is a simple shell escape package for JavaScript. Versions prior to 1.5.8 were found to be subject to code injection on windows. This impacts users that use Shescape (any API function) to escape arguments for cmd.exe on Windows An attacker can omit all arguments following their input by including a line feed character (`'\\n'`) in the payload. This bug has been patched in [v1.5.8] which you can upgrade to now. No further changes are required. Alternatively, line feed characters (`'\\n'`) can be stripped out manually or the user input can be made the last argument (this only limits the impact).","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Shescape is a simple shell escape package for JavaScript. Versions prior to 1.5.8 were found to be subject to code injection on windows. This impacts users that use Shescape (any API function) to escape arguments for cmd.exe on Windows An attacker can omit all arguments following their input by including a line feed character (`'\\n'`) in the payload. This bug has been patched in [v1.5.8] which you can upgrade to now. No further changes are required. Alternatively, line feed characters (`'\\n'`) can be stripped out manually or the user input can be made the last argument (this only limits the impact).","source":"cvelist"},{"lang":"en","text":"### Impact\n\nThis impacts users that use Shescape (any API function) to escape arguments for **cmd.exe** on **Windows**. An attacker can omit all arguments following their input by including a line feed character (`'\\n'`) in the payload. Example:\n\n```javascript\nimport cp from \"node:child_process\";\nimport * as shescape from \"shescape\";\n\n// 1. Prerequisites\nconst options = {\n  shell: \"cmd.exe\",\n};\n\n// 2. Attack\nconst payload = \"attacker\\n\";\n\n// 3. Usage\nlet escapedPayload;\nescapedPayload = shescape.escape(payload, options);\n// Or\nescapedPayload = shescape.escapeAll([payload], options)[0];\n// Or\nescapedPayload = shescape.quote(payload, options);\n// Or\nescapedPayload = shescape.quoteAll([payload], options)[0];\n\ncp.execSync(`echo Hello ${escapedPayload}! How are you doing?`, options);\n// Outputs:  \"Hello attacker\"\n```\n\n> **Note**: `execSync` is just illustrative here, all of `exec`, `execFile`, `execFileSync`, `fork`, `spawn`, and `spawnSync` can be attacked using a line feed character if CMD is the shell being used.\n\n### Patches\n\nThis bug has been patched in [v1.5.8] which you can upgrade to now. No further changes are required.\n\n### Workarounds\n\nAlternatively, line feed characters (`'\\n'`) can be stripped out manually or the user input can be made the last argument (this only limits the impact).\n\n### References\n\n- https://github.com/ericcornelissen/shescape/pull/332\n- https://github.com/ericcornelissen/shescape/releases/tag/v1.5.8\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n- Comment on https://github.com/ericcornelissen/shescape/pull/332\n- Open an issue at https://github.com/ericcornelissen/shescape/issues (_New issue_ > _Question_ > _Get started_)\n\n[v1.5.8]: https://github.com/ericcornelissen/shescape/releases/tag/v1.5.8","format":"markdown","source":"ghsa"},{"lang":"es","text":"Shescape es un sencillo paquete de escape de shell para JavaScript. Las versiones anteriores a 1.5.8, fueron encontradas sujetas a inyección de código en Windows. Esto afecta a usuarios que usan Shescape (cualquier función de la API) para escapar de los argumentos de cmd.exe en Windows Un atacante puede omitir todos los argumentos que siguen a su entrada mediante la inclusión de un carácter de avance de línea (\"\"\\n\"\") en la carga útil. Este error ha sido parcheado en la [v1.5.8], a la que puede actualizar ahora. No es necesario realizar más cambios. Alternativamente, los caracteres de avance de línea (\"\"\\n\"\") pueden ser eliminados manualmente o la entrada del usuario puede convertirse en el último argumento (esto sólo limita el impacto)","source":"nvd"}],"published":"2022-07-15T21:39:14.000Z","modified":"2026-06-17T04:44:58.233Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:H","score":8.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:H","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:H","score":8.1,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-74"],"affected":[{"ranges":[{"version":"< 1.5.8","status":"affected"}],"vendor":"ericcornelissen","product":"shescape","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.5.8"}],"ecosystem":"npm","package":"shescape","purl":"pkg:npm/shescape","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.5.8"}],"vendor":"shescape_project","product":"shescape","cpe":"cpe:2.3:a:shescape_project:shescape:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/ericcornelissen/shescape/releases/tag/v1.5.8","tags":["release-notes","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ericcornelissen/shescape/security/advisories/GHSA-jjc5-fp7p-6f8w","tags":["exploit","patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ericcornelissen/shescape/pull/332","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-31179","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/ericcornelissen/shescape/commit/aceea7358f7222984e21260381ebc5ec4543b76f","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/ericcornelissen/shescape","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-04-22T15:45:15.980Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-31179","url":"https://www.cve.org/CVERecord?id=CVE-2022-31179","licence":"CVE Terms of Use","modified":"2025-04-22T17:46:08.799Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-jjc5-fp7p-6f8w","url":"https://github.com/advisories/GHSA-jjc5-fp7p-6f8w","licence":"CC-BY-4.0","modified":"2023-11-08T04:09:28.955Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-31179","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-31179","licence":"Public domain","modified":"2026-06-17T04:44:58.233Z"}],"updatedAt":"2026-11-25T22:58:13.343Z","epss":{"score":0.01424,"percentile":0.73682,"date":"2026-12-01T12:00:22.000Z"}}