T09 · Insecure Skill Coding Practices
- Location
templates/optimized-skill-template.md:35- Finding
Reusable Template Exposes API Keys Through Command Output
- Content
View full analysis
= 2.0 | `npm install -g tool-x` | `tool-x --version` | | API Key Y | — | See TOOLS.md | `echo $API_KEY` | ``` ### Technical Analysis The reusable skill template recommends `echo $API_KEY` as a dependency verification command. This prints the complete secret rather than merely confirming that the variable is configured. Because this template is intended to be copied into generated or optimized skills, the unsafe pattern may propagate to other project files. If an agent or user executes the command, the API key can be retained in terminal scrollback, CI logs, agent transcripts, command-capture systems, or other monitoring output. The issue does not expose a hardcoded credential in this repository. Exploitation requires a generated skill to retain the example and execute it in an environment where `API_KEY` contains a real secret. ### Attack Path 1. A skill is created or optimized using `optimized-skill-template.md`. 2. The API-key verification row is retained or adapted without replacing the command. 3. A real credential is assigned to the referenced environment variable. 4. A user, agent, or automated validation process executes `echo $API_KEY`. 5. The complete credential is written to observable output. 6. A party with access to logs, transcripts, terminal history, or captured output retrieves and reuses the credential. ### Impact Assessment An attacker could obtain the privileges associated with the disclosed API key, potentially including access to remote services, data, usage quotas, or billable operations. The exact impact depends on the permissions assigned to the credential. This issue does not independently provide local privilege escalation or arbitrary code execution. ]]>- Remediation
View remediation
&2 exit 1 fi ``` Additional hardening measures: 1. Explicitly state that credentials must never be printed, logged, or included in generated reports. 2. Use secret managers or protected environment variables for credential storage. 3. Redact sensitive environment-variable values from agent transcripts and CI logs. 4. Add a review rule that rejects generated verification commands containing `echo $...` for variables whose names include `KEY`, `TOKEN`, `SECRET`, or `PASSWORD`. 5. Rotate any credential that may already have been exposed through this pattern. ]]>
