T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/config_manager.py:133
- Finding
- Plaintext Storage of Feishu Credentials and Private WhatsApp Messages<![CDATA[ ## Vulnerability Details **File Location**: `scripts/config_manager.py:133-143`, `scripts/config_manager.py:213-217` **Vulnerability Type**: Plaintext sensitive-data storage with unrestricted default file permissions **Risk Level**: High ### Vulnerable Code ```python def save_whatsapp_config(self): try: with open(self.whatsapp_config_path, 'w', encoding='utf-8') as f: json.dump(self.whatsapp_config, f, ensure_ascii=False, indent=2) def save_feishu_config(self): try: with open(self.feishu_config_path, 'w', encoding='utf-8') as f: json.dump(self.feishu_config, f, ensure_ascii=False, indent=2) ``` ```python with open(self.matched_messages_path, 'w', encoding='utf-8') as f: json.dump({ "last_updated": datetime.now().isoformat(), "messages": existing_messages }, f, ensure_ascii=False, indent=2) ``` ### Technical Analysis The configuration manager serializes Feishu application secrets, tenant access tokens, table tokens, WhatsApp target metadata, and matched WhatsApp messages directly into plaintext JSON files. Files created through ordinary `open(..., 'w')` calls inherit permissions determined by the process umask. The application does not explicitly enforce owner-only permissions, encrypt message contents, or separate credentials from general configuration. The matched-message cache contains message content, sender details, chat identifiers, timestamps, and potentially attachment or chat-link metadata. The credential file may contain reusable Feishu API credentials. Adding these locations to `.gitignore` only reduces accidental source-control commits and does not protect the data from local users, backup systems, malware, or other processes. ### Attack Path 1. A user configures valid Feishu credentials and starts monitoring WhatsApp conversations. 2. The Skill writes the credentials to `config/feishu-settings.json`. 3. Keyword-matched messages are written to `data/matched_mess ...[truncated 737 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove secrets from JSON configuration and load them from environment variables, an operating-system keychain, or a dedicated secret manager. - Create sensitive files with owner-only permissions such as `0600`, and verify existing file permissions before use. - Encrypt cached message content at rest using a key stored separately from the data. - Store only fields required for export and redact unnecessary sender, attachment, and chat metadata. - Apply an explicit retention policy and securely delete successfully exported or expired records. - Refuse to start if secret or cache files are readable by group or other users. - Document backup and data-protection requirements for the cache and configuration directories. ]]>
