Skip to content

fix: reject unmatched quotes in matchGitArgs to prevent flag injection - #760

Merged
EndBug merged 2 commits into
mainfrom
cursor/c23c747f
Aug 8, 2026
Merged

fix: reject unmatched quotes in matchGitArgs to prevent flag injection#760
EndBug merged 2 commits into
mainfrom
cursor/c23c747f

Conversation

@EndBug

@EndBug EndBug commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Reject unmatched ' / " in matchGitArgs before string-argv parsing so values like fix'--force cannot inject --force into custom push/fetch/pull/tag/tag_push/commit args
  • Add regression tests for the quote-injection PoC and balanced quoting
  • Document the rejection and warn against interpolating untrusted refs into custom git-arg strings

Test plan

  • npm test (includes new matchGitArgs quote cases)
  • Confirm origin fix'--force --set-upstream throws unmatched-quote error
  • Confirm balanced quotes still parse (e.g. origin a'b'c --set-upstream, --longOption 'hello world')
  • Confirm commit message with apostrophes (e.g. Let's go) is unaffected
  • Confirm rebuilt lib/ matches source

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes

    • Improved Git argument parsing by rejecting inputs with unmatched single or double quotes.
    • Preserved support for balanced quotes, including quoted values containing spaces and embedded quote characters.
    • Helps prevent malformed or potentially unsafe command-line arguments from being processed.
  • Documentation

    • Updated guidance on sanitizing untrusted Git values and avoiding flag injection risks.
    • Added recommendations to use trusted, static branch names in force-push examples.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@EndBug, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1018b387-5491-4978-978f-36212fbc1308

📥 Commits

Reviewing files that changed from the base of the PR and between 4e74267 and 1b82cf0.

📒 Files selected for processing (4)
  • README.md
  • lib/index.js
  • src/util.ts
  • test/util.test.ts
📝 Walkthrough

Walkthrough

matchGitArgs now rejects unmatched quotes before parsing while preserving balanced quoted arguments. The README documents sanitization requirements and trusted branch names. Tests cover both rejection and successful parsing.

Changes

Git argument safety

Layer / File(s) Summary
Quote validation and parsing tests
src/util.ts, test/util.test.ts
matchGitArgs validates single- and double-quote balance before parsing. Tests cover unmatched quotes and balanced quoted arguments.
Safe Git argument usage guidance
README.md
The README documents quote rejection, sanitization of untrusted values, and trusted branch names for force-push examples.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: rejecting unmatched quotes in matchGitArgs to prevent flag injection.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch cursor/c23c747f
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/c23c747f

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EndBug
EndBug marked this pull request as ready for review August 8, 2026 21:58
Co-authored-by: Cursor <cursoragent@cursor.com>
@EndBug
EndBug merged commit 75038f8 into main Aug 8, 2026
11 checks passed
@EndBug
EndBug deleted the cursor/c23c747f branch August 8, 2026 22:07
kodiakhq Bot pushed a commit to pdylanross/fatigue that referenced this pull request Aug 12, 2026
Bumps EndBug/add-and-commit from 10 to 11.

Release notes
Sourced from EndBug/add-and-commit's releases.

v11.0.0
What's Changed

chore(deps): bump picomatch by @​dependabot[bot] in EndBug/add-and-commit#724
chore(deps-dev): bump handlebars from 4.7.8 to 4.7.9 by @​dependabot[bot] in EndBug/add-and-commit#725
chore(deps): bump lodash from 4.17.23 to 4.18.1 by @​dependabot[bot] in EndBug/add-and-commit#728
chore(deps-dev): bump ts-jest from 29.4.6 to 29.4.9 by @​dependabot[bot] in EndBug/add-and-commit#727
chore(deps): bump @​actions/github from 9.0.0 to 9.1.0 by @​dependabot[bot] in EndBug/add-and-commit#729
chore(deps): bump @​actions/github from 9.1.0 to 9.1.1 by @​dependabot[bot] in EndBug/add-and-commit#732
chore(deps): bump @​actions/core from 3.0.0 to 3.0.1 by @​dependabot[bot] in EndBug/add-and-commit#733
ci(deps): bump actions/dependency-review-action from 4 to 5 by @​dependabot[bot] in EndBug/add-and-commit#734
chore(deps-dev): bump ts-jest from 29.4.9 to 29.4.11 by @​dependabot[bot] in EndBug/add-and-commit#736
chore(deps-dev): bump jest from 30.3.0 to 30.4.2 by @​dependabot[bot] in EndBug/add-and-commit#735
chore(deps-dev): bump eslint-plugin-prettier from 5.5.5 to 5.5.6 by @​dependabot[bot] in EndBug/add-and-commit#738
chore(deps): bump js-yaml from 4.1.1 to 4.2.0 by @​dependabot[bot] in EndBug/add-and-commit#739
ci(deps): bump actions/checkout from 6 to 7 by @​dependabot[bot] in EndBug/add-and-commit#741
chore(deps): bump undici from 6.24.1 to 6.27.0 by @​dependabot[bot] in EndBug/add-and-commit#744
ci(deps): bump actions/setup-node from 6 to 7 by @​dependabot[bot] in EndBug/add-and-commit#749
chore(deps-dev): bump @​vercel/ncc from 0.38.4 to 0.44.1 by @​dependabot[bot] in EndBug/add-and-commit#746
chore(deps): bump js-yaml from 4.2.0 to 5.2.1 by @​dependabot[bot] in EndBug/add-and-commit#747
chore(deps-dev): bump ts-jest from 29.4.11 to 29.4.12 by @​dependabot[bot] in EndBug/add-and-commit#750
chore(deps): bump js-yaml from 5.2.1 to 5.2.2 by @​dependabot[bot] in EndBug/add-and-commit#751
chore(deps): bump undici from 6.27.0 to 6.28.0 by @​dependabot[bot] in EndBug/add-and-commit#753
fix: reject remote-helper git flags that enable RCE by @​EndBug in EndBug/add-and-commit#754
fix: prevent git option injection via new_branch by @​EndBug in EndBug/add-and-commit#755
fix: verify committed lib/ matches source in CI by @​EndBug in EndBug/add-and-commit#756
fix: stop logging full git config (credential leak) by @​EndBug in EndBug/add-and-commit#758
fix: reject -F/--file git args that can exfiltrate runner files by @​EndBug in EndBug/add-and-commit#759
fix: reject unmatched quotes in matchGitArgs to prevent flag injection by @​EndBug in EndBug/add-and-commit#760
fix: refuse unexpected gitlinks staged by git add by @​EndBug in EndBug/add-and-commit#761
fix: do not report committed=true for empty commit SHA by @​EndBug in EndBug/add-and-commit#757
ci: pin actions-tagger and restrict release workflow permissions by @​EndBug in EndBug/add-and-commit#762
fix: neutralize bidi and control chars in action logs by @​EndBug in EndBug/add-and-commit#763

Full Changelog: EndBug/add-and-commit@v10.0.0...v11.0.0



Commits

645ecc0 11.0.0
06e788f fix: neutralize bidi and control chars in action logs (#763)
68ec86a ci: pin actions-tagger and restrict release workflow permissions (#762)
f1bb0cc fix: do not report committed=true for empty commit SHA (#757)
ebc24bf fix: refuse unexpected gitlinks staged by git add (#761)
75038f8 fix: reject unmatched quotes in matchGitArgs to prevent flag injection (#760)
d07c930 fix: reject -F/--file git args that can exfiltrate runner files (#759)
0971289 fix: stop logging full git config (credential leak) (#758)
c38a33b fix: verify committed lib/ matches source in CI (#756)
b4a0134 fix: prevent git option injection via new_branch (#755)
Additional commits viewable in compare view




Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

@dependabot rebase will rebase this PR
@dependabot recreate will recreate this PR, overwriting any edits that have been made to it
@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
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.

1 participant