Description:

This control ensures that the protection configured on the default branch also applies to repository administrators and roles with permission to bypass branch protections. Administrators must follow the same pull request, review, and status check requirements as other contributors.

Note: This check ensures that default branch protection on GitHub repositories applies to administrators, so admins cannot bypass the branch rules. Note: This check requires a classic branch protection rule on the default branch with “Do not allow bypassing the above settings” enabled. Repositories protected only by rulesets will fail, because GitHub hides the ruleset bypass list from read-only apps.


Rationale:

If administrators can bypass branch protection, unreviewed or unauthorized changes can be pushed or merged directly into the default branch, either by mistake or through a compromised administrator account. Applying protection to administrators enforces segregation of duties and ensures that every change follows the approved process.


Impact:

  • Administrators can no longer bypass branch protection on the default branch.

  • Emergency changes require an approved bypass process or a temporary change to the protection configuration.

  • Enforces consistent review and approval for all contributors.

  • Supports segregation of duties and compliance requirements.


Default Value:

  • Classic branch protection rules: administrators and roles with the bypass branch protections permission can bypass the rule unless Do not allow bypassing the above settings is selected.

  • Rulesets: only users, teams, roles, or apps added to the ruleset’s Bypass list can bypass it. The Bypass list is empty by default.


Remediation:

Classic Branch Protection Rule:

Test Plan:

  1. Sign in to GitHub with administrative access to the repository.

  2. Navigate to the target repository.

  3. Select Settings.

  4. Under Code and automation, select Branches.

  5. Under Branch protection rules, verify that a rule matches the default branch (e.g., main).

  6. Click Edit next to the rule and verify that Do not allow bypassing the above settings is selected.

  1. If no matching rule exists or the setting is not selected, follow the Implementation Steps below to remediate the issue and repeat the test.


Implementation Steps:

  1. Sign in to GitHub with administrative access to the repository.

  2. Navigate to the target repository.

  3. Select Settings.

  4. Under Code and automation, select Branches.

  1. Next to Branch protection rules, click Add classic branch protection rule, or click Edit next to an existing rule.

  1. In Branch name pattern, enter the name of the default branch (e.g., main).

  1. Select Do not allow bypassing the above settings.

  1. Click Create (or Save changes for an existing rule) to apply the rule.


Backout Plan:

  1. Sign in to GitHub with administrative access to the repository.

  2. Navigate to the target repository.

  3. Select Settings.

  4. Under Code and automation, select Branches.

  5. Click Edit next to the applicable branch protection rule.

  6. Clear Do not allow bypassing the above settings.

  7. Click Save changes.

  8. Verify that administrators can bypass the rule according to the updated configuration.


References: