T09 · Insecure Skill Coding Practices
- Location
SKILL.md:16- Finding
Unqualified Git Stash Restoration Can Apply and Remove an Unrelated Stash
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 16-37
Vulnerability Type: Unsafe Git state handling
Risk Level: MediumVulnerable Code
bash git stash push -m "temp stash before rebase $(date +%Y%m%d%H%M%S)"bash git pull --rebasebash git stash popTechnical Analysis
The workflow runs
git stash popwithout verifying that the precedinggit stash pushcreated a new stash and without identifying the exact stash generated by this invocation.When the working tree has no eligible tracked changes,
git stash pushdoes not create a new stash entry. If the repository already contains an older stash, the unqualifiedgit stash popoperates on the currentstash@{0}. Consequently, it may apply and remove a pre-existing stash unrelated to the workflow.The sequence also lacks explicit success checks between the state-changing commands. Restoration should not proceed if stashing or
git pull --rebasefails. Because the Skill is activated by a broad conversational trigger and modifies repository state, the absence of confirmation and state validation increases the likelihood of accidental invocation and repository disruption.Attack Path
- A repository contains a pre-existing stash created by the user or another process.
- The tracked working tree has no changes eligible for a new stash.
- The user invokes the Skill through one of its matching work-start phrases.
git stash pushcreates no new stash entry.- The workflow performs
git pull --rebase. - The unqualified
git stash popselects the existingstash@{0}. - The unrelated stash is applied to the working tree and, if application succeeds, removed from the stash list.
Impact Assessment
The issue does not grant additional operating-system privileges or establish persistence. Its scope is the active Git repository and the files represented by the selected stash.
Exploitation ...[truncated 308 chars]
- Remediation
View remediation
Remediation Suggestions
- Ask for explicit user confirmation before running repository-mutating Git commands.
- Validate that the current directory is the intended Git repository and display its root, branch, and remote before proceeding.
- Capture the stash list or stash object identifier before and after
git stash pushand verify that this invocation created a new entry. - Restore only the exact stash created by this workflow. Do not use an unqualified
git stash pop. - Prefer applying the verified stash first and dropping it only after successful application:
bash before="$(git rev-parse -q --verify refs/stash 2>/dev/null || true)" git stash push -m "temp stash before rebase $(date +%Y%m%d%H%M%S)" || exit 1 after="$(git rev-parse -q --verify refs/stash 2>/dev/null || true)" created_stash="" if [ -n "$after" ] && [ "$after" != "$before" ]; then created_stash="$after" fi git pull --rebase || exit 1 if [ -n "$created_stash" ]; then git stash apply "$created_stash" || exit 1 git stash drop "$created_stash" fi - Stop immediately if stashing or rebasing fails. If a rebase conflict occurs, preserve the verified stash and instruct the user to resolve or abort the rebase manually.
- Clearly report when no new stash was created and skip all restoration commands in that case.
