T09 · Insecure Skill Coding Practices
- Location
SKILL.md:40- Finding
API Key Exposure Through Secret File Output Instructions
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 40–52
Vulnerability Type: Exposure of plaintext credentials through Agent-visible terminal output
Risk Level: MediumVulnerable Code
markdown This skill requires an API key. The API key is stored in the `~/.upkuajing/.env` file: ```bash cat ~/.upkuajing/.envExample file content:
text UPKUAJING_API_KEY=your_api_key_hereAPI Key Not Set
First check if the
~/.upkuajing/.envfile has UPKUAJING_API_KEY; If UPKUAJING_API_KEY is not set, prompt the user to choose:- User has one: User provides it (manually add to ~/.upkuajing/.env file)
- User doesn't have one: You can apply using the interface (
auth.py --new_key), the new key will be automatically saved to ~/.upkuajing/.env
text ### Technical Analysis The Skill explicitly instructs the Agent to run `cat ~/.upkuajing/.env`. This prints the complete contents of the credential file rather than merely determining whether the required variable exists. Displaying the file is unnecessary for the declared functionality. The runtime implementation in `scripts/common.py` already checks the process environment and the designated file for `UPKUAJING_API_KEY`. Consequently, the instruction exceeds the minimum disclosure required to authenticate API requests. Terminal output produced during an Agent run may become part of the model context, conversation transcript, execution logs, observability records, or debugging artifacts. The command may also expose unrelated secrets if the same file contains additional environment variables. ### Attack Path 1. The Agent loads the Skill instructions while preparing an authenticated query. 2. Following `SKILL.md`, it executes `cat ~/.upkuajing/.env`. 3. The API key and any other values in the file are printed to standard output. 4. That output is captured in Agent context, execution logs, or retained transcripts. 5. A party with ...[truncated 698 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the instruction to run
cat ~/.upkuajing/.env. - Use a presence-only check that never prints the value, such as a dedicated script returning only whether the key is configured.
- Prefer the existing
get_api_key()behavior or add a--check-keyoperation that returns a redacted status. - Never place user-provided credentials directly into conversation content or command output.
- If diagnostic output is required, display only a fixed redacted form and avoid revealing enough characters to facilitate credential recovery.
- Warn users to rotate any key that has already appeared in an Agent transcript or execution log.
- Remove the instruction to run
