T09 · Insecure Skill Coding Practices
- Location
SKILL.md:15- Finding
Insecure Plaintext and Chat-Based API Key Handling
- Content
View full analysis
~/.novita/config.json ``` ### Method 2: Environment Variable ``` From `SKILL.md:29-38`: ```markdown ```bash export NOVITA_API_KEY="YOUR_API_KEY" ``` ### Method 3: Direct Parameter Include in request: `Please use API Key sk_xxx to generate an image...` --- ## API Key Reading Logic ``` 1. Check if user message contains API Key (starts with sk_) 2. Check config file ~/.novita/config.json 3. Check environment variable NOVITA_API_KEY ``` The same insecure message-based precedence is reinforced in `agents/openclaw.yaml:6-10`: ```yaml API Key reading order: 1. Key in user message (starts with sk_) 2. Config file ~/.novita/config.json 3. Environment variable NOVITA_API_KEY ``` ### Technical Analysis The recommended setup writes a long-lived bearer credential into `~/.novita/config.json` without explicitly setting secure directory or file permissions. The resulting permissions depend on the user's current `umask`; in an inadequately configured environment, the credential may be readable by other local users or processes. The Skill also explicitly encourages users to place API keys directly into chat messages. Such credentials can consequently enter conversation histories, agent traces, telemetry, debugging output, backups, or other systems that process and retain messages. Giving message-provided credentials the highest precedence also increases the likelihood that sensitive keys will be handled as ordinary prompt conte ...[truncated 1643 chars]- Remediation
View remediation
~/.novita/config.json chmod 600 ~/.novita/config.json ``` 4. Validate file ownership and permissions before reading the configuration. Reject or warn about files accessible to group or other users. 5. Redact API-key patterns from logs, traces, error messages, and progress output. 6. Never include the bearer token in command output, URLs, diagnostic messages, or completion responses. 7. Update both `SKILL.md` and `agents/openclaw.yaml` so that secure secret storage is the only recommended credential source. 8. Document key rotation and immediate revocation procedures for credentials that have already been submitted through chat. ]]>
