T09 · Insecure Skill Coding Practices
- Location
lib/config.py:112- Finding
LLM API Key Stored in a Plaintext Configuration File Without Enforced Permissions
- Content
View full analysis
None: """Save configuration to file""" with open(CONFIG_FILE, 'w') as f: json.dump(self.config_data, f, indent=2) ``` ```python def set_api_key(self, key: str) -> None: """Set API key""" self.set("api_key", key) ``` ### Technical Analysis The `set_api_key()` method places the LLM API key directly in the general configuration dictionary, after which `save()` serializes that dictionary as plaintext JSON in `~/.nex-voice/config.json`. The implementation does not: - Use an operating-system credential manager. - Encrypt the stored credential. - Create the configuration file with mode `0600`. - Enforce mode `0700` on the containing data directory. - Correct permissions on an existing configuration file. - Use an atomic, securely permissioned file replacement operation. The resulting permissions depend on the user's current `umask` and pre-existing filesystem state. On a multi-user system or a machine containing untrusted local processes, the API key may consequently be readable outside its intended security boundary. ### Attack Path 1. A user runs `nex-voice config set-api-key`. 2. The supplied credential is stored under the `api_key` field in `config.config_data`. 3. `Config.save()` writes the complete configuration to `~/.nex-voice/config.json` as plaintext. 4. The file receives permissions based on the process `umask` or retains unsafe pre-existing permissions. 5. An attacker with local filesystem access reads the configuration file. 6. The attacker extracts the API key and uses it against the configured LLM provider. This issue requires local access or another process executing under an account that can read the file; it does not independently provide remote acc ...[truncated 602 chars]- Remediation
View remediation
