Security issue: shelljs
See original GitHub issueBug and Security
Problem
Our goal is not to prevent malicious attacks but prevent user problems from normal folder naming. Please make sure the user can have spaces and $ in folder names.
There are different shells that use different escape symbols. I would like to support Windows Terminal, Powershell and (git) bash.
Notes
Escape symbols
- *nix uses \
- Windows Terminal uses ^
This almost works for *nix but not for Windows paths because the escape symbols are different:
let escapedDirname = __dirname.replace(/(["$])/g, "\\$1");
console.log(__dirname);
console.log(escapedDirname);
let cmd = `npm run --prefix "${escapedDirname}" start`;
console.log(cmd);
require("shelljs").exec(cmd);```
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
shelljs vulnerabilities
version published direct vulnerabilities
0.8.5 6 Jan, 2022 0. C. 0. H. 0. M. 0. L
0.8.4 24 Apr, 2020 0. C. 1. H. 0....
Read more >0.8.3 high severity vuln · Issue #945 · shelljs ...
Description of the bug: Received warnings on PM2 that shelljs got tagged for a security vulnerability. WS-2017-3737 More information moderate ...
Read more >CVE-2022-0144
This flaw allows an attacker to craft stdout files, which leads to crashing the ShellJS scripts running with privileges. A flaw was found...
Read more >Shelljs Project Shelljs : List of security vulnerabilities
Security vulnerabilities of Shelljs Project Shelljs : List of all related CVE security vulnerabilities. CVSS Scores, vulnerability details and links to full ...
Read more >shelljs-exec-proxy
Start using shelljs-exec-proxy in your project by running `npm i ... shell.git.commit('-am', 'Fixed issue #1'); shell.git.push('origin', 'master'); ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi, ShellJS maintainer here. Chiming in with a couple thoughts.
We’re not going to sanitize your input for this API. This is an explicit requirement for using
shell.exec(). We have recommendations to help you accomplish this.I recommend you err on the side of caution. What if someone installs your project into a folder named
/path/to/malicious folder name; rm -rf*/subdir/(all of which are legal unix filename characters)? Even if you think this is a non-issue because the attacker already has control over the system, the power tomkdirshouldn’t be the power to execute arbitrary code. At the very least, you have a bug if you’re installed in a folder with a space in the name, which is a totally reasonable folder name.We just updated the description and changed the goal.