Skip to content

fix: validate and escape commit hash in pull_upstream cherry-pick (CWE-78) - #340

Open
Matthew-Selvam wants to merge 1 commit into
Conway-Research:mainfrom
Matthew-Selvam:fix/180-cherry-pick-command-injection
Open

fix: validate and escape commit hash in pull_upstream cherry-pick (CWE-78)#340
Matthew-Selvam wants to merge 1 commit into
Conway-Research:mainfrom
Matthew-Selvam:fix/180-cherry-pick-command-injection

Conversation

@Matthew-Selvam

Copy link
Copy Markdown

Summary

Fixes #180. The pull_upstream tool interpolated the commit parameter directly into git cherry-pick ${commit} with no execution-time validation or escaping. The policy engine's validate.git_hash rule covers the request layer, but a policy bypass or misconfigured rule would have exposed this injection point directly at the exec call.

Fix

  • Validate the commit hash format (/^[a-f0-9]{7,40}$/i) at execution time, returning a blocked message on mismatch.
  • Wrap the value with the existing escapeShellArg() helper before interpolating into the shell command.

Testing

  • tsc --noEmit passes.
  • Existing command-injection.test.ts policy-layer tests for pull_upstream still pass (71/71 in tools-security.test.ts, full suite green).

…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
@Matthew-Selvam

Copy link
Copy Markdown
Author

This is ready for maintainer review whenever you get a chance — happy to make any changes requested.

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.

Security: Unescaped commit hash in pull_upstream cherry-pick (CWE-78)

1 participant