T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/publish-template.sh:23
- Finding
- Sensitive Files Can Be Staged and Uploaded to GitHub<![CDATA[ ## Vulnerability Details **File Location**: `scripts/publish-template.sh:23-40` **Vulnerability Type**: Sensitive data exposure through unsafe repository publishing **Risk Level**: Medium ### 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 attempts to identify sensitive files, including environment files, PEM files, private keys, secrets, and SSH private-key filenames. It does not write to or modify SSH keys; the pre-scan warning is caused by filename matching. The security issue is that detection only produces a warning. A user can continue despite detected secrets, after which `git add -A` stages all non-ignored content and `gh repo create --push` uploads the resulting commit. The scan is also incomplete: - It only searches to a maximum depth of two directories. - It relies on a limited set of filename patterns. - It does not inspect the actual staged file set. - It does not scan file contents for tokens or credentials. - It does not explicitly verify that `.agents.local.md` is ignored. - It stages the entire working tree instead of an allowlist of intended template files. Creating the repository as private reduces public exposure, but uploaded secrets remain available to repository collaborators, installed GitHub applications, automation, backups, and anyone who later receives access. Se ...[truncated 1372 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Abort unconditionally when potentially sensitive files are found instead of offering a continuation prompt. 2. Replace `git add -A` with an explicit allowlist of files required by the template. 3. Verify before staging that `.agents.local.md` and other local context files are covered by `.gitignore`. 4. Inspect the complete staged set using `git diff --cached --name-only` before committing. 5. Scan staged file contents with a secret scanner such as Gitleaks or TruffleHog. 6. Search the entire repository rather than limiting detection to two directory levels. 7. Add broader checks for common credential locations and filenames. 8. Display the exact staged files and require explicit confirmation immediately before the push. 9. If a secret has already been uploaded, revoke or rotate it immediately and remove it from repository history using an appropriate history-rewriting tool. ]]>
