T09 · Insecure Skill Coding Practices
- Location
askia.mjs:63- Finding
API Credentials Exposed Through Command-Line Arguments
- Content
View full analysis
{ 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 askia stats askia queue [category] [limit] askia answer askia ask [|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
View remediation
