Skip to content

A coding instance can push to and open PRs on any repo the user can reach, not just its registered one #676

Description

@proagentstore

A coding instance's registered repo is a working-directory default, not an authorization boundary. Nothing prevents an instance from writing to a completely different repository.

Observed today, unambiguously:

  • Instance e4d2d031-833b-4ccf-8b39-8af08337075b ("PAS Coder") has exactly one repo registered: proappstore-online/platform, workdir ~/dev/stores/pas/platform. coding_repos_list returns that single entry and nothing else.
  • It was given an objective to implement proappstore-online/platform issue Refactor: split agent-storage.ts (1262 LOC) per storage domain #137 (an MCP tool to edit an existing board ticket).
  • The run reported success — and had pushed branch feat/update-board-ticket to ProAgentStore/platform and opened PR feat(mcp): a board ticket can be edited, not only filed and moved #675 there. A different GitHub organisation entirely.
  • proappstore-online/platform received nothing: no branch, no PR, no commits. The work exists only in the other org's repo.
  • The run's own closing summary described the target as "the PAGS platform repo", so the engine's model of where it was working had drifted, and no layer beneath it disagreed.

Root cause: the runner's git and gh credentials are the user's own account credentials, which reach every repo and org that account can write to. The registered repo scopes where the agent starts, not what it can reach. A run whose reasoning drifts to the wrong repo will succeed at writing there.

This is a containment problem rather than a prompting problem. Instructing objectives more carefully reduces the odds; it does not make the wrong-repo write impossible.

Requested change — scope credentials per instance via the GitHub App:

  1. Issue each coding instance a GitHub App installation token scoped to its registered repo, and use that token for the runner's git and gh operations instead of the account-wide credential. githubApp already shows as configured in coding_diagnostics, so the mechanism is present.
  2. Write access should be limited to the instance's registered repo. A push, branch create, PR open, merge or issue write against any other repo should fail at the credential layer, not rely on the engine choosing correctly.
  3. Read access should remain broader — across the user's own repos. This matters and should not be lost: in a separate run today, the agent usefully consulted proappstore-online/platform PR Refactor: extract sub-hooks from packages/sdk/src/voice/use-voice.ts (1127 LOC) #138 as a reference implementation while working on ProAgentStore/platform. Scoping reads down to a single repo would break that legitimate pattern.
  4. When a write is refused for being out of scope, surface the refused target repo in the run's stop reason, so the user sees "attempted write to X, not permitted" rather than a generic failure.
  5. Consider surfacing the effective token scope in coding_diagnostics, so a user can confirm what an instance is actually able to write to before giving it autonomous work.

Reported by the account owner after a run landed a completed feature in the wrong organisation's repository and reported success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1: blocks external usersMust be true before someone who is not the owner can run an agent (#68)backendBackend / Worker / API workbugSomething isn't workingcoderThe Coder wedge agent (#68) — Engine, Pilot, Co-pilot, Loop, Overseerrunnerpackages/browser-runner + packages/cli — ships only via an npm publishsecuritySecurity hardening / audit finding

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions