T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/main.py:127
- Finding
- Detected credentials are exposed in terminal and JSON reports<![CDATA[ ## Vulnerability Details **File Location**: `scripts/main.py:127-139`, `scripts/main.py:257-273`, and `scripts/main.py:277-283` **Vulnerability Type**: Plaintext sensitive-data exposure **Risk Level**: Medium ### Vulnerable Code ```python # scripts/main.py:127-139 for pattern_name, pattern_regex in patterns.items(): matches = re.finditer(pattern_regex, content, re.IGNORECASE) for match in matches: issues.append({ "severity": "high" if "key" in pattern_name or "token" in pattern_name else "medium", "type": pattern_name, "commit": commit_hash, "date": date, "author": author, "file": filename, "match": match.group(0)[:50] + ("..." if len(match.group(0)) > 50 else ""), "line": content[:match.start()].count('\n') + 1, "remediation": f"Remove secret from history using git filter-branch or BFG" }) ``` ```python # scripts/main.py:257-273 if args.json: output = { "repository": os.path.abspath(path), "scan_date": datetime.now(timezone.utc).isoformat(), "repository_info": repo_info, "security_issues": secrets, "large_files": large_files, "health_metrics": health, "summary": { "total_security_issues": len(secrets), "total_large_files": len(large_files), "stale_branches": len(health["stale_branches"]), "binary_files": health["binary_files"], } } print(json.dumps(output, indent=2, default=str)) ``` ```python # scripts/main.py:277-283 if secrets: print(f"\n⚠️ SECURITY ISSUES FOUND ({len(secrets)}):") for i, issue in enumerate(secrets[:5], 1): print(f"{i}. {issue['severity'].upper()}: {issue['type']} found in commit {issue['commit'][:8]}") print(f" File: {issue['file']}") print(f" Match: {issue['match']}") print(f" Remediation: {issue['remediation']}") ``` ### Tech ...[truncated 2920 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the raw `match` value from issue records. Report only the pattern type, commit, file, and line number. 2. If correlation is required, replace the secret with an irreversible fingerprint such as a truncated SHA-256 digest computed locally. 3. If a visual indicator is necessary, use strict masking that does not reveal meaningful credential material, such as `[REDACTED]`. Avoid preserving prefixes or suffixes unless a particular credential format has been reviewed for safe disclosure. 4. Ensure both human-readable and JSON output use the same centralized redaction function so future output formats cannot accidentally bypass masking. 5. Add automated tests containing representative AWS, GitHub, Stripe, password, SSH-private-key, and generic-token fixtures. Assert that no complete fixture secret or substantial substring appears in output. 6. Document that audit reports contain sensitive repository metadata and should receive restrictive file permissions, limited retention, and access controls. 7. Recommend immediate credential rotation whenever a potential secret is found, because removing it from Git history alone does not invalidate it. A safer issue record would resemble: ```python issues.append({ "severity": "high" if "key" in pattern_name or "token" in pattern_name else "medium", "type": pattern_name, "commit": commit_hash, "date": date, "author": author, "file": filename, "match": "[REDACTED]", "line": content[:match.start()].count("\n") + 1, "remediation": ( "Rotate the credential immediately and remove it from Git history." ), }) ``` ]]>
