Repository navigation
Fix shell command injection in tool execution and PR creation - #5152
Merged
Merged
Conversation
…rary input Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Contributor
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 93ca34e1-42aa-4082-8c31-20eb605a6d28
Lauren Prinn (laurenprinn)
marked this pull request as ready for review
November 6, 2026 01:03
Avoid passing generated batch paths directly to cmd.exe /c in the no-shell execution branch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Garrett Campbell (gcampbell-msft)
approved these changes
Nov 6, 2026
Garrett Campbell (gcampbell-msft)
left a comment
Collaborator
There was a problem hiding this comment.
Approve with feedback (offline)
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.
General fix approach: stop building shell command strings with interpolated input and stop using
execSyncwith a single command string. Instead, executegitwithcp.execFileSyncand pass arguments as an array so user-controlled values are treated as data, not shell syntax.Best single fix in this snippet: refactor
runGitto acceptcommand: string[]and invokecp.execFileSync("git", [...gitConfigArgs, ...command]). Then update call sites in shown code to pass argument arrays (especially line 232 cleanup delete-branch call). Keep behavior equivalent by preserving logging and auth/config handling, but avoid shell interpretation entirely.Edits needed in
tools/pr-creator/src/index.ts:runGitsignature and implementation (lines around 109–121).sourceBranchAlreadyExistsand cleanup callers to pass arrays instead of interpolated command strings.child_processalready imported.Suggested fixes powered by Copilot Autofix. Review carefully before merging.