Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Here’s how to lock down Organization Default Permissions in GitHub using the web console.
1. Open your Organization Settings
- Sign in to GitHub.
- In the top-right, click your profile picture.
- Under “Organizations”, click the organization you want to configure.
- In the org view, click Settings (top tabs).
2. Reduce Default Repository Permissions (Base Permissions)
GitHub has a “base” (default) permission that applies to all org members on all repositories unless explicitly overridden.- In the left sidebar, look for one of:
- Member privileges, or
- Organization security → Base permissions (newer UI)
- Find Base permissions or Default repository permissions.
- Change from overly permissive settings (e.g.,
WriteorAdmin) to a least-privilege option:- Prefer Read or None depending on your policy:
- Read: members can view all repos by default.
- None: members only see repos they are explicitly granted access to.
- Prefer Read or None depending on your policy:
- Click Save / Update.
3. Restrict Who Can Create Repositories (if needed)
- In the same Member privileges (or similar) section:
- Under Repository creation / Repository permissions, adjust:
- Allow creation of Private, Internal, Public repos only for:
- Organization owners (strict), or
- Selected members if you need delegated admins.
- Allow creation of Private, Internal, Public repos only for:
- Save changes.
4. Review & Clean Up Existing Access
Changing defaults does not fix past grants. Quickly review:- People tab → check member roles (Owner vs Member).
- Repositories tab:
- For sensitive repos, open the repo → Settings → Collaborators and teams:
- Remove broad
Write/Adminfor@org/*or large teams. - Scope permissions narrowly (Read/Write/Admin per team/user).
- Remove broad
- For sensitive repos, open the repo → Settings → Collaborators and teams:
Using CLI
Using CLI
Below are step‑by‑step instructions to remediate overly‑permissive Org Default Permissions in GitHub using the GitHub CLI (
If you don’t have
For the strictest posture (no automatic access):
This forces repo creation to be done only by org owners or via approved automation.Adjust according to what is allowed in your org.
Verify:
Run this for each organization you manage, adjusting
If you share your current JSON for
gh), by tightening the default member privileges and default repository permissions.Assumptions:- You’re an org owner (or have equivalent admin rights).
- You have
ghinstalled and authenticated (gh auth login).
1. Identify Current Organization Default Settings
ReplaceORG with your organization login (e.g., my-company).jq, remove the pipe and inspect JSON manually.2. Restrict Default Repository Permission for Members
To remediate “org default permissions” you typically wantread or none (instead of write or admin) as the default permission for organization members on new repos.Available values: read, write, admin, none.Example: set default to read:3. Restrict Members from Creating Repositories
If your misconfiguration is that “any member can create repos”:3.1 Disable Member Repo Creation Entirely
3.2 (Optional) If You Allow Some Creation, Limit Types
If you must allow creation, restrict types (GitHub Enterprise / orgs that support these flags):4. Confirm the New Configuration
Re-run:default_repository_permissionisreadornone(per your policy).members_can_create_repositoriesisfalse(or restricted as desired).- Allowed repo types match your security policy.
5. (Optional) Script It for Repeatable Use
Example remediation script:$ORG and the values as needed.If you share your current JSON for
/orgs/ORG, I can give you the exact gh api patch command tailored to your current misconfiguration.Using Python
Using Python
Below are concrete, step‑by‑step remediation instructions to lock down an organization’s default (base) permissions in GitHub using Python.Assumption:
You want to enforce least-privilege by ensuring that new org members and newly created repos don’t get broad access by default.
Use this to verify what “org default permissions” currently are.
If you tell me your exact desired policy (e.g., default permission level and which actions to allow for members), I can give you a ready-to-run Python script tailored to it.
You want to enforce least-privilege by ensuring that new org members and newly created repos don’t get broad access by default.
1. Decide the Desired Default Permissions
Typical least-privilege setup:default_repository_permission:"read"or"none"members_can_create_repositories:false- Optionally, also restrict:
members_can_create_private_repositoriesmembers_can_create_internal_repositoriesmembers_can_create_public_repositoriesmembers_can_create_pagesmembers_can_create_public_pagesmembers_can_create_private_pages
2. Prepare a Token with Correct Scopes
-
Create a Fine-grained personal access token or classic PAT with:
admin:orgscope (for managing org settings)- If classic: also
read:orgif you want to read config first
-
Store it securely (e.g., environment variable
GITHUB_TOKEN).
3. Identify Your Organization Name
You need the login name of the org, e.g.:4. Install Dependencies
You can userequests (no extra install beyond pip install requests) or PyGithub. Below is with requests (simplest for IAM-like config changes):5. Python: Read Current Org Default Permissions
6. Python: Remediate (Set Least-Privilege Defaults)
7. Verify Remediation
Run the “read current settings” script again and confirm:default_repository_permissionmatches your target (e.g."read"or"none").- Repository creation and other default capabilities are aligned with policy.
8. (Optional) Make This Enforceable / Repeatable
- Put the script into CI/CD and:
- Run it periodically or
- Trigger on changes to a “org-policy” repo.
- Fail the pipeline if the current settings do not match your policy JSON.
If you tell me your exact desired policy (e.g., default permission level and which actions to allow for members), I can give you a ready-to-run Python script tailored to it.
Using Terraform
Using Terraform
default_repository_permission does not force resource replacement; it updates the organization setting in place.After you update your configuration, terraform plan should show a single ~ (update in-place) on github_organization_settings.org with default_repository_permission changing from its current value (e.g., "read") to "none".
