fix: validate and escape commit hash in pull_upstream cherry-pick (CWE-78) - #340
Open
Matthew-Selvam wants to merge 1 commit into
Open
Conversation
…E-78) Adds execution-time validation of the commit hash format and wraps it with escapeShellArg() before interpolating into the cherry-pick command, as defense-in-depth alongside the policy engine's validate.git_hash rule. Fixes Conway-Research#180
Author
|
This is ready for maintainer review whenever you get a chance — happy to make any changes requested. |
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.
Summary
Fixes #180. The
pull_upstreamtool interpolated thecommitparameter directly intogit cherry-pick ${commit}with no execution-time validation or escaping. The policy engine'svalidate.git_hashrule covers the request layer, but a policy bypass or misconfigured rule would have exposed this injection point directly at the exec call.Fix
/^[a-f0-9]{7,40}$/i) at execution time, returning a blocked message on mismatch.escapeShellArg()helper before interpolating into the shell command.Testing
tsc --noEmitpasses.command-injection.test.tspolicy-layer tests forpull_upstreamstill pass (71/71 intools-security.test.ts, full suite green).