T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/log_scan.py:65
- Finding
- Unredacted Sensitive Log Content May Be Persisted in Audit Artifacts## Vulnerability Details **File Location**: `scripts/log_scan.py:65-78`, with persistence at `scripts/run_audit.py:70` **Vulnerability Type**: Plaintext sensitive-data exposure **Risk Level**: Medium ### Vulnerable Code ```python try: with f.open("r", errors="ignore") as fh: hits = [] for i, line in enumerate(fh): if i >= args.max_lines: break for regex, label in PATTERNS: if regex.search(line): hits.append({ "label": label, "line": i + 1, "text": line.strip()[:200] }) if hits: results.append({"file": str(f), "hits": hits}) except OSError: continue ``` The resulting data is written without further sanitization: ```python write_json(out_dir / "log_scan.json", log_scan) ``` ### Technical Analysis The log scanner stores the first 200 characters of every line matching terms such as `ERROR`, `Exception`, `Traceback`, `failed`, `timeout`, or `retry`. It does not detect or redact authorization headers, API keys, access tokens, passwords, URL credentials, connection strings, session identifiers, or personal information. Operational error messages frequently include request parameters, configuration values, authentication data, or serialized exceptions. Consequently, the generated `eval/log_scan.json` can contain plaintext copies of sensitive data. This behavior also conflicts with the secret-handling rules in `SKILL.md`, which state that only the presence and path of keys or tokens should be reported. ### Attack Path 1. A workspace log records a sensitive value on a line containing one of the configured failure keywords. 2. The Skill scans that log during an audit. 3. `log_scan.py` copies up to 200 characters of the matching line without redaction. 4. `run_audit.py` serializes the cap ...[truncated 603 chars]
- Remediation
- ## Remediation Suggestions - Apply centralized redaction before any log text is stored or printed. - Redact authorization headers, bearer tokens, API keys, passwords, cookies, private keys, URL user information, database connection strings, and known credential formats. - Prefer storing only the file path, line number, matched label, and a sanitized message. - Replace sensitive values with stable placeholders such as `[REDACTED_TOKEN]`. - Add tests containing representative secrets to verify that neither JSON nor console output contains the original values. - Consider making raw snippets opt-in and displaying an explicit warning when enabled.
