Skip to content

Conversation

@odaysec
Copy link

@odaysec odaysec commented Oct 23, 2025

const { exec } = require('child_process');
const util = require('util');
const path = require('path');
const execAsync = util.promisify(exec);

console.log('[customSign] Docker command:', dockerCommand);
console.log('[customSign] Starting to run sign cmd via docker...');
const { stdout, stderr } = await execAsync(dockerCommand);
console.log('[customSign] Docker command output:', stdout);
if (stderr) {
console.error('[customSign] Docker command error output:', stderr);
}

fix this problem, remove string-based shell interpolation with exec, and switch to child_process.spawn (or execFile) with argument arrays. Specifically, the docker command line must be split into command and arguments and each dynamic value provided as a separate array element, avoiding unintended shell interpretation.

Steps:

  • Replace execAsync(dockerCommand) with a call to spawn or execFile (preferably promisified).
  • Split the constructed docker command into a command (docker) and an array of arguments (including run, --rm, -v, etc.).
  • Pass dynamic values (directoryPath, environment vars, etc.) as array arguments, not within interpolated strings.
  • Properly handle stdout/stderr as before.
  • Add necessary import (promisify), and update function to await the spawned process.

@CLAassistant
Copy link

CLAassistant commented Oct 23, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@jackkav jackkav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool contribution thanks, this code is only run by electron-builder during the packaging process, I don't see an exploit vector, but it looks like it adheres to better secure coding practices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants