T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
API Key Disclosure Through Secret File Output
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 37-46
Vulnerability Type: API key exposure through Agent instructions
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 Skill instructs the Agent to run `cat ~/.upkuajing/.env` to determine whether an API key is configured. This outputs the complete contents of a credential file, including the bearer token used for authenticated and billable API operations. Reading the specific `UPKUAJING_API_KEY` is necessary for the declared functionality. Printing the entire file is not necessary and exceeds the minimum disclosure required for a presence check. Command output may be captured in Agent context, execution transcripts, terminal logs, debugging systems, or conversation history. This also exposes any unrelated values that a user may have placed in the same `.env` file. ### Attack Path 1. A user invokes the Skill without explicitly supplying an API key through the process environment. 2. The Agent follows the documented setup instructions. 3. The Agent executes `cat ~/.upkuajing/.env`. 4. The complete bearer token is returned in command output and enters the Agent or execution transcript. 5. An actor with access to the transcript, logs, or captured context obtains the token. 6. The actor reuses the token against the UpKuaJing API for authenticated operations. ### Impact Assessment A disclosed key may permit unauthorized paid customs-data queries, retrieval of associated account information, creation of payment orders, and other operations authorized for that API credential. The issue does not grant operating-system privile ...[truncated 109 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the instruction to print the credential file.
- Check only whether the expected variable is present and non-empty, without displaying its value.
- Prefer supplying the key through a protected process environment or operating-system credential store.
- Ensure command output never includes the full key or a key prefix.
- Add documentation covering token revocation and rotation after suspected transcript or log exposure.
- If file-based storage remains supported, read only the
UPKUAJING_API_KEYentry and avoid processing or displaying unrelated entries.
