fix(git-auth): refuse non-GitHub hosts in the App credential helper#114
Merged
Merged
Conversation
Port of the host-allowlist our upstream contribution ships (NousResearch/hermes-agent#69972, commit 99fe8c7): git invokes credential helpers for EVERY https remote, so a helper that ignores the request's host= field hands the installation token to any URL a repo, submodule, or redirect points at. The boot-written gitconfig already scopes the helper to https://github.com; this enforces the same boundary inside the helper itself. get-credential now parses git's stdin description block and answers only for github.com / gist.github.com over https — anything else emits nothing and exits 0 so git falls through to the next helper. An empty request (manual smoke test) still answers, so existing invocations are unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes the gap our own upstream audit found in our deployed helper (fleet lessons 2026-07-23, item 6):
hermes_cli/github_app_token.pyanswered every credential request without checking thehost=field, relying solely on the boot-written scoped gitconfig.What
Port of the host-allowlist shipped in our upstream contribution (NousResearch/hermes-agent#69972, commit 99fe8c7):
get-credentialnow parses git's stdin credential description blockgithub.com/gist.github.comoverhttpsWhy
git invokes credential helpers for EVERY https remote. A malicious submodule or redirect pointing at an attacker host would previously have been handed the org installation token if the helper were ever wired unscoped. Defense in depth: the scoped gitconfig remains, and the helper now enforces the same boundary itself.
Tests
tests/hermes_cli/test_github_app_token.py22/22 pass;test_git_credentials_boot.py+test_gh_token_inject.py41/41 pass; ruff clean🤖 Generated with Claude Code