VDB
Sign up
MEDIUM5.5

GHSA-446w-rrm4-r47f

Exposure of home directory through shescape on Unix with Bash

Quick fix

GHSA-446w-rrm4-r47f — shescape: upgrade to the fixed version with the command below.

npm install shescape@1.5.1

Details

### Impact

The issue allows for exposure of the home directory on Unix systems when using Bash with the `escape` or `escapeAll` functions from the _shescape_ API with the `interpolation` option set to `true`. Other tested shells, Dash and Zsh, are not affected.

```javascript const cp = require("child_process"); const shescape = require("shescape");

const payload = "home_directory=~"; const options = { interpolation: true }; console.log(cp.execSync(`echo ${shescape.escape(payload, options)}`)); // home_directory=/home/user ```

Depending on how the output of _shescape_ is used, directory traversal may be possible in the application using _shescape_.

### Patches

The issue was patched in `v1.5.1`.

### Workarounds

Manually escape all instances of the tilde character (`~`) using `arg.replace(/~/g, "\\~")`.

### References

See GitHub issue https://github.com/ericcornelissen/shescape/issues/169.

Are you affected?

Enter the version of the package you're using.

Affected packages

npm/shescape
Introduced in: 1.4.0Fixed in: 1.5.1
Fixnpm install shescape@1.5.1

References