T09 · Insecure Skill Coding Practices
Warning
- Location
- incident_capture.py:218
- Finding
- Plaintext Collection and Retention of Sensitive Workspace and Agent-Memory Content<![CDATA[ ## Vulnerability Details **File Location**: `incident_capture.py:218-252`, `incident_capture.py:139-145`, `config_example.json:20-38`, `config_example.py:30-42`, `config_example.py:209` **Vulnerability Type**: Plaintext sensitive-data collection and storage **Risk Level**: Medium ### Vulnerable Code Default configuration includes source code, configuration, logs, JSON data, Markdown documents, and agent-memory files without excluding common secret-bearing files: ```json "EXCLUDE_PATTERNS": [ "__pycache__/*", "*.pyc", ".git/*", "node_modules/*", "incident_data/*", "*.tmp", "*.swp" ], "INCLUDE_PATTERNS": [ "*.py", "*.md", "*.txt", "*.json", "*.jsonl", "*.yaml", "*.yml", "*.toml", "*.cfg", "*.ini", "*.log" ], "LOG_FILES": [ "*.log", "memory/*.md", "*.jsonl" ] ``` The snapshot implementation reads matching files verbatim: ```python for dirpath, dirnames, filenames in os.walk(self.root): # Skip excluded directories dirnames[:] = [ d for d in dirnames if not _matches_any(os.path.join(dirpath, d) + "/", self.exclude) ] for fname in filenames: full_path = os.path.join(dirpath, fname) rel_path = os.path.relpath(full_path, self.root) if not _matches_any(rel_path, self.include): continue if _matches_any(rel_path, self.exclude): continue try: stat = os.stat(full_path) except OSError: continue size = stat.st_size total_size += size if total_size > self.max_snapshot_size: raise RuntimeError( f"Snapshot exceeds MAX_SNAPSHOT_SIZE ({self.max_snapshot_size} bytes). " f"Adjust INCLUDE_PATTERNS or MAX_SNAPSHOT_SIZE." ) fhash = _file_hash(full_path) content = None if size <= self.max_file_size: try: with open(full_path, "r", encoding="utf-8", errors="replace") as fh: ...[truncated 2852 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Make metadata-only capture the default and require explicit opt-in before storing file content. 2. Add secure default exclusions for: - `.env` and `.env.*` - Private keys and certificates - Credential and token files - Cloud-provider configuration directories - Agent memory and conversation history - Authentication cookies and session files 3. Provide an explicit allowlist of approved capture paths rather than relying primarily on extension-based matching. 4. Run secret redaction before serialization. Replace secret values with irreversible placeholders while preserving enough context for forensic analysis. 5. Ensure detection prevents storage rather than merely recording that a pattern was found. 6. Create data directories with mode `0700` and snapshot, incident, and report files with mode `0600` where supported. 7. Support encryption at rest with keys stored outside the snapshot directory. 8. Warn users when the selected configuration includes logs, memory, configuration, or other likely sensitive content. 9. Add configurable retention periods and secure deletion guidance. 10. Document that snapshot and report files must not be committed, synchronized, or shared without review. ]]>
