T09 · Insecure Skill Coding Practices
- Location
SKILL.md:106- Finding
Overbroad Git Staging Can Commit Unrelated Sensitive Files
- Content
View full analysis
: " ``` ``` ### Technical Analysis The skill instructs the agent to run `git add -A` after every operation batch. This command stages all modifications, deletions, and untracked files throughout the current Git working tree, including files unrelated to the wiki operation. The intended task only requires changes to designated wiki content and generated reports. Repository-wide staging violates least-scope principles and does not provide an inspection or user-confirmation step before creating a commit. Although this does not directly escalate operating-system privileges, it can cause sensitive or unrelated repository content to be recorded permanently in Git history. Because removing a secret from the working tree does not remove it from existing commits, accidental inclusion may persist and later be disclosed if the repository is shared or pushed. ### Attack Path 1. A sensitive or unrelated file exists in the repository, such as an environment file, credential export, private note, generated token, or another developer's unfinished work. 2. Alternatively, an attacker or untrusted process places a crafted file anywhere inside the Git working tree. 3. The skill performs a legitimate wiki operation. 4. Following `SKILL.md`, the agent executes `git add -A`. 5. Git stages the sensitive or attacker-controlled file together with the intended wiki changes. 6. The chained `git commit` records all staged content without requiring review or explicit user approval. 7. If the repository is later pushed, synchronized, archived, or shared, the unintended content may be exposed. ### Impact Assessment The affected scope is the entire Git working tree rather than only the ...[truncated 703 chars]- Remediation
View remediation
git status --short git diff --cached --stat git diff --cached ``` 4. Require explicit user confirmation after displaying the staged-file list and before running `git commit`. 5. Check for sensitive file types and names, including `.env` files, private keys, credential exports, tokens, archives, and temporary files. 6. Maintain an appropriate `.gitignore`, but do not treat it as a substitute for path-scoped staging and review. 7. Avoid automatic commits when the working tree already contains unrelated changes. Detect this condition before the operation and ask the user how to proceed. ]]>
