Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(exec): document security concerns #950

Merged
merged 1 commit into from Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -340,6 +340,11 @@ Not seeing the behavior you want? `exec()` runs everything through `sh`
by default (or `cmd.exe` on Windows), which differs from `bash`. If you
need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option.

**Note:** as `shell.exec()` executes an arbitrary string in the system
shell, it is **critical** to properly sanitize user input to avoid command
execution. For more context, consult the [Security
guidelines](https://github.com/shelljs/shelljs/wiki/Security-guidelines).


### find(path [, path ...])
### find(path_array)
Expand Down
5 changes: 5 additions & 0 deletions src/exec.js
Expand Up @@ -177,6 +177,11 @@ function execAsync(cmd, opts, pipe, callback) {
//@ Not seeing the behavior you want? `exec()` runs everything through `sh`
//@ by default (or `cmd.exe` on Windows), which differs from `bash`. If you
//@ need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option.
//@
//@ **Note:** as `shell.exec()` executes an arbitrary string in the system
//@ shell, it is **critical** to properly sanitize user input to avoid command
//@ execution. For more context, consult the [Security
//@ guidelines](https://github.com/shelljs/shelljs/wiki/Security-guidelines).
function _exec(command, options, callback) {
options = options || {};
if (!command) common.error('must specify command');
Expand Down