T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/publish-template.sh:23
- Finding
- Sensitive Files Can Be Committed and Uploaded to GitHub<![CDATA[ ## Vulnerability Details **File Location**: `scripts/publish-template.sh:23-39` **Vulnerability Type**: Sensitive-data exposure through unsafe Git staging and repository publication **Risk Level**: High ### Vulnerable Code ```bash sensitive_files=$(find . -maxdepth 2 \( -name ".env*" -o -name "*.pem" -o -name "*.key" -o -name "*.secret" -o -name "id_rsa*" \) 2>/dev/null || true) if [ -n "$sensitive_files" ]; then echo "⚠️ Potentially sensitive files detected:" echo "$sensitive_files" echo "" read -rp "Continue anyway? (y/N) " confirm [[ "$confirm" =~ ^[Yy]$ ]] || exit 1 fi git add -A git commit -m "Initial commit: agent context system template" 2>/dev/null || true gh repo create "$GH_USER/$REPO_NAME" \ --private \ --source=. \ --remote=origin \ --description "Template: persistent local-only memory for AI coding agents" \ --push ``` ### Technical Analysis The script searches for several sensitive filename patterns, but detection only produces an overridable warning. If the user confirms, `git add -A` stages the entire working tree, including the files that triggered the warning. The resulting commit is then uploaded through `gh repo create --push`. The check is also incomplete: - It only searches to a maximum depth of two directories. - It relies on a limited list of filename patterns. - It does not inspect file contents for credentials or tokens. - It does not verify the final staged-file list. - It does not enforce an allowlist of files required for the template. - It suppresses commit errors, making the resulting repository state less transparent. Creating a private repository does not eliminate the exposure. The files are still transferred to GitHub, become accessible to authorized repository users and integrations, and remain in Git history unless the history is explicitly rewritten. The static pre-scan characterized this behavior as writing to SSH key files. That characterization is inaccurate: th ...[truncated 1656 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Fail closed when sensitive files are detected.** Do not permit an interactive override in the automated publishing script. 2. **Replace `git add -A` with an explicit allowlist**, for example by staging only the documented template files and directories. 3. **Inspect the staged set before committing** using `git diff --cached --name-only` and abort if any path is outside the allowlist. 4. **Scan staged contents for secrets**, not only filenames. Use a maintained secret scanner and treat any match as a blocking error. 5. **Verify ignore rules before staging.** Ensure `.env*`, private-key formats, credential files, local scratchpads, and tool-specific local configuration are excluded. 6. **Require a clean, dedicated repository root.** Abort when unrelated files or pre-existing staged changes are present. 7. **Display the exact files that will be uploaded** and require explicit confirmation after the final staged-file validation. 8. **Document incident response.** If a secret is committed, revoke or rotate it immediately and rewrite the repository history; deleting it in a later commit is insufficient. ]]>
