T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/feedback_collector.py:57
- Finding
- Plaintext Storage of User Identifiers and Complete Financial Conversations## Vulnerability Details **File Location**: `scripts/feedback_collector.py`, lines 57-79 **Vulnerability Type**: Plaintext sensitive-data storage without access-control or retention safeguards **Risk Level**: High ### Vulnerable Code ```python log_entry = { "timestamp": datetime.now().isoformat(), "user_id": user_id, "pet_type": pet_type, "question": question, "response": response, "feedback": feedback, "helpful": helpful, "metadata": metadata or {} } log_file = self.feedback_dir / f"{datetime.now().strftime('%Y-%m-%d')}.jsonl" with open(log_file, 'a', encoding='utf-8') as f: f.write(json.dumps(log_entry, ensure_ascii=False) + '\n') ``` ### Technical Analysis The feedback collector stores the user's identifier, complete question, complete Agent response, free-form feedback, and arbitrary metadata in an unencrypted JSONL file. In an investment-assistant context, questions and metadata may contain holdings, investment amounts, risk preferences, or other sensitive financial information. The file is created using the process's default permissions. The implementation does not explicitly apply a restrictive mode such as `0600`, encrypt records, redact sensitive values, separate records by user, establish a retention period, or verify that the user consented to persistent conversation logging. The predictable date-based filename also makes stored records easy to locate. Any process or account with read access to the project data directory can inspect all interactions recorded for that date. ### Attack Path 1. A user asks a question containing holdings, financial circumstances, or another sensitive detail. 2. The collector receives the complete question and response through `log_interaction`. 3. The collector writes the user ID and complete conversation to a predictable plaintext JSONL file. 4. A local user, compromised process, backup service, or synchronization utility ...[truncated 712 chars]
- Remediation
- ## Remediation Suggestions 1. Obtain explicit, informed user consent before storing conversation content. 2. Minimize collection by storing aggregate metrics rather than complete questions and responses. 3. Redact account numbers, security identifiers, holdings, monetary values, personal identifiers, and credentials before persistence. 4. Use pseudonymous, validated user identifiers rather than directly identifying values. 5. Create files atomically with owner-only permissions, such as mode `0600`, and ensure the parent directory is mode `0700`. 6. Encrypt sensitive records at rest using a key held outside the project directory. 7. Isolate each user's records and enforce authorization whenever records are read or exported. 8. Define and enforce a short retention period with secure deletion. 9. Restrict arbitrary metadata to a documented schema and reject unexpected sensitive fields. 10. Prevent conversation logs from being included in cloud synchronization or backups unless the user separately authorizes that transfer.
