T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:37
- Finding
- Credential File Contents May Be Exposed to the Agent and Command Output<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 37-46 **Vulnerability Type**: Excessive exposure of a credential file **Risk Level**: Medium ### Vulnerable Code ```markdown This skill requires an API key. The API key is stored in the `~/.upkuajing/.env` file: ```bash cat ~/.upkuajing/.env ``` **Example file content**: ``` UPKUAJING_API_KEY=your_api_key_here ``` ### **API Key Not Set** First check if the `~/.upkuajing/.env` file has UPKUAJING_API_KEY; ``` ### Technical Analysis The documentation directs the Agent to execute `cat ~/.upkuajing/.env` to determine whether an API key is configured. This prints the complete file rather than checking only whether `UPKUAJING_API_KEY` exists. Although access to the API key is necessary for authenticated queries, exposing the whole credential file is not necessary. The file may contain the UpKuaJing key, comments, or additional credentials added by the user. Command output can enter the Agent context, terminal history, execution logs, transcripts, or diagnostic records. The Python implementation in `scripts/common.py` already supports reading only the named variable. Therefore, the full-file output instruction exceeds the minimum access and disclosure needed by the declared functionality. ### Attack Path 1. A user invokes the Skill without an API key in the process environment. 2. The Agent follows the setup instruction in `SKILL.md`. 3. The Agent executes `cat ~/.upkuajing/.env`. 4. Every value in the file is printed into an observable command result. 5. The output may be retained in Agent transcripts, terminal logs, monitoring systems, or debugging records. 6. Any party with access to those records may recover the API key or other secrets contained in the file. ### Impact Assessment The issue does not grant new filesystem privileges because the process can already read the user's file. However, it unnecessarily expands the exposure scope of secrets from a local credential file to command ...[truncated 280 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the instruction to execute `cat ~/.upkuajing/.env`. - Prefer the declared `UPKUAJING_API_KEY` environment variable as the sole credential source where practical. - If file fallback is retained, use the existing local parser to retrieve only `UPKUAJING_API_KEY` without printing its value. - Expose only a Boolean status such as “API key configured” or “API key missing.” - Never include the credential value, even partially, in Agent output, logs, exceptions, or diagnostic messages. - Advise users to keep unrelated credentials in separate files. ]]>
