Repository navigation
Description
OpenCodeReview Version
v1.3.4
Operating System
macOS (Apple Silicon)
Installation Method
npm (global)
LLM Provider
Anthropic (Claude)
Bug Description
Bug description
Ref values supplied via --from, --to, and --commit are passed as bare
positional arguments to git subcommands without any --/--end-of-options
guard separating them from option flags. A ref value beginning with - is
therefore interpreted by git as an option rather than a revision, and several of
those options have dangerous side effects:
git diff --output=<file> …→ arbitrary file overwritegit grep -O<cmd>/--open-files-in-pager=<cmd>→ arbitrary command execution
Affected call sites:
internal/diff/git.go:118—git diff … <base> <p.to> "--"(p.to before--)internal/diff/git.go:125—git show … <p.commit>(no--)internal/diff/git.go:260—git merge-base <from> <to>(no--)internal/tool/filereader.go:130,216—git show <Ref>:<path>(Ref concatenated raw)internal/tool/code_search.go:70—<ref>appended intogit grepbefore--internal/tool/file_find.go:75—git ls-tree -r --name-only <ref>
The values are never validated as refs before reaching git (git's own ref-naming
rules forbid a leading -, but these raw strings bypass that check).
Steps to Reproduce
Steps to reproduce
- In any git repo:
ocr review --commit '--output=/tmp/ocr_pwn'
→/tmp/ocr_pwnis created/overwritten with git diff output. - (RCE path) drive a review in range/commit mode where the ref equals
--open-files-in-pager=...; thecode_searchtool'sgit grepinvocation
launches the supplied program once a match exists.
Expected Behavior
Expected behaviour
A ref value that is not a valid git revision — in particular one that begins with
- — must be rejected before any git invocation, and refs must be passed to git
in a way that cannot be reinterpreted as command-line options. No --from/--to/ --commit value should be able to cause git to write files or execute commands.
Actual behaviour
ocr review --commit '--output=/path/to/file' (or --to, --from) reaches
git diff/show and writes the diff to an attacker-chosen path; a ref such as
--open-files-in-pager=<cmd> reaching the git grep path in code_search can
execute an arbitrary command. The shipped GitHub Action avoids this only because
it happens to use head.sha and an origin/ prefix; any other automation that
forwards an untrusted branch/commit name to these flags is exploitable.
Logs / Error Output
Additional Context
Suggested fix
- Validate every non-empty
--from/--to/--commitvalue at ingestion: reject any
value starting with-and confirm it resolves
(git rev-parse --verify --end-of-options <ref>^{commit}). - Defense in depth: insert
--end-of-optionsimmediately before ref arguments in
thediff/show/merge-basecalls.
Activity
MuoDoo commentedon Jun 12, 2026
We confirmed the git option-injection issue.
--output=<file>is reachable through the currentocr review --commitflow and can write an attacker-chosen file. We also confirmed thatgit grep --open-files-in-pager=<cmd>is a real RCE sink in thecode_searchpath, but we have not found a stable end-to-end RCE path through the currentocr reviewflow because the malicious ref fails earlier during diff loading.lizhengfeng101 commentedon Jun 13, 2026
Hi @Aravindargutus,
Thank you for discovering and reporting this critical RCE vulnerability. Your proof-of-concept with the
-O<path>flag injection viagit grepwas particularly insightful.This has been fixed in v1.3.5 (PR #112). The fix includes:
--commit/--from/--tovalue starting with-at the CLI entry point--end-of-optionsguards before user-supplied refs in all git command call sites (git show,git diff,git grep,git ls-tree,git log,git merge-base)git rev-parse --verifybefore useAll users will receive the fix automatically on their next use via npm.
Thanks again for helping make OpenCodeReview more secure!