T09 · Insecure Skill Coding Practices
- Location
scripts/publish.sh:7- Finding
Unrestricted Git Staging May Publish Unintended Sensitive Files
- Content
View full analysis
Vulnerability Details
File Location:
scripts/publish.sh, lines 7-54
Vulnerability Type: Unrestricted file staging and remote publication
Risk Level: MediumVulnerable Code
bash SKILL_DIR="/Users/italks/WorkBuddy/Claw/.codebuddy/skills/crayfish-diary" REPO_URL="https://github.com/italks/crayfish-diary.git" if [ ! -d "$SKILL_DIR" ]; then exit 1 fi cd "$SKILL_DIR" if [ ! -d ".git" ]; then git init fi git add . if git diff --staged --quiet; then echo "No changes to commit" else git commit -m "Update diary skill" fi if ! git remote | grep -q "origin"; then git remote add origin "$REPO_URL" fi git branch -M main git push -u origin mainThe original script includes informational output and a multiline commit message between these operations; they do not alter the vulnerable staging and publication behavior.
Technical Analysis
The publishing script changes into a hard-coded directory outside the installed artifact path and executes
git add .. This recursively stages every eligible file beneath that directory rather than limiting publication to the intended release files.The audited project does not contain a
.gitignore, althoughPUBLISH.mdlists one as part of the expected package. Consequently, local configuration files, credentials, private notes, generated artifacts, or other unintended files placed beneath the target directory can be included in a commit. The subsequent unconditionalgit push -u origin mainpublishes the commit to the configured remote repository.The hard-coded path also means the script may operate on a different copy of the project than the copy from which the script is invoked. There is no validation of the repository root, staged file list, remote URL when an
originremote already exists, or sensitive-file patterns before publication.Attack Path
- A sensitive or unintended file is created or alre ...[truncated 1563 chars]
- Remediation
View remediation
Remediation Suggestions
-
Derive the repository directory from the script's own location instead of using an absolute user-specific path:
bash SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" SKILL_DIR="$(cd -- "$SCRIPT_DIR/.." && pwd)" cd -- "$SKILL_DIR" -
Add a restrictive
.gitignorecovering secrets and generated files, including.env, private keys, credential files, archives, caches, and editor metadata. -
Replace
git add .with an explicit release allowlist:bash git add -- \ SKILL.md README.md README_CN.md PUBLISH.md clawhub.json \ scripts/create_diary.py scripts/publish.sh \ assets/crayfish_icon.svg .gitignore -
Reject sensitive files before committing by inspecting the staged file list and running a secret scanner such as Gitleaks or TruffleHog.
-
Display
git diff --cached --name-statusand require explicit operator confirmation before committing or pushing. -
Validate that
git rev-parse --show-toplevelequals the intended project directory and verify the exactoriginURL even when that remote already exists. -
If unintended sensitive data has already been pushed, rotate exposed credentials immediately and remove the material from repository history using an appropriate history-rewriting procedure.
-
