
Essay Permissions
Least-Privilege Branch Protection Rules for Agent Commits
Give agents their own identity, narrow rules, and no standing bypass.
Branch protection for AI coding agents begins with identity. An agent must authenticate as a non-human workload with permissions limited to its task. For protection to work, it also needs server-side rules, tight limits on bypass, runtime controls, and elevated access that ends when the work does.
Why AI coding agents are not developer proxies and cannot be governed like them
Identity conflation makes agent activity indistinguishable from human activity. When an agent authenticates as the developer who launched it, it inherits everything that person can reach. Logs attribute its actions to the same identity, and server-side controls cannot distinguish an agent push from a deliberate human push. The credential erases the distinction that policy needs.
Agents also differ from fixed-function CI jobs because their behavior is probabilistic. An agent may take different paths through the same task, so its broad permissions are harder to reason about than those of a deterministic service account. An initially narrow use case does not constrain that behavior. As the workflow expands, teams can grant broader access without revisiting the original role.
How using admin or owner credentials makes branch protection rules inert
Owner or admin credentials can put the agent outside the protections shown in the branch protection interface. GitHub rulesets support bypass actors, which are identities allowed to skip one or more rules. When the agent operates under an owner account with admin bypass, it receives that exemption as a side effect of authentication. The rules exist, but the identity avoids them. Adding more restrictions to the same ruleset does not correct that mismatch.
The consequence extends to anything running under that identity. Capabilities such as gh pr merge --admin or a direct push to a protected branch become available to the agent, including when repository content manipulates its behavior. Bypass lists can compound the problem when many integration actors have bypass_mode set to always. Each listed actor receives an escape from the stated protections. Effective enforcement depends on who authenticates.
What over-privileged agent credentials make possible when something goes wrong
Too much access can turn an agent failure into a supply-chain event. If the affected repository produces a package or action, the consequences can propagate to downstream consumers. Multiple researchers have independently found this same pattern across agent platforms. Permissions determine how far an unintended action can reach once an agent takes the wrong path.
Pillar Security’s CVE-2026-22708 disclosure shows a related weakness in command approval. In the Cursor case, attackers poisoned the execution environment and waited for a trusted, already-approved command to run the malicious payload on its own. That allowlist inversion exposes the limits of repository permissions in bounding agent behavior. The environment in which approved commands run also needs enforced limits.
The correct identity model — a dedicated non-human principal with delegated-user claims
The correct architecture gives every agent its own identity while preserving the authority of the requester where delegation applies. A business-job agent, such as an issue-triage bot, runs as itself. Its permissions cover reading the queue and writing routing information and labels, without inheriting unrelated access. The job defines the permitted scope of its authority. A task-for-a-person agent instead uses its own identity plus the delegated identity of the person requesting the work.
In that delegated model, the agent can act only where both identities are allowed to act, and logs record both names. It neither borrows the person’s login nor acts independently of the person’s authority. Microsoft’s July 2026 guidance calls for a lifecycle-managed principal with a named owner, an explicit purpose, task-based roles scoped to resources, controlled tool access, and end-to-end auditability. A dedicated service account implements the repository-facing part of this design. It gives commits and remote actions a stable identity distinct from the requester, making it possible to test whether branch protections actually apply.
Scoping branch protection rules to the minimum the agent's task actually requires
Teams should start with the task’s resource inventory when they design rules. That inventory covers repository paths, branches, build tools, network destinations, credentials, and external systems, separating read access from write access for each. The ordinary coding-agent boundary is narrow. The agent can commit to its own branch and open a pull request, but cannot push to protected branches, force-push, or merge. These are the same controls applied to CI pipelines, now applied to something that writes its own commands.
Those restrictions need to be in version control itself as well as in the agent’s command policy. A server-side rule must still block the operation if the agent circumvents its local policy. To accommodate a genuine rule incompatibility, the layering pattern separates the rule requiring an exemption from protections the agent must still encounter. The agent receives a bypass for that specific rule, while protected-branch, review, and required-check controls remain outside the exemption. A blanket bypass would erase that separation.
GitHub Copilot coding agent provides a bounded example. As of April 3, 2026, it signs every commit it makes and works with the “Require signed commits” rule enabled. That capability removes the signing incompatibility. Where an incompatibility does exist, it justifies only a rule-scoped exemption.
Agents also differ from fixed-function CI jobs because their behavior is probabilistic.
Bypass actor configuration is where correctly designed rules most often fail in practice
Bypass lists often grow because adding an integration is easier than diagnosing which rule it cannot satisfy. Each addition seems to fix one problem, but the full list weakens the rules for every actor on it. The protections remain visible in the interface. Without pruning, that visibility can conceal a growing gap between policy and effective access.
The robotsix-github-workflows case in October 2026 shows how that gap affects agent actions. A chat agent merged a pull request as the fleet GitHub App while a required status check had been red for hours. A blanket bypass existed so an auto-release workflow could direct-push release commits, although the workflow already fell back to PR + auto-merge when a push was rejected. The exemption was unnecessary for that release path. On 2026-10-26, remediation removed the bypass actor from live rulesets and changed scripts to send an empty bypass_actors array, with an explicit exit 2 if a bypass app ID was set.
Bypass policy needs to be both testable and resistant to accidental reintroduction. A non-bypass test actor should try the protected operation and be blocked. Teams also need to check the identity the agent runs under, because a ruleset that looks right may report current_user_can_bypass as always.
Just-in-time elevation for the minority of workflows that genuinely need higher privilege
Some automated workflows genuinely require direct pushes to protected branches, including semantic release, changelog generation, and bot-authored version bumps. Requiring PR + human approval can defeat their purpose. Higher privilege should last only for the specific action that requires it, followed by an automatic return to minimal permissions.
Microsoft’s guidance calls for time-limited entitlements through temporary role activation, short-lived tokens, or per-action approvals. The Cloud Security Alliance’s April 2026 guidance similarly rejects permanent, standing production access in favor of just-in-time credentials scoped to task resources. Short-lived credentials cut the time in which a leaked credential can be used. A proxy that attaches credentials at call time reduces exposure further because the agent never holds them.
A refresh token kept beside a short-lived token is still a long-lived secret, while binding a token to the machine or container that requested it makes a leaked copy useless elsewhere. The strongest setups combine short lifetimes with brokered credential use. An audited emergency path can let a needed action go through without turning into a routine bypass for every automated workflow.
Extending least-privilege enforcement to the agent's runtime environment, not just its branch permissions
Branch protection works at the repository boundary, but harm can happen before any push. Network calls, package installation, and readable credentials all create paths outside that boundary. A coding agent therefore needs an allowlist enforced by its execution harness. The runtime must constrain what commands can reach. Otherwise, a protected branch coexists with an execution environment that permits unrelated actions.
A concrete command policy confines the agent to one checked-out repository in a disposable environment, with no reads or writes outside it. Approved commands include the project’s build, test, lint, and format tools, read-only git, and file edits inside the repository. Credentials stay outside the environment, and authenticated actions go through a broker the agent cannot read. Network access is off except for the internal package mirror and named hosts the project requires. Packages come only from the internal artifact repository, and adding a dependency requires a human. The agent cannot escalate privileges or alter its policy, hooks, or configuration, and every command is logged with its identity and triggering task.
These controls operate at distinct enforcement points. Version control enforces branch rules, the firewall enforces network rules, and the identity system controls credentials. The Global Secure Access MCP Firewall preview, documented from August 2026 and listed in the September 2026 Entra release, extends that approach to tool traffic. It provides central visibility into agent traffic to external MCP servers and can block unapproved servers, tools, resources, and prompts at execution time. OWASP calls the broader principle “Least Agency,” covering minimal autonomy, tool access, and credential scope.
Applying the model — what changes when the agent gets its own scoped identity
The garyj/dotfiles case in November 2026 demonstrates the change at the server boundary. Claude Code and Codex agents had been pushing with the developer’s GitHub credentials, which bypassed default-branch rulesets. The fix introduced a scoped bot identity distinct from the developer. In a test repository with the same ruleset, a default-branch push succeeded with the developer’s credentials before the change and failed after the agent identity was introduced.
For a deployment team, the corresponding verification starts with the identity actually used for authentication. Every ruleset covering the agent’s branches needs a bypass audit, with always exemptions removed unless a specific, documented rule exemption justifies them. A protected-operation test then establishes effective enforcement, while scripted bypass configuration prevents an accidental exemption from returning unnoticed. Credential handling needs the same scrutiny. Tokens should be short-lived and injected at call time by a broker.
Temporary credentials and ephemeral environments should end with the task, while reusable automation permissions need review whenever scope changes. Repeated access denials are useful operational evidence. They may reveal unclear task boundaries or a missing approved dependency, and should trigger a deliberate policy decision.
What correct enforcement looks like over time, not just at setup
Least privilege is a runtime property that must survive workflow changes. Tool sets and bypass lists accumulate when a new task gains a capability and the completed task never loses it. Agent capabilities are cheap to add, which accelerates the familiar drift of over-privileged service accounts. Correct initial configuration is therefore insufficient. Access must expire with the task, and reusable permissions must be reconsidered after scope changes.
Maintaining that boundary means retaining a scoped identity, verifiable bypass configuration, runtime enforcement, and automatic expiry of elevated access. Logs must record the agent’s identity, the task that triggered each command, and the scope that applied when the action occurred. Tool-traffic controls then show what the agent actually calls. For a practical audit, the team needs to be able to quickly answer “what happened, under what authority, and what changed? from those records.
Notes
- Least privilege for AI agents: Identity, access, and tool binding
Supplied the model of a lifecycle-managed agent principal with a named owner, scoped roles, controlled tool access, auditability, and time-limited entitlements.


