Skip to content

fix(tools): use execFile instead of exec to avoid shell injection#5197

Draft
marcoscaceres wants to merge 4 commits intomainfrom
alert-autofix-47
Draft

fix(tools): use execFile instead of exec to avoid shell injection#5197
marcoscaceres wants to merge 4 commits intomainfrom
alert-autofix-47

Conversation

@marcoscaceres
Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/speced/respec/security/code-scanning/47

Use child_process.execFile() (or spawn) with an explicit executable and argument array, instead of exec() with a single interpolated shell command string.

Best minimal fix in this file:

  1. Replace exec import with execFile.
  2. Refactor commandRunner(program) so it tokenizes the static program once (e.g., "java -jar <path>"), then combines those tokens with parsed cmd tokens, and calls a new toExecFilePromise(file, args, options).
  3. Replace toExecPromise(cmd, ...) with toExecFilePromise(file, args, ...) that calls execFile(file, args, ...).
  4. Keep behavior (logging, timeout, output piping) equivalent.

This removes shell interpretation while preserving current functionality in tools/release.cjs.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…m environment values

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@marcoscaceres
Copy link
Copy Markdown
Contributor Author

@copilot see the CI error about the commit message. Can you fix that please?

Copilot AI and others added 2 commits April 14, 2026 03:03
Agent-Logs-Url: https://github.com/speced/respec/sessions/cf64d910-0bb6-4b8e-8a7b-e6ebd7300833

Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented Apr 14, 2026

@copilot see the CI error about the commit message. Can you fix that please?

Fixed in commits 593763c and c81e958.

Two issues were addressed:

  1. The commits now use conventional commit format (fix(tools): ...)
  2. The splitArgs function had a Prettier formatting violation that was causing the lint CI to fail — fixed that too

Note: the PR title still shows the original non-conventional text. Since I can't update the PR title directly, you may need to edit it manually to something like fix(tools): use execFile instead of exec to avoid shell injection so the "Check PR title" CI check passes.

@marcoscaceres marcoscaceres changed the title Potential fix for code scanning alert no. 47: Shell command built from environment values fix: code scanning alert no. 47: Shell command built from environment values Apr 14, 2026
@marcoscaceres marcoscaceres changed the title fix: code scanning alert no. 47: Shell command built from environment values fix(tools): use execFile instead of exec to avoid shell injection Apr 14, 2026
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.

2 participants