T09 · Insecure Skill Coding Practices
- Location
scripts/emotion_tracker.py:20- Finding
Emotion records are stored in a predictable plaintext file with default permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/emotion_tracker.py, lines 20-43
Vulnerability Type: Plaintext storage of sensitive psychological data
Risk Level: MediumVulnerable Code
python DATA_FILE = "emotion_log.jsonl" def get_data_path(): script_dir = os.path.dirname(os.path.abspath(__file__)) return os.path.join(script_dir, DATA_FILE) def log_emotion(emotion, intensity, trigger="", body_feeling="", context=""): entry = { "timestamp": datetime.now().isoformat(), "date": datetime.now().strftime("%Y-%m-%d"), "emotion": emotion, "intensity": int(intensity), "trigger": trigger, "body_feeling": body_feeling, "context": context, } path = get_data_path() with open(path, "a", encoding="utf-8") as f: f.write(json.dumps(entry, ensure_ascii=False) + "\n") return entryTechnical Analysis
The tracker persistently records emotions, intensity levels, triggering events, bodily sensations, free-form context, and timestamps in
scripts/emotion_log.jsonl. This information can constitute sensitive psychological and behavioral data.The file is:
- Stored at a predictable location inside the installed skill directory.
- Written in unencrypted JSON Lines format.
- Created using the process's default permission behavior rather than explicit owner-only permissions.
- Retained indefinitely without configurable expiration or deletion controls.
- Written without first obtaining explicit consent for persistent storage.
The effective permissions depend on the runtime environment and its
umask. In a shared or permissively configured environment, another local account, service, backup process, indexing tool, or process with access to the project directory could read the accumulated records. Storing mutable user data inside the skill installation directory also mixes executable package conte ...[truncated 1633 chars]- Remediation
View remediation
Remediation Suggestions
- Make persistent storage opt-in and obtain explicit user consent before saving emotion records.
- Default to memory-only processing where long-term retention is not required.
- Store runtime data in a dedicated per-user application-data directory rather than inside the skill installation directory.
- Create the data file with owner-only permissions, such as mode
0600, using a secure file-opening method that does not depend solely on the ambientumask. - Verify and correct the permissions of existing files before appending data.
- Consider authenticated encryption at rest when the threat model includes administrators, backups, or filesystem compromise. Encryption keys must be managed separately from the data file.
- Add configurable retention periods, record-level deletion, complete-history deletion, and export controls.
- Minimize collection of free-form trigger, body-sensation, and context information unless it is necessary for the requested functionality.
- Clearly disclose the storage location, retained fields, retention period, and deletion procedure to the user.
- Handle malformed or partially written records safely without exposing their contents through diagnostic output.
