T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:424
- Finding
- API Credential Stored Without Restrictive File Permissions## Vulnerability Details **File Location**: `SKILL.md`, lines 424–429 **Vulnerability Type**: Plaintext sensitive credential with insufficient permission hardening **Risk Level**: Medium **Vulnerable Code:** ```python os.makedirs(os.path.dirname(self.credentials_path), exist_ok=True) with open(self.credentials_path, "w") as f: json.dump({ "api_key": data["api_key"], "bot_id": data["bot_id"] }, f) ``` The path is initialized as follows at line 406: ```python self.credentials_path = os.path.expanduser("~/.config/mosstrade/credentials.json") ``` ### Technical Analysis The implementation stores a bearer API key in a plaintext JSON file. The directory and file are created with process-default permissions rather than explicit restrictive modes. If the process has a permissive `umask`, another local user may be able to read the credential. The code also does not guard against symbolic-link replacement or use atomic file creation. In a locally hostile environment, an attacker who can manipulate the destination path may attempt to redirect the write or interfere with credential storage. Reading one dedicated credential file and sending its key to the declared MossTrade API are consistent with the Skill's authenticated simulated-trading functionality. No evidence indicates that the key is sent to unrelated services. The security issue is the local storage implementation, which is less restrictive than necessary. ### Attack Path 1. The Skill enrolls a bot and receives an API key from the declared MossTrade API. 2. It creates `~/.config/mosstrade` and writes `credentials.json` using default filesystem permissions. 3. On a system with permissive defaults, another local user or compromised process reads the file. 4. The attacker extracts the bearer API key. 5. The attacker uses the key in the `Authorization` header when calling authenticated MossTrade endpoints. 6. The attacker can imperson ...[truncated 527 chars]
- Remediation
- ## Remediation Suggestions - Create the credential directory with mode `0700`. - Create the credential file atomically with mode `0600`, rather than relying on the process `umask`. - Refuse to follow symbolic links when creating or replacing the file. - Write to a securely created temporary file in the same directory, set its permissions, flush it, and atomically rename it into place. - Prefer an operating-system credential manager or secret store when available. - Never include the API key in logs, exception messages, or diagnostic output. - Validate the ownership and permissions of an existing credential file before reading it.
