T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:107
- Finding
- Branch Protection Remediation Can Overwrite Stronger Existing Controls## Vulnerability Details **File Location**: `SKILL.md`, lines 107-115 **Vulnerability Type**: Unsafe replacement of security configuration **Risk Level**: High ### Vulnerable 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=false ``` ### Technical Analysis The documented remediation uses an authenticated `PUT` request 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/test` and `ci/lint`. - `restrictions=null` explicitly 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 1. A repository has existing branch protection with organization-specific status checks or restricted push actors. 2. The audit report recommends applying the documented remediation. 3. An operator with repository administration privileges executes the generated `gh api -X PUT` command. 4. GitHub replaces the existin ...[truncated 1214 chars]
- Remediation
- ## Remediation Suggestions 1. Retrieve the current branch-protection configuration before making any modification. 2. Use the repository's discovered default branch rather than hard-coding `main`. 3. Merge approved changes into the existing configuration instead of replacing all settings with a static template. 4. Preserve all existing required status-check contexts unless an authorized operator explicitly approves their removal. 5. Preserve existing push restrictions. Do not set `restrictions` to `null` unless broadening push access is an intentional, separately confirmed action. 6. Generate a before-and-after configuration diff and require explicit operator confirmation. 7. Validate that the configured status-check names exist in the target repository. 8. Use a correctly typed JSON request body and verify the resulting configuration with a follow-up API request. 9. Add a dry-run mode and process repositories individually so that an error cannot weaken protections across an entire organization. 10. Abort remediation if the existing configuration cannot be retrieved or parsed reliably.
