T09 · Insecure Skill Coding Practices
- Location
- SKILL.md:219
- Finding
- Overbroad Git staging and destructive preview branch force-push<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 219–223 **Vulnerability Type**: Overbroad file staging and destructive Git operation **Risk Level**: Medium ### Vulnerable Code ```bash cd ~/projects/dev-blog git checkout -B preview git add -A git commit -m "Add blog post: {title}" git push origin preview --force ``` ### Technical Analysis The publishing workflow stages the entire repository with `git add -A`. This includes all modified, deleted, and untracked files that are not excluded by Git ignore rules, rather than only the generated blog posts and associated image assets. Consequently, unrelated drafts, configuration files, local artifacts, or sensitive files can be included in the deployment commit. The subsequent unconditional `git push origin preview --force` replaces the remote preview branch tip without checking whether the branch contains concurrent changes. These operations exceed the minimum privileges and change scope needed to publish a specific blog post. The workflow only needs to stage the generated `.mdoc` files and approved image assets, and it normally does not need to rewrite remote branch history. ### Attack Path 1. An attacker, another local process, or an unrelated development task places a sensitive or malicious file in the `dev-blog` working tree, or modifies an existing tracked file. 2. The Skill begins the documented publishing workflow without first requiring a clean working tree. 3. `git add -A` stages the unrelated change along with the intended blog files. 4. The commit permanently includes all staged content. 5. `git push origin preview --force` publishes the commit and overwrites the current remote preview branch tip. 6. The unrelated content may become accessible through the preview deployment or repository history, while concurrent remote work may be discarded. This path requires write access to the local repository or the ability to influence its working tree. It does not independently grant ...[truncated 812 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require a clean working tree before making generated changes: ```bash test -z "$(git status --porcelain)" || { echo "Refusing to publish from a non-clean working tree." exit 1 } ``` 2. Stage only the files created or modified for the current post: ```bash git add -- \ "src/content/blog/ko/${slug}.mdoc" \ "src/content/blog/en/${slug}.mdoc" \ "src/assets/${approved_image_name}.webp" ``` 3. Review the exact staged file list and patch before committing: ```bash git diff --cached --name-status git diff --cached ``` 4. Reject staged paths outside an explicit allowlist such as `src/content/blog/` and `src/assets/`. 5. Replace the unconditional force-push with a normal push: ```bash git push origin preview ``` 6. If branch replacement is genuinely required, obtain explicit user approval and use `--force-with-lease` rather than `--force`: ```bash git push origin preview --force-with-lease ``` 7. Confirm that no secrets or local configuration files are staged before creating the commit. ]]>
