T09 · Insecure Skill Coding Practices
- Location
SKILL.md:107- Finding
Branch Protection Remediation Can Overwrite Stronger Existing Controls
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 107-115
Vulnerability Type: Unsafe replacement of security configuration
Risk Level: HighVulnerable Code
bash # Apply protection to a repo gh api -X PUT "repos/$REPO/branches/main/protection" \ -f required_pull_request_reviews='{"required_approving_review_count":2,"dismiss_stale_reviews":true,"require_code_owner_reviews":true}' \ -f required_status_checks='{"strict":true,"contexts":["ci/test","ci/lint"]}' \ -f enforce_admins=true \ -f restrictions=null \ -F allow_force_pushes=false \ -F allow_deletions=falseTechnical Analysis
The documented remediation uses an authenticated
PUTrequest to replace branch-protection settings with a fixed template. It does not retrieve and merge the repository's existing configuration before making the change.In particular:
- Existing required status-check contexts are replaced with only
ci/testandci/lint. restrictions=nullexplicitly removes existing user, team, or application push restrictions.- The target branch is hard-coded as
main, although the audit process discovers each repository's actual default branch. - The command lacks a preview, comparison, or confirmation step.
- Repository-specific requirements are not preserved.
A repository may already require stronger or additional checks, such as security scanning, integration tests, deployment approval, provenance verification, or organization-specific policy checks. Replacing those settings can weaken the repository despite the command being presented as a security fix.
Attack Path
- A repository has existing branch protection with organization-specific status checks or restricted push actors.
- The audit report recommends applying the documented remediation.
- An operator with repository administration privileges executes the generated
gh api -X PUTcommand. - GitHub replaces the existin ...[truncated 1214 chars]
- Existing required status-check contexts are replaced with only
- Remediation
View remediation
Remediation Suggestions
- Retrieve the current branch-protection configuration before making any modification.
- Use the repository's discovered default branch rather than hard-coding
main. - Merge approved changes into the existing configuration instead of replacing all settings with a static template.
- Preserve all existing required status-check contexts unless an authorized operator explicitly approves their removal.
- Preserve existing push restrictions. Do not set
restrictionstonullunless broadening push access is an intentional, separately confirmed action. - Generate a before-and-after configuration diff and require explicit operator confirmation.
- Validate that the configured status-check names exist in the target repository.
- Use a correctly typed JSON request body and verify the resulting configuration with a follow-up API request.
- Add a dry-run mode and process repositories individually so that an error cannot weaken protections across an entire organization.
- Abort remediation if the existing configuration cannot be retrieved or parsed reliably.
