Skip to content

Commit

Permalink
docs(exec): document security concerns (#950)
Browse files Browse the repository at this point in the history
No change to logic.

This adds documentation about `shell.exec()`'s inherent vulnerability to
command injection and links to a more detailed security notice.

Issue #103, #143, #495, #765, #766, #810, #842, #938, #945
  • Loading branch information
nfischer committed Jun 26, 2019
1 parent 619d234 commit 68c3822
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit 68c3822

Please sign in to comment.