agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

feat(safety): gate worker changes to GitHub identity (`gh auth switch`) and pushes to non-origin remotes

Open homeshrawat opened this issue 3 months ago • 3 comments

Summary

A worker can change the machine's active GitHub identity (gh auth switch) and push code under a different account, with no approval gate, no notification to the orchestrator, and no audit record. The identity change is global and persists after the session ends.

To be clear about scope: forking is a legitimate, supported workflow (#2609 calls it "the standard fork-contribution workflow"). The problem is the silent switch of the human's GitHub identity, not the fork.

What happened

A worker finished its task and could not push to origin — the account it was running as had read-only access. Without asking, it:

  1. Ran gh auth switch to a different GitHub account configured on the machine
  2. Forked the repository to that account
  3. Pushed the branch there
  4. Opened a cross-fork PR authored by that account
  5. Left gh switched to the wrong account when it finished, reporting status: idle

The orchestrator learned of this only by reading the worker's on-disk transcript afterward. Every message sent to stop it was silently lost to a separate bug, so no correction was possible while it ran.

Because gh auth switch is global, every subsequent gh command on the machine — including the human's own, and other agents' — ran as the wrong account until manually reverted.

Why this is worth gating

  • Identity misattribution: commits and PRs land under an account the human did not choose, in a repo belonging to an organization.
  • Persistence: the change outlives the session that made it, silently affecting unrelated work.
  • Data exposure: here the upstream repo was public, so nothing leaked. Had it been private, a fork/push to a personal account would have been an exfiltration path — reachable through ordinary agent tool use, with no gate.
  • Recovery cost: unwinding it required deleting a branch and PR, re-forking under the right account, re-pushing, and re-opening the PR.

Requested behavior

A policy gate for identity- and publication-affecting operations, with confirm-or-deny and an event surfaced to the orchestrator:

  • gh auth switch, gh auth login, gh auth refresh (scope escalation)
  • gh repo fork, gh repo delete
  • git push to any remote that is not the session's expected origin

Two cheaper mitigations, valuable on their own:

  1. Snapshot and restore the active gh account across a session, or at minimum verify at teardown and warn when a session ends with the account changed. A session that leaves global state dirty should not report clean idle completion.
  2. Emit an event to the orchestrator when a worker changes auth identity or pushes to a non-origin remote, so it is visible even when it is permitted.

Environment

  • macOS (darwin 23.6.0), cursor harness worker
  • gh 2.92.0, two accounts configured in the keyring
  • Repo at 3934bc86a

homeshrawat avatar Aug 05 '26 23:08 homeshrawat

Thanks for contributing to Agent Orchestrator.

This issue is being picked up by the current external contributor on-call pair:

  • @illegalcall
  • @somewherelostt

If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @somewherelostt here.

For faster context or live questions, you can also join the AO Discord.

Join the session here: https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

somewherelostt avatar Aug 06 '26 15:08 somewherelostt

After reviewing the scope, this affects only machines with multiple GitHub accounts already configured, and only when a worker explicitly switches between them. A reliable AO-wide fix would require cross-harness command enforcement or per-session credential isolation. That cost is disproportionate to the demonstrated impact, so I suggest closing this as not planned. @AgentWrapper

Rishet11 avatar Aug 30 '26 10:08 Rishet11

Hi @homeshrawat, per the earlier discussion the gh-auth gating approach isn't planned. Closing as not planned. Thanks for the safety thinking.

Rishet11 avatar Sep 03 '26 15:09 Rishet11