Check provider logo

Repository denies default branch deletion

repository_default_branch_deletion_disabled

Severitymedium
Servicerepository
by Prowler

GitHub repository default branch have branch protections or rulesets with Allow deletions disabled.

Risk

Permitting default branch deletion undermines availability by breaking CI/CD, releases, and PR targets.

It also impacts integrity: the canonical ref can be removed, enabling history tampering, branch hijacking, and harder audits/rollbacks.

Run this check with Prowler CLI

prowler github --checks repository_default_branch_deletion_disabled

Recommendation

Disable deletions on the default branch using branch protection or rulesets (Allow deletions=false). Apply controls to admins, minimize bypass lists, and enforce least privilege. Combine with required pull requests and status checks for defense in depth.

Remediation

CLI

gh api -X DELETE repos/<OWNER>/<REPO>/branches/<DEFAULT_BRANCH>/protection/allow_deletions

Terraform
Other
  1. In GitHub, open the repository and go to Settings > Branches
  2. Edit the branch protection rule for the default branch (or Add rule if none exists)
  3. Ensure "Allow deletions" is unchecked
  4. Click Save changes

Source Code

Resource Type

NotDefined

References