{"id":"CVE-2025-30222","aliases":["CVE-2025-30222","GHSA-66pp-5p9w-q87j"],"related":[],"kind":"vulnerability","state":"published","title":"Shescape has potential environment variable exposure on Windows with CMD","summary":"Shescape is a simple shell escape library for JavaScript. Versions 1.7.2 through 2.1.1 are vulnerable to potential environment variable exposure on Windows with CMD. This impact users of Shescape on Windows that explicitly configure `shell: 'cmd.exe'` or `shell: true` using any of `quote`/`quoteAll`/`escape`/`escapeAll`. An attacker may be able to get read-only access to environment variables. This bug has been patched in v2.1.2. For those who are already using v2 of Shescape, no further changes are required. Those who are are using v1 of Shescape should follow the migration guide to upgrade to v2. There is no plan to release a patch compatible with v1 of Shescape. As a workaround, users can remove all instances of `%` from user input before using Shescape.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Shescape is a simple shell escape library for JavaScript. Versions 1.7.2 through 2.1.1 are vulnerable to potential environment variable exposure on Windows with CMD. This impact users of Shescape on Windows that explicitly configure `shell: 'cmd.exe'` or `shell: true` using any of `quote`/`quoteAll`/`escape`/`escapeAll`. An attacker may be able to get read-only access to environment variables. This bug has been patched in v2.1.2. For those who are already using v2 of Shescape, no further changes are required. Those who are are using v1 of Shescape should follow the migration guide to upgrade to v2. There is no plan to release a patch compatible with v1 of Shescape. As a workaround, users can remove all instances of `%` from user input before using Shescape.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nThis impact users of Shescape on Windows that explicitly configure `shell: 'cmd.exe'` or `shell: true` using any of `quote`/`quoteAll`/`escape`/`escapeAll`.\n\nAn attacker may be able to get read-only access to environment variables. Example:\n\n```javascript\nimport * as cp from \"node:child_process\";\nimport { Shescape } from \"shescape\";\n\n// 1. Prerequisites\nconst shescape = new Shescape({\n    shell: \"cmd.exe\",\n    // Or\n    shell: true, // Only if the default shell is CMD\n});\n\n// 2. Payload\nconst payload = '\"%PATH%';\n\n// 3. Usage\nlet escapedPayload;\n\nescapedPayload = shescape.quote(payload);\n// Or\nescapedPayload = shescape.quoteAll([payload]);\n// Or\nescapedPayload = shescape.escape(payload);\n// Or\nescapedPayload = shescape.escapeAll([payload]);\n\n// And (example)\nconst result = cp.execSync(`echo Hello ${escapedPayload}`, options);\n\n// 4. Impact\nconsole.log(result.toString());\n// Outputs \"Hello\" followed by the contents of the PATH environment variable\n```\n\nFor Shescape prior to v2.0.0, the `options` object must have `shell: 'cmd.exe'` or `shell: undefined` and `interpolation: true`.\n\n\n### Patches\n\nThis bug has been patched in [v2.1.2](https://github.com/ericcornelissen/shescape/releases/tag/v2.1.2) which you can upgrade to now.\n\nIf you are already using v2 of Shescape, no further changes are required. If you are using v1 of Shescape, follow the [migration guide](https://github.com/ericcornelissen/shescape/blob/155b13b4141750203ce71249f1b0fdc638c7a0d0/docs/migration.md) to upgrade to v2. There is no plan to release a patch compatible with v1 of Shescape.\n\n\n### Workarounds\n\nAlternatively, users can remove all instances of % from user input before using Shescape.\n\n\n### References\n\n- Shescape Pull Request [#1916](https://github.com/ericcornelissen/shescape/pull/1916)\n- Shescape commit [0a81f1e](https://github.com/ericcornelissen/shescape/commit/0a81f1eb077bab8caae283a2490cd7be9af179c6)\n- Shescape release [v2.1.2](https://github.com/ericcornelissen/shescape/releases/tag/v2.1.2)\n\n\n### For more information\n\n- Comment on Pull Request [#1916](https://github.com/ericcornelissen/shescape/pull/1916)\n- Comment on commit [0a81f1e](https://github.com/ericcornelissen/shescape/commit/0a81f1eb077bab8caae283a2490cd7be9af179c6)\n- Open an issue at [https://github.com/ericcornelissen/shescape/issues](https://github.com/ericcornelissen/shescape/issues) (New issue > Question)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Shescape es una librería de escape de shell sencilla para JavaScript. Las versiones 1.7.2 a 2.1.1 son vulnerables a la posible exposición de variables de entorno en Windows con CMD. Esto afecta a los usuarios de Shescape en Windows que configuran explícitamente `shell: 'cmd.exe'` o `shell: true` mediante `quote`/`quoteAll`/`escape`/`escapeAll`. Un atacante podría obtener acceso de solo lectura a las variables de entorno. Este error se ha corregido en la versión 2.1.2. Quienes ya utilizan la versión 2 de Shescape no requieren cambios adicionales. Quienes utilizan la versión 1 de Shescape deben seguir la guía de migración para actualizar a la versión 2. No se prevé publicar un parche compatible con la versión 1 de Shescape. Como workaround, los usuarios pueden eliminar todas las instancias de `%` de la entrada de usuario antes de usar Shescape.","source":"nvd"}],"published":"2025-03-25T23:00:08.995Z","modified":"2026-09-10T03:50:22.897Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:U","score":2.1,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:U","score":2.1,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:U","rating":"LOW"}],"cwes":["CWE-200"],"affected":[{"ranges":[{"version":">= 1.7.2, < 2.1.2","status":"affected"}],"vendor":"ericcornelissen","product":"shescape","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"1.7.2","status":"affected","fixed":"2.1.2"}],"ecosystem":"npm","package":"shescape","purl":"pkg:npm/shescape","source":"ghsa"}],"references":[{"url":"https://github.com/ericcornelissen/shescape/security/advisories/GHSA-66pp-5p9w-q87j","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ericcornelissen/shescape/pull/1916","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ericcornelissen/shescape/commit/0a81f1eb077bab8caae283a2490cd7be9af179c6","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ericcornelissen/shescape/releases/tag/v2.1.2","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-30222","tags":["advisory"],"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-03-26T13:30:30.955Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-30222","url":"https://www.cve.org/CVERecord?id=CVE-2025-30222","licence":"CVE Terms of Use","modified":"2025-03-26T13:30:34.363Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-66pp-5p9w-q87j","url":"https://github.com/advisories/GHSA-66pp-5p9w-q87j","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:22.897Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-30222","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-30222","licence":"Public domain","modified":"2026-06-17T09:08:23.090Z"}],"updatedAt":"2026-11-25T22:58:55.513Z","epss":{"score":0.00297,"percentile":0.24038,"date":"2026-12-01T12:00:22.000Z"}}