Repository forking should be disabled. Organizations should never allow private or internal repositories to be forked. If enabled, forking is allowed on private, internal, and public repositories. If disabled, forking is only allowed on public repositories. This setting is also configurable per-repository. By default, new organizations are configured to disallow the forking of private and internal repositories. https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-organization-settings/managing-the-forking-policy-for-your-organization
Leaving repository forking enabled organization-wide lets any member copy a private repository into a context you no longer control. Once forked, source code and embedded secrets can be pushed to a personal namespace, a public fork, or an unmanaged location, defeating branch protections and review gates that only apply to the upstream repository. Forks are a common path for accidental source exposure and for exfiltration by a compromised account, because the fork action itself is rarely monitored.
A private repository contains a committed legacy connection string. An engineer forks it to their personal account to experiment, and the fork is created as public. The connection string is now exposed on the public internet even though the original repository's visibility was never changed.
Disable forking for private and internal repositories at the organization level, and grant fork rights only where an open-source contribution workflow genuinely requires it. Pair this with secret scanning and push protection so that even an approved fork cannot leak credentials. DevOps Shield reports every organization where forking remains broadly enabled so you can close the gap consistently.
On GitHub this is the 'Allow forking of private repositories' organization setting. The equivalent intent on Azure DevOps is expressed through repository security and the 'Forks' permission, and on GitLab through project forking permissions, so do not assume disabling it in one provider covers the others. GitHub also evaluates this at both the organization and repository tiers, and the stricter of the two applies.
# Check the organization-level forking setting with the GitHub CLI
gh api /orgs/<your-org> --jq '.members_can_fork_private_repositories'
# Disable forking of private repositories org-wide
gh api -X PATCH /orgs/<your-org> -f members_can_fork_private_repositories=false
1. Go to Organization Settings. 2. In the 'Access' section of the sidebar, click Member privileges. 3. Under the 'Repository forking' section. 4. Ensure the 'Allow forking of private and internal repositories' setting is disabled.
{
"target": "GHOrganization",
"if": {
"allOf": [
{
"resource": "GHOrganization",
"property": "MembersCanForkPrivateRepositories",
"operator": "equals",
"value": false
}
]
},
"then": {
"effect": "Audit"
}
}
Copyright © DevOps Shield. All Rights Reserved. Privacy Policy | Cookie Policy | Terms and Conditions | v1.0.9