T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/release.sh:13
- Finding
- Release Script May Commit and Publish Unintended Local Files## Vulnerability Details **File Location**: `scripts/release.sh`, lines 13-30 **Vulnerability Type**: Unrestricted file staging and unsafe repository-context handling **Risk Level**: Medium ```bash # Check if git repo exists if [ ! -d ".git" ]; then echo "Initializing git repository..." git init git remote add origin $REPO_URL fi # Add all files git add . # Commit git commit -m "Release v$VERSION - Same Idea skill for finding resonating quotes" || true # Create tag git tag -a "v$VERSION" -m "Release version $VERSION" || true # Push git push origin main || git push origin master || true git push origin --tags || true ``` ### Technical Analysis The release script acts on the caller's current working directory instead of resolving and validating the Skill repository root. It then uses `git add .`, which recursively stages all files not excluded by Git configuration. If the current directory is not a Git repository, the script initializes it and assigns the hardcoded external GitHub repository as its remote. If the current directory is already a Git repository, the script accepts that repository and its existing `origin` without verifying its identity. In both cases, it may commit and push files unrelated to the Skill. The script does not provide an explicit release-file allowlist, inspect staged files for secrets, verify the destination remote, or request confirmation before transmission. The `|| true` clauses also suppress commit, tag, and push failures, potentially concealing partial or unexpected release behavior. ### Attack Path 1. A user invokes `scripts/release.sh` while the current working directory is incorrect, or sensitive untracked files are present in the intended repository. 2. The script either uses the existing Git repository or initializes the current directory as a new repository. 3. `git add .` stages all non-ignored files under that directory, potentially including cre ...[truncated 1135 chars]
- Remediation
- ## Remediation Suggestions 1. Resolve the repository root from the script's own location and change to it before executing Git commands: ```bash SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd -- "$SCRIPT_DIR/.." && pwd)" cd -- "$REPO_ROOT" ``` 2. Abort unless the directory is the expected repository. Validate both the repository root and normalized remote URL before staging or pushing: ```bash test "$(git rev-parse --show-toplevel)" = "$REPO_ROOT" || exit 1 test "$(git remote get-url origin)" = "$REPO_URL" || exit 1 ``` 3. Do not initialize an arbitrary directory automatically. Repository initialization and remote configuration should be separate, explicit setup operations. 4. Replace `git add .` with an explicit allowlist of release files, for example: ```bash git add -- SKILL.md README.md CONTRIBUTING.md DESIGN.md RELEASE_NOTES.md scripts/find_similar.py ``` 5. Verify `.gitignore` coverage for environment files, credentials, editor state, local vault data, build artifacts, and temporary files. 6. Display the staged file list and abort on unexpected paths: ```bash git diff --cached --name-only ``` 7. Add automated secret scanning before committing, and require explicit user confirmation before pushing. 8. Remove broad `|| true` error suppression. Handle expected conditions individually and terminate on unexpected commit, tagging, or push failures.
