T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/answer-intent-map.js:510
- Finding
- API Credentials Can Be Exposed Through Command-Line Arguments and Plaintext Configuration## Vulnerability Details **File Location**: `scripts/answer-intent-map.js:510, 529, 544-545` **Vulnerability Type**: Insecure credential handling **Risk Level**: Medium ### Vulnerable Code ```js --api-key <string> Perplexity API key (overrides PERPLEXITY_API_KEY env) ``` ```js const loaded = JSON.parse(fs.readFileSync(configPath, 'utf8')); config = { ...config, ...loaded }; ``` ```js const perplexityKey = flags['api-key'] || process.env.PERPLEXITY_API_KEY || config.perplexityApiKey; const openaiKey = process.env.OPENAI_API_KEY || config.openaiApiKey; ``` ### Technical Analysis The script supports two insecure alternatives to environment-based secret handling: 1. A Perplexity API key may be supplied through the `--api-key` command-line argument. 2. Perplexity and OpenAI API keys may be loaded from ordinary JSON configuration properties. Command-line secrets can be captured in shell history, terminal transcripts, process-monitoring telemetry, job-runner logs, and—depending on the operating system and configuration—process listings visible to other local users. Plaintext configuration secrets may be exposed through permissive file permissions, backups, support bundles, workspace sharing, or accidental source-control commits. The configuration behavior also conflicts with the Skill metadata statement that API keys are loaded from environment variables. ### Attack Path 1. A user invokes the script with a command such as: ```bash node scripts/answer-intent-map.js --api-key SECRET --category "example" ``` Alternatively, the user places `perplexityApiKey` or `openaiApiKey` in `aeo-config.json`. 2. The secret remains in shell history or operational logs, is visible in process metadata while the command runs, or persists in the plaintext configuration. 3. A local user, monitoring service, workspace recipient, or party with access to an accidentally committed configuration obtains the credential. 4. The exposed credential is reused against the ...[truncated 474 chars]
- Remediation
- ## Remediation Suggestions 1. Remove support for the `--api-key` argument. 2. Remove `config.perplexityApiKey` and `config.openaiApiKey` as credential sources. 3. Read API credentials exclusively from environment variables or an approved secret manager: ```js const perplexityKey = process.env.PERPLEXITY_API_KEY; const openaiKey = process.env.OPENAI_API_KEY; ``` 4. If interactive credential entry is necessary, use a masked prompt and retain the value only in memory. 5. Explicitly reject credential-related properties in configuration files to prevent accidental plaintext storage. 6. Add documentation warning users not to place credentials in configuration files or command-line arguments. 7. Add relevant configuration filenames to `.gitignore`, enforce restrictive file permissions where configuration may contain sensitive business data, and enable repository secret scanning. 8. Rotate any API credential previously supplied through a command line or committed to a configuration file.
