T09 · Insecure Skill Coding Practices
Note
- Location
- scripts/free-models.js:12
- Finding
- Unnecessary Collection and Requirement of an OpenRouter API Key< Openclaw should export the key (or string with a prefix "sk-or-") as the value of Environment Variable `OPENROUTER_API_KEY` before calling the cli. ```bash export OPENROUTER_API_KEY="sk-or-v1-..." node scripts/free-models.js ``` ``` ### Technical Analysis The documentation instructs users to obtain and export a live OpenRouter API key. The CLI then reads that credential from the process environment and refuses to run without it. However, the only network request is a parameterless HTTPS GET request to the public OpenRouter models endpoint. The key is not added to an `Authorization` header, request body, query string, or any other outbound field. Consequently, access to the credential is not necessary for the Skill's declared model-discovery and filtering functionality. Requiring a sensitive credential when it is not used violates least-privilege principles and unnecessarily expands the sensitive data available to the Node.js process. The static pre-scan warning about sensitive ...[truncated 1657 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the unnecessary environment-variable read: ```js const API_KEY = process.env.OPENROUTER_API_KEY || null; ``` 2. Remove the API-key gate from `main()` so public model discovery works without credentials: ```js async function main() { console.log('🔍 Fetching models from OpenRouter...\n'); // Continue with public model discovery. } ``` 3. Remove the instructions in `SKILL.md` that ask users to obtain and export `OPENROUTER_API_KEY`. 4. If authenticated functionality is introduced later: - Request a credential only for operations that genuinely require authentication. - Read the key immediately before the authenticated request rather than at module initialization. - Send it only to the documented OpenRouter HTTPS origin using an authorization header. - Never place it in URLs, logs, error messages, or command-line arguments. - Validate the destination origin before attaching the authorization header. - Recommend a restricted, revocable key with the minimum available account privileges. 5. Add a test confirming that model discovery succeeds when `OPENROUTER_API_KEY` is absent. ]]>
