GitHub repository default branch blocks force pushes through branch protection.
Evaluates whether the default branch permits force pushes. This protection can be enforced through classic branch protection or repository rulesets.
Risk
Allowing force pushes on the default branch erodes integrity and auditability by enabling history rewrites and deletion of commits. Attackers or insiders can inject unreviewed code, bypass reviews and status checks, and corrupt PRs, risking supply-chain compromise and reduced availability.
prowler github --checks repository_default_branch_disallows_force_push
Recommendation
Disable Allow force pushes on the default branch. Enforce PR-based changes with required reviews and status checks, require signed commits and linear history, and restrict bypass to minimal actors. Apply protections to admins too to uphold least privilege and defense in depth.
Remediation
- In GitHub, open the repository and go to Settings
- In the sidebar, click Branches
- Edit the protection rule for the default branch (or Add rule with the default branch name)
- Ensure Allow force pushes is unchecked/disabled
- Click Save changes
Source Code
Resource Type
NotDefined
References
- https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/managing-a-branch-protection-rule
- https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches#allow-force-pushes
- https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets