T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
API Key Exposure Through Documented Credential File Inspection
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 37–46
Vulnerability Type: Plaintext credential disclosure
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;text ### Technical Analysis The documentation directs the Agent or user to print the complete contents of a credential file merely to determine whether an API key exists. This operation exposes the plaintext value of `UPKUAJING_API_KEY` to standard output. Printing the file exceeds the minimum privileges necessary for the declared trade-query functionality. Key availability can be checked without disclosing its value. Output generated by the command may be retained in Agent context, chat transcripts, terminal scrollback, execution logs, screen recordings, or monitoring systems. The associated parser in `scripts/common.py` also reads every assignment from the `.env` file even though the Skill only requires `UPKUAJING_API_KEY`. While it does not print those values itself, restricting parsing to the required key would further reduce exposure. ### Attack Path 1. A user or Agent follows the documented API-key setup workflow. 2. The command `cat ~/.upkuajing/.env` is executed. 3. The full plaintext API key appears in terminal or Agent output. 4. That output is retained in a transcript, log, or other observable channel. 5. A party with access to that channel obtains the key. 6. The exposed key is reused to make authenticated requests to the UpKuaJing API, including potentially billable requests or account-information operations. ### Impact Assessment Successful exploitation exposes the privileges assigned to the affected UpKuaJing API key. An attacker may be able to: - Submit authenticated API requests. - ...[truncated 400 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the instruction to execute
cat ~/.upkuajing/.env. - Let
get_api_key()determine whether the key is available without displaying it. - If a separate presence check is needed, return only a boolean or a redacted status message.
- Never place the plaintext key in Agent responses, command output, logs, or exception messages.
- Modify
load_env_file()or replace it with a targeted reader that retrieves onlyUPKUAJING_API_KEY. - Redact any accidental secret values using a fixed representation such as
[REDACTED]. - Recommend rotating the API key if it has already been printed into a shared or persistent transcript.
- Remove the instruction to execute
