Skip to content

Prevent command injection in CLI docs build script#2536

Open
fnando wants to merge 2 commits into
mainfrom
exec-file-sync
Open

Prevent command injection in CLI docs build script#2536
fnando wants to merge 2 commits into
mainfrom
exec-file-sync

Conversation

@fnando

@fnando fnando commented Jun 25, 2026

Copy link
Copy Markdown
Member

What

Replaces every execSync shell-string call in scripts/stellar_cli.mjs with execFileSync using argument arrays, and moves the latest-tag filtering out of a shell pipe (git tag | grep | tail) into JavaScript.

Why

The previous code interpolated the cliRef value (sourced from the --cli-ref flag / stellar-cli-ref workflow input) directly into a shell string passed to execSync, a command-injection anti-pattern. Passing arguments as an array treats them as data, not shell instructions, so a ref value can no longer break out of the intended git command. This is defense-in-depth hardening — the input is not externally controllable in current upstream workflows, but the fix protects future dispatch wiring and local runs with untrusted refs.

Notes

No behavior change for the normal build path: git clone/fetch/checkout and pnpm format:mdx run as before; the tag selection now filters out rc/preview tags in JS instead of via shell.

Copilot AI review requested due to automatic review settings June 25, 2026 17:02
@fnando fnando self-assigned this Jun 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the docs build helper script by removing shell-string command execution and replacing it with argument-based process execution to prevent command injection when using --cli-ref.

Changes:

  • Replace execSync(<shell string>) with execFileSync(<cmd>, <args>, { cwd }) for all git/pnpm invocations.
  • Move git tag | grep | tail logic into JavaScript filtering to avoid shell pipelines.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/stellar_cli.mjs Outdated
Comment thread scripts/stellar_cli.mjs
@stellar-jenkins-ci

Copy link
Copy Markdown

1 similar comment
@stellar-jenkins-ci

Copy link
Copy Markdown

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