Check ID: repository_default_branch_deletion_disabled
Provider: GitHub
Service: repository
Severity: MEDIUM
Categories: software-supply-chain
Resource type: NotDefined

What this check verifies

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.

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

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

References

Where this check fires

This check runs on every scheduled scan against your GitHub account. Findings appear at Cloud Security → Findings filterable by Check ID = repository_default_branch_deletion_disabled. To re-evaluate after a fix, hit Run now on the account’s schedule under Cloud Security → Schedules — the next scan re-checks this control and marks the finding fixed or keeps it persistent.
← Back to GitHub checks