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 and Infographic
Least privilege means you give the key that opens exactly the doors you need — no more. This agent needs to read issues, comment on them, and create labels. All three operations fall under the 'issues' permission scope, and write-level access covers all three. Read-only issues access blocks posting and labeling. Granting contents, pull-requests, or admin access 'just in case' is exactly what least privilege is designed to prevent.
Full explanation below image
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: - Read open issues: Requires at minimum read access to issues. - Post comments on issues: Requires write access to issues (comments are a sub-resource of issues in GitHub's permission model). - Create labels: Labels are 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 (you cannot write without being able to read), so a single issues: write permission grants all three required capabilities.
Option A 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.
Option C is incorrect because granting contents, pull-requests, and actions write access gives the agent the ability to push code to branches, create and merge pull requests, and trigger CI 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.
Option D 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.
Option B is correct. issues: write is the single, minimal permission that satisfies all three of this agent's operational requirements.