T09 · Insecure Skill Coding Practices
Warning
- Location
- askia.mjs:63
- Finding
- API Credentials Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `askia.mjs:63`, `askia.mjs:79`, `askia.mjs:96`, `askia.mjs:130`, `askia.mjs:145`, `askia.mjs:179`, and `askia.mjs:257`; unsafe usage is also documented in `SKILL.md:54-110` **Vulnerability Type**: API credential exposure through process arguments and shell history **Risk Level**: Medium ### Vulnerable Code ```js // Get agent profile profile: async (args) => { const apiKey = args[0] || error('API key is required'); const result = await apiRequest('/agents/me', 'GET', null, apiKey); const agent = result.data; ``` The same argument-based credential pattern is used by the `stats`, `queue`, `answer`, `ask`, and `vote` commands. The command arguments are obtained directly from the process command line: ```js async function main() { const command = process.argv[2]; const args = process.argv.slice(3); ``` The documented usage explicitly directs users to place credentials on the command line: ```bash askia profile <apiKey> askia stats <apiKey> askia queue <apiKey> [category] [limit] askia answer <apiKey> <questionId> <answer> askia ask <apiKey> <title>[|body|category|complexity] askia vote <apiKey> <answerId> [value] ``` ### Technical Analysis The CLI treats the first positional argument as a bearer API key. Command-line arguments are not an appropriate secret transport mechanism because they can be exposed through: - Shell history files. - Process enumeration tools while the command is running. - Terminal scrollback, copied command transcripts, or session recording. - Wrapper scripts, task runners, and diagnostic systems that log complete commands. - Operating-system process accounting or audit facilities. The key is subsequently placed in the HTTP `Authorization` header: ```js if (apiKey) headers['Authorization'] = `Bearer ${apiKey}`; ``` HTTPS protects the credential in transit to the declared service, but it does not protect the credential from local disclosure before the request is sent. ...[truncated 1158 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Stop accepting API keys as positional command-line arguments. 2. Prefer a protected environment variable, such as `ASKIA_API_KEY`, while documenting that users should inject it through their execution environment rather than placing it inline in a shell command. 3. For interactive use, support a hidden prompt that disables terminal echo. 4. For persistent credentials, use the operating system's credential manager or a configuration file restricted to the owning user, such as mode `0600` on Unix-like systems. 5. Update the documented syntax to omit the API key: ```bash export ASKIA_API_KEY="askia_xxx" askia profile askia queue "HUMAN_TO_AI" 5 ``` 6. Avoid printing, logging, or including the key in exception messages. 7. Redact bearer tokens and values matching the API-key format in diagnostic output. 8. Recommend rotation of keys that have already been used through the documented command-line interface. ]]>
