How a GitHub Marketplace App Could Have Taken Over Your Repository
A GitHub GraphQL mutation allowed a GitHub App with only Members: read and Metadata: read permissions to grant a team Admin access to a repository, while the equivalent REST API correctly enforced the required Administration: write permission. An attacker-controlled app installed on an organization could use this to escalate a team's privileges, potentially giving an attacker-controlled user repository Admin access.
jeetbhdr.github.io
Published on jeetbhdr.github.io
I found a GitHub GraphQL authorization issue that allowed a GitHub App (internal or Marketplace) with only minimal permissions to grant a team Admin access to a repository. The same change through the REST API was blocked.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the GraphQL updateTeamsRepository mutation did not enforce the repository Administration: write permission that the equivalent REST endpoint requires, allowing a token with only Members: read and Metadata: read to change team repository permissions.
Impact
An attacker-controlled app could grant a team Admin access to a repository, and if that team contained an attacker-controlled user, that user could gain repository Admin access, which could include changing branch protection, managing access, and modifying webhooks and deploy keys, posing a supply chain risk.
What the attacker needed
App installed on org with repo access; attacker controls a user in the team
The fix
GitHub fixed the issue by making the GraphQL mutation enforce the same repository Administration: write permission as the REST endpoint.
How it was found
- Install the attacker-controlled GitHub App on the organization with access to the target repository.
- Generate an installation access token for the app.
- Use the token to call the updateTeamsRepository GraphQL mutation with the repository ID, team ID, and permission set to ADMIN.
- The mutation succeeds and grants the team Admin access to the repository.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
GitHub Apps are third-party tools you install on your account or organization, and they ask for specific permissions. Normally, an app can only do what its permissions allow. Here, a bug meant an app with very limited permissions could still give a team full admin rights over a repository, which it should not have been able to do.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.