answered from live GitHub & Hugging Face data
What are the security implications of using fine-grained PATs vs GitHub App tokens for AI coding agents?
Verdict: For an AI coding agent, use a GitHub App installation token. A fine-grained PAT gives the agent the same reach as the person who created it, and it lasts much longer.
Comparison
| Risk factor | Fine-grained PAT | GitHub App installation token |
|---|---|---|
| Lifetime | Set by the user. Infinite lifetime is allowed unless an org policy blocks it. | Expires after 1 hour. |
| Whose access it has | The token owner's access, limited to one resource owner and the selected repositories. | Only the repositories and permissions the installer granted to the app. |
| Scope control at issue time | Choose repositories and permissions when you create the token. | Request a subset of repositories and permissions for each token. The token cannot exceed what the app holds. |
| Who it is tied to | A user. It stops working if that user loses access. | The app installation. It is not tied to one person and remains if the installer leaves. |
| Attribution in logs | Actions appear as the human user. | Actions appear as a bot, such as @jenkins[bot]. |
| Revocation | The user or GitHub can revoke it. | Removing repositories from the installation removes access. The installer can also uninstall the app. |
| Rate limits | Tied to the user. | Scale with the number of repositories and users. |
Sources: token expiration and revocation, installation access tokens, personal access token management, and deciding when to build a GitHub App.
Security implications
1. Blast radius of a leaked credential
- A leaked PAT works until it expires or is revoked. You can set no expiry.
- A leaked installation token works for at most one hour.
- A leaked PAT carries all of the owner's rights on the selected resources. Narrow repository and permission choices reduce this risk, but they do not change the lifetime.
2. Automatic revocation
- GitHub revokes any token pushed to a public repository or public gist. This applies to PATs and app tokens.
- GitHub revokes a personal access token that has not been used in one year.
- Agents that write logs or config files can expose tokens. Keep tokens out of logs and committed files.
3. Human dependency
- A PAT stops working when its owner leaves or loses repository access.
- A GitHub App installation stays in place after the installer leaves. The docs say this lets integrations continue to work.
- A shared PAT on a developer's account gives the agent that developer's full reach. This is the most common failure mode.
4. Attribution and audit
- App actions show the app as the actor. This makes agent activity easier to separate from human activity.
- PAT actions show the human as the actor. Reviewers may not know an agent acted.
5. Where PATs still fit
- Fine-grained PATs cannot do some tasks. The docs list gaps, including contributing to public repos where the user is not a member, outside-collaborator contributions, access to Packages, and the Checks API.
- The docs say personal access tokens are for acting as yourself. For long-lived integrations, they point to GitHub Apps.
- Use a PAT only when the task needs one of these gaps. Set the shortest practical expiry.
6. Token user-to-server tokens
- If an app acts on behalf of a user, its user access token expires after eight hours by default. Owners can disable expiry, but the docs advise against it.
Recommendation
- Register a GitHub App for the agent.
- Install it on only the repositories the agent needs.
- Mint an installation token per task with the smallest
permissionsandrepositoriesvalues. - Use a fine-grained PAT only for a gap the app cannot cover, with a short expiry.
- Never use a classic PAT for an agent.
Choose a GitHub App if the agent runs repeatedly, works across repositories, or must not depend on one person. Choose a fine-grained PAT if you test a single task by hand and need one of the gaps listed above.
If you run more than one agent, give each agent its own GitHub App identity. A single shared app shows all agents as the same bot. githug does this today: each agent gets its own key, which mints one-hour tokens for one repository through a GitHub App. Its commits show the agent as author and name the accountable human in trailers. The hug CLI sets this up during the beta.
This is general guidance, not legal advice. Check your organization's token policies before you deploy.