Conversation
exec/execLarge/execWithStdin pass a string to execSync, which runs /bin/sh -c, and every caller built that string by interpolating a ref, a path or a search term. All of them are reachable unauthenticated over HTTP: /api/diff?ref=, /api/file/<path>?ref=, /api/commits?search=, /api/revert-file. Quoting did not help - "$(…)" expands too. There is also a no-network trigger: the diff parser feeds every changed file name back into `git show <ref>:<path>` for its line count, so opening a diff whose PR renames a file to `evil$(touch PWNED).txt` was enough to execute. Everything in the package now goes through argv-form git(), gitLines() and gitWithStdin(). revertFile uses `git clean --force --` for untracked files rather than `rm`, so git refuses paths outside the repository. getRecentCommits also drops the literal quotes it wrapped --format in, which were being parsed as part of the first and last field. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018PkYQzbsnMihHesafWvXKs
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.
Audit finding P1-1.
exec/execLarge/execWithStdinhand a string toexecSync, which runs/bin/sh -c, and every caller built that string by interpolating a ref, a path or a search term.All of them are reachable unauthenticated over HTTP:
GET /api/diff?ref=…git merge-base <ref> HEADGET /api/file/<path>?ref=…git show <ref>:<path>— both halvesGET /api/commits?search=…git log --grep=<search>POST /api/revert-filerm "<filePath>"Double quotes were no protection:
"$(…)"expands.There is also a trigger that needs no request at all. The diff parser feeds every changed file name
back into
git show <ref>:<path>for its line count, so opening a diff whose pull request renamesa file to
evil$(touch PWNED).txtexecuted it. git permits that file name; the regression testbuilds a repository containing exactly it.
@diffity/gitnow goes through argv-formgit(),gitLines(),gitWithStdin()revertFileusesgit clean --force --for untracked files instead ofrm, so git itself refuses paths outside the repository — no containment check to get wronggetRecentCommitsdrops the literal quotes it wrapped--formatin, which were being parsed into the first and last fieldTests cover the hostile file name through
getFileContent,getFileLineCount,getDiff,getDiffFilesandgetDiffStat, a$(…)ref throughgetMergeBase/normalizeRef, and a$(…)search term through
getRecentCommits— each asserting no side effect happened. Note that gitrejects branch names containing parentheses, so the ref vector is the API parameter, not a branch.
Remaining from the same finding, for a follow-up:
packages/githubstill interpolatesowner/repointo
gh api …strings (audit P2-1; the delivery path there is a submodule's.gitmodulesURL).Stacked on #9.
🤖 Generated with Claude Code
https://claude.ai/code/session_018PkYQzbsnMihHesafWvXKs