T09 · Insecure Skill Coding Practices
- Location
scripts/check-secrets.sh:46- Finding
Secret scanner exposes detected credentials in terminal and CI logs
- Content
View full analysis
Vulnerability Details
File Location:
scripts/check-secrets.sh, lines 46-54
Vulnerability Type: Sensitive information exposure through diagnostic output
Risk Level: MediumVulnerable Code:
bash for pattern in "${SECRET_PATTERNS[@]}"; do while IFS= read -r file; do [ -z "$file" ] && continue MATCH=$(grep -Pn "$pattern" "$file" 2>/dev/null || true) if [ -n "$MATCH" ]; then echo " 🚨 POSSIBLE SECRET in $file:" echo "$MATCH" | head -3 | sed 's/^/ /' ERRORS=$((ERRORS + 1)) fi done <<< "$FILES" doneTechnical Analysis
grep -Pnreturns the complete matching source line, including the value that triggered the secret-detection pattern. The script then prints up to three complete matches without redaction.The configured patterns cover passwords, bearer tokens, API keys, GitHub tokens, Slack tokens, AWS access-key identifiers, and JWT-like values. Consequently, a security control intended to prevent credential disclosure can reproduce credentials in less-protected output channels.
This is particularly dangerous in automated environments where standard output is retained in CI logs, agent transcripts, build logs, terminal recordings, or debugging artifacts. The script does not transmit the values itself, but downstream log retention can materially expand their exposure.
Attack Path
- A source or configuration file contains a hardcoded credential.
- A developer, AI agent, pre-commit hook, or CI job invokes
check-secrets.sh. grepcaptures the entire credential-bearing line.- The script writes that line to standard output.
- The execution environment stores or forwards the output.
- A user with access to those logs obtains the credential and may use its associated permissions.
An attacker able to contribute repository content could also place a real or planted c ...[truncated 606 chars]
- Remediation
View remediation
Remediation Suggestions
- Never print the complete matching line or secret value.
- Report only the file path, line number, and detected secret type.
- If context is necessary, replace the matched value with
[REDACTED]before output. - Prefer a scanner that returns structured metadata without returning secret contents.
- Add tests verifying that representative token and password values never appear in standard output or standard error.
- Document that historical CI logs generated by affected versions may contain secrets and should be reviewed, removed where possible, and followed by credential rotation.
- Restrict CI log access and retention as defense in depth.
