A Copilot agent is designed to read open issues, post comments on those issues, and create labels — nothing else. Following the principle of least privilege, which set of GitHub token permissions should be granted to this agent?
Select an answer to reveal the explanation.
Short Explanation
Least privilege means you hand out only the keys you need. This agent needs to read issues, comment, and create labels, and write access to issues covers all three. Read-only issues blocks comments and labels, while extra permissions are just unnecessary risk.
Full Explanation
The principle of least privilege states that a process or user should be granted only the permissions needed to perform its specific tasks, and no more. This limits the blast radius if the agent is compromised, misbehaves, or is exploited.
For this agent's three operations: - Reading open issues requires at minimum read access to 'issues'. - Posting comments on issues requires write access to 'issues' because comments are a sub-resource of issues in GitHub's permission model. - Creating labels is also managed under the 'issues' permission scope; creating a label on a repo requires write access to 'issues'.
Therefore, 'issues: write' is both necessary and sufficient. The 'issues: write' scope implicitly includes read access because you cannot write without being able to read, so a single 'issues: write' permission grants all three required capabilities.
The set granting read access to 'issues' only is incorrect because 'issues: read' allows the agent to list and read issue data but blocks any write operations; posting a comment or creating a label will return a 403 Forbidden error. Read-only is not sufficient for this agent's write requirements.
The set granting write access to 'issues', 'contents', 'pull-requests', and 'actions' is incorrect because it gives the agent the ability to push code to branches, create and merge pull requests, and trigger continuous integration workflows, none of which are part of its defined purpose. Provisioning for future growth violates least privilege and creates unnecessary risk. Permissions should be re-evaluated and expanded only when a concrete new requirement exists.
The set granting admin access to the repository is incorrect because admin access includes repository management capabilities such as modifying branch protection rules, adding collaborators, deleting the repository, and managing webhooks. None of these are needed for an issue-commenting agent, and granting them is a serious security risk.
The correct set is write access to 'issues' and no other permissions. 'issues: write' is the single, minimal permission that satisfies all three of this agent's operational requirements.