Check provider logo

Repository default branch denies force pushes

repository_default_branch_disallows_force_push

Severityhigh
Servicerepository
by Prowler

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.

Run this check with Prowler CLI

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

Terraform
Other
  1. In GitHub, open the repository and go to Settings
  2. In the sidebar, click Branches
  3. Edit the protection rule for the default branch (or Add rule with the default branch name)
  4. Ensure Allow force pushes is unchecked/disabled
  5. Click Save changes

Source Code

Resource Type

NotDefined

References