Prevent command injection in CLI docs build script#2536
Open
fnando wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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>)withexecFileSync(<cmd>, <args>, { cwd })for all git/pnpm invocations. - Move
git tag | grep | taillogic into JavaScript filtering to avoid shell pipelines.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Preview is available here: |
1 similar comment
|
Preview is available here: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces every
execSyncshell-string call inscripts/stellar_cli.mjswithexecFileSyncusing 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
cliRefvalue (sourced from the--cli-refflag /stellar-cli-refworkflow input) directly into a shell string passed toexecSync, 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 intendedgitcommand. 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/checkoutandpnpm format:mdxrun as before; the tag selection now filters outrc/previewtags in JS instead of via shell.