Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Below are concise, step‑by‑step instructions to reduce excessive repository admins in GitHub using the web console (GitHub.com UI).
If you share your repo type (personal vs organization) and current number of admins/teams, I can suggest an exact target layout (e.g., “1 owner + 1 maintainers team + write-only contributors”).
1. Confirm You Have Permission
You must be:- An Organization Owner (for org repos), or
- A Repository Admin (for personal or org repos)
2. List Current Admins for a Repository
- Sign in to GitHub.com.
- Open the repository:
https://github.com/<org-or-user>/<repo-name> - Click Settings (top menu in the repo).
- In the left sidebar, click:
- Collaborators and teams (for org repos: “Manage access”)
- Under Manage access, review:
- Teams with access and their permission level
- Individuals with access and their permission level
3. Reduce Individual Admins to Lower Roles
For each user who doesn’t truly need admin rights:- In Settings → Manage access, find the person with Admin access.
- Click the gear icon (or three-dot menu) next to that user.
- Under Repository access, change:
- From: Admin
- To: Maintain (for maintainers) or Write (for regular contributors)
- Click Save or Update access.
4. Use Teams Instead of Individual Admins (Org Repos)
If you are in an organization:- Go to the org page:
https://github.com/<org> - Click Teams.
- Create or choose a team (e.g.
repo-maintainers). - Click the team → Repositories → Add a repository to this team.
- Select the repository and set permission to:
- Maintain for people who manage issues/PRs but don’t need admin, or
- Write for regular contributors.
- Remove individual Admin access for those now covered by the team (same method as step 3).
5. Remove Unnecessary Teams with Admin Access
- In the repository, go to Settings → Manage access.
- Under Teams, find any team with Admin level.
- Click the gear icon next to the team.
- Change permission:
- From Admin
- To Maintain or Write, as appropriate.
- Save changes.
6. Restrict Who Can Be a Repo Admin at Org Level (Optional)
For organizations to keep admin counts low going forward:- Go to the Organization page.
- Click Settings.
- In the left sidebar, review:
- Member privileges / Repository creation / Base permissions.
- Set:
- Base permissions to Read (or lower), not Admin.
- Restrict who can create repositories or manage settings to Organization owners only.
- Ensure only a small set of Organization Owners exist (Org Settings → People → change role from Owner to Member where appropriate).
7. Periodically Audit Admins
- On a schedule (e.g. monthly), for each critical repo:
- Go to Settings → Manage access.
- Export or screenshot current access.
- Remove or downgrade permissions that are no longer needed.
If you share your repo type (personal vs organization) and current number of admins/teams, I can suggest an exact target layout (e.g., “1 owner + 1 maintainers team + write-only contributors”).
Using CLI
Using CLI
Below is a concise, step‑by‑step way to identify and reduce excessive repo admins using the GitHub CLI (
This shows logins that have Members of these teams may effectively be “repo admins” depending on team permission.Use this to identify who can manage repos/org settings globally.
Valid values:
Confirm the list is limited to the strictly necessary admins.
gh).Assumptions:- You have
ghinstalled and authenticated (gh auth login). - You’re an admin/owner on the repo or org.
- Replace
OWNER(user/org) andREPOwith your values.
1. List who has admin access on a repository
A. List collaborators and their permissions (classic collaborators)
admin: true via direct collaborator access.B. List teams with admin access (for org repos)
C. (Optional) List org members with admin role (org‑wide)
2. Decide the minimal required admins
Offline step:- For each admin user or team, decide:
- Keep as admin,
- Downgrade to
maintainorpush, or - Remove.
3. Downgrade or remove individual repo admins
A. Change a collaborator’s permission (e.g., admin → maintain)
pull, triage, push, maintain, admin.B. Remove a collaborator entirely
4. Downgrade or remove admin teams
A. Change team permission on the repo (admin → maintain, for example)
B. Remove team access to the repo
5. Reduce organization‑wide admins (if needed)
Use this carefully—org admins lose global powers.A. List current org admins
B. Change a user’s org role from admin → member
C. Remove a user from the org (if appropriate)
6. Re‑verify effective repo admins
Re‑run checks:Using Python
Using Python
Below is a practical, step‑by‑step way to reduce excessive repo admins in GitHub using Python (via the GitHub REST API and/or PyGithub).
Use this output to decide which users/teams should no longer have admin rights.
Run in dry-run mode first by commenting out the change lines and just printing what would happen.
6. (Optional) Using Raw REST API via
If you prefer not to use PyGithub:
1. Preparation
- Decide the policy you want to enforce, for example:
- Only a specific team(s) can be admin.
- Or max N admin users per repo.
- Create a GitHub Personal Access Token (PAT) with at least:
repoadmin:org(if managing org repos, teams, etc.)
2. Install Python dependencies
3. Enumerate Admins and Decide Remediations
3.1. Using PyGithub to list repos and their admins
4. Implement Least-Privilege Changes
4.1. Define allowed admins (policy)
Example: only one “core-admins” team plus maybe some specific user(s) per repo.4.2. Downgrade or remove excessive admins
5. Safer: Dry-run / Audit Mode
Add aDRY_RUN = True flag:6. (Optional) Using Raw REST API via requests
If you prefer not to use PyGithub:- List collaborators with permission:
GET /repos/{owner}/{repo}/collaborators?permission=admin - Change a collaborator’s permission:
PUT /repos/{owner}/{repo}/collaborators/{username}with body:{"permission": "push"}
7. Governance
- Run the audit/remediation script periodically (e.g., as a GitHub Action or CI job).
- Log all changes.
- Optionally notify affected users/teams before/after changes.
Using Terraform
Using Terraform
permission does not replace the repository; it updates access in place, but it is immediately effective and may block previous admin/push actions.For verification, terraform plan should show:- No change to
github_repository.repo github_repository_collaborator.adminwithpermission = "admin"- All other
github_repository_collaborator.*changing fromadmin/pushto the lower permission you chose (e.g.,pull).

