T09 · Insecure Skill Coding Practices
- Location
scripts/update.sh:12- Finding
Unconfirmed Destructive Repository Cleanup During Self-Update
- Content
View full analysis
Vulnerability Details
File Location:
scripts/update.sh, lines 12–15
Vulnerability Type: Destructive update operation without confirmation or dry-run protection
Risk Level: MediumComplete Code Snippet
bash cd "$(dirname "$0")/.." git reset --hard HEAD 2>/dev/null git clean -fd 2>/dev/null git pull 2>/dev/nullTechnical Analysis
The self-update script changes into the Skill repository and unconditionally performs two destructive Git operations before pulling updates:
git reset --hard HEADdiscards modifications to tracked files in the index and working tree.git clean -fdrecursively deletes untracked files and directories.
The script provides no confirmation prompt, explicit destructive-operation flag, dry-run mode, or backup mechanism. Redirecting standard error to
/dev/nullfurther obscures failures and makes it harder for the operator to understand which update step failed.This behavior conflicts with the preservation-oriented update procedure documented in
references/self-update-imagine.md:5, which specifies:text cd {agent_root}/skills/ocas-imagine && git stash && git pull origin main && git stash popThe executable implementation therefore expands a routine update operation into an irreversible local cleanup that is not disclosed by its usage message, which only states that it pulls the latest version while preserving local data.
Attack Path
- The update helper is invoked directly with
bash scripts/update.sh, or through the self-update mechanism described by the Skill. - The script changes into the repository root.
git reset --hard HEADsilently removes tracked local modifications.git clean -fdsilently removes all untracked files and directories beneath that repository.- Only after this deletion does the script run
git pull. - Any local customization or untracked data stored in the Skill repository is lost without an interactive approval step or recoverable backup.
No ...[truncated 922 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the unconditional
git reset --hardandgit clean -fdoperations from the normal update path. - Implement the documented preservation flow using
git stash, an explicit upstream pull, andgit stash pop, while handling merge conflicts safely. - If cleanup is genuinely required, place it behind an explicit option such as
--discard-local-changes. - Before destructive cleanup:
- Show the affected tracked and untracked files.
- Require explicit user confirmation.
- Support a dry-run mode.
- Create a recoverable backup or archive.
- Validate that the resolved repository directory is the intended Skill root before running Git commands.
- Stop suppressing all Git errors. Return clear failures and abort immediately when a step fails.
- Update the usage text and Skill documentation so the actual effects are accurately disclosed.
- Remove the unconditional
