Skip to content

Inject GitHub auth at the MITM proxy so agents never hold tokens; tighten shared token cache perms #1861

Description

@clubanderson

Current state

Agents authenticate to GitHub three different ways, each with a weakness:

  1. git → credential helper (git-credential-hive.sh): good — UID-verified, mode-gated — but only covers git.
  2. gh CLI → per-agent scoped token file after 🔒 fix: teach agents gh auth via their per-agent scoped token #1860 (previously agents improvised with the shared cache).
  3. Shared gh-app-token.cache0640 group node, readable by every agent UID. Any agent can cat it and skip the helper's UID/mode gate entirely, holding an unscoped app token. The MITM proxy's mode enforcement then stands alone.

Proposal

The proxy already MITMs api.github.com and inspects every request per agent mode. Complete the design:

  1. Proxy-side auth injection: for requests the mode check allows, the proxy strips whatever Authorization header the agent sent and injects a token minted server-side for that agent's tier. Agents then need no token material at all — gh works with a dummy GH_TOKEN=hive (gh requires the variable to be non-empty), and token theft between agents becomes structurally impossible. This also finishes the story started by the ${GH_AUTH} text ("authentication is handled in transit"), which today is only true for the CA layer.
  2. Tighten the shared cache to 0600 once nothing but the hive runtime (UID 0/dev) needs it — the credential helper runs as the agent but can be given a setuid-free path via a tiny local token broker (unix socket) if needed.
  3. git via injection too: once injection exists, the credential helper can hand out a dummy credential and rely on the proxy, keeping the mode gate as a fast local pre-check.

Why now

Field debugging (2026-07-13/14) showed an agent independently discovering the shared-cache read within one session when its push failed — the gap gets found under pressure. Two layers were designed; today only one holds once a token leaks sideways.

Related: #1860 (interim: per-agent scoped tokens for gh), #1849/#1850/#1856/#1858 (this week's config/enforcement hardening).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions