T09 · Insecure Skill Coding Practices
- Location
SKILL.md:173- Finding
Unrestricted Repository-Wide Staging May Commit Sensitive Files
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 173–186
Vulnerability Type: Unrestricted staging of all repository changes
Risk Level: Mediumpython def commit(self, message: str = None) -> dict: """提交变更""" if not message: message = self.generate_commit_message() # Stage all self._run(["git", "add", "-A"]) # Commit result = self._run(["git", "commit", "-m", message]) return { "success": result["success"], "message": message, "output": result.get("stdout", ""), }Technical Analysis
The
commit()method executesgit add -A, which stages every tracked modification, deletion, and untracked file in the repository. It does not restrict staging to files selected by the user, display the final staged set, filter likely secret files, or request confirmation before creating the commit.The method also ignores the result of the staging command. Consequently, it proceeds to
git commiteven if staging failed or only partially achieved the intended state. Although commands are passed as argument lists and therefore do not exhibit shell-command injection, the repository-wide staging behavior violates least-surprise and safe-change-control principles.Attack Path
- An attacker, compromised development tool, or unrelated process creates a sensitive or unintended file inside the repository, such as
.env, a private key, credentials, or generated artifacts. - The file remains untracked and may not be noticed by the user.
- The user invokes
GitHelper.commit()to commit an unrelated intended change. git add -Astages the sensitive file along with all other repository changes.git commitrecords the staged file without requiring review or confirmation.- If the resulting commit is later pushed, the sensitive content may be disclosed to everyone with access to the remote repository and may persist in Git history.
Impact Assessment
The method operates ...[truncated 627 chars]
- An attacker, compromised development tool, or unrelated process creates a sensitive or unintended file inside the repository, such as
- Remediation
View remediation
Remediation Suggestions
- Do not stage the entire repository implicitly. Require an explicit list of files or stage only files the user has selected.
- Show the exact staged file set and require confirmation before committing.
- Add deny rules for common sensitive files and patterns, including
.env*, private keys, credential files, tokens, and cloud configuration secrets. - Respect
.gitignore, but do not treat it as the only secret-control mechanism. - Inspect staged content with secret-scanning controls before committing.
- Check the result of
git addand abort immediately if staging fails. - Consider committing only already-staged changes by default, leaving staging as a separate, explicit operation.
- Return both staging and commit errors so callers can accurately determine what occurred.
