T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:84
- Finding
- OpenRouter API Key Exposed Through Command-Line and Cron Examples<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:28-46, 84-87`; `scripts/rotate_free_models.py:550-551` **Vulnerability Type**: Credential exposure through process arguments, shell history, and persistent scheduler configuration **Risk Level**: Medium ### Vulnerable Code ```markdown # SKILL.md:84-87 Run via cron every 6 hours for auto-rotation: 0 */6 * * * python3 rotate_free_models.py --api-key "sk-or-xxx" --restart > /var/log/model-rotate.log 2>&1 ``` ```python # scripts/rotate_free_models.py:550-551 parser.add_argument("--api-key", default=os.environ.get("OPENROUTER_API_KEY"), help="OpenRouter API key") ``` The quick-start examples at `SKILL.md:28-46` likewise recommend passing the key directly with `--api-key`. ### Technical Analysis The Skill accepts the OpenRouter API key through a command-line option and repeatedly recommends that method in its documentation. Command-line secrets may be exposed through: - Process listings and process-inspection interfaces while the command is running. - Shell command history. - Monitoring, debugging, or endpoint-management software that records command lines. - Persistent crontab content and administrative backups. - Accidental copying of commands into logs, tickets, or terminal transcripts. The script already supports `OPENROUTER_API_KEY`, so embedding the credential in command arguments or crontab is not necessary for the declared functionality. Although the script only sends the Bearer token to the fixed OpenRouter HTTPS endpoint, its local method of receiving the token is insecure. ### Attack Path 1. A user follows the documented example and invokes the script with a live key: ```bash scripts/rotate_free_models.py --api-key "sk-or-live-key" --restart ``` 2. The complete command is retained in shell history, stored in crontab, or temporarily exposed through process metadata. 3. An attacker with access to the same account, readable operational records, backups, or ...[truncated 669 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove command-line API keys from every example in `SKILL.md` and the script help text. 2. Recommend using `OPENROUTER_API_KEY` from a secret manager or a protected environment file. 3. For scheduled execution, load the secret from a file owned by the service account and restricted to mode `0600`; do not place the value directly in crontab. 4. Consider deprecating `--api-key`, or make it emit a warning explaining that command-line secrets may be observable. 5. Use a dedicated, least-privileged OpenRouter key with spending and usage limits where supported. 6. Ensure logs and exception handling never print request headers or the credential. 7. Rotate any production key that has already been stored in shell history, crontab, logs, or shared documentation. ]]>
