T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:66
- Finding
- API Key May Be Exposed Through Documented Plaintext Inspection<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 66–75 **Vulnerability Type**: Plaintext credential disclosure **Risk Level**: Medium ### Vulnerable Code Snippet ```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 Skill legitimately needs to determine whether an UpKuaJing API key is configured. However, the documented `cat ~/.upkuajing/.env` command prints the entire credential file rather than checking only whether the required variable exists. When an agent or user follows this instruction, the full API key can appear in terminal output, agent transcripts, debugging records, screenshots, command logs, or other monitoring systems. Printing the secret exceeds the minimum privilege necessary for checking whether it is configured. The underlying code in `scripts/common.py` limits credential retrieval to `UPKUAJING_API_KEY` and sends it to the fixed UpKuaJing HTTPS API endpoint. No evidence of intentional credential exfiltration was identified. The vulnerability is specifically the unnecessary disclosure encouraged by the documentation. ### Attack Path 1. A user or agent follows the documented API-key setup procedure. 2. The command `cat ~/.upkuajing/.env` is executed. 3. The complete API key is printed in plaintext. 4. Terminal output or the agent conversation is retained in logs, monitoring systems, or shared session history. 5. A person or system with access to those records obtains the key. 6. The exposed key is used to authenticate to the UpKuaJing API and perform operations under the victim's account. ### Impact Assessment An attacker who obtains the key may be able to: - Make authenticated UpKuaJing API requests as the affected account. - Consume account ...[truncated 405 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the instruction to run `cat ~/.upkuajing/.env`. 2. Prefer checking the environment variable without printing its value. 3. If the fallback file must be checked, report only whether the key is present, for example through a helper that returns a Boolean result. 4. Redact credentials in all output, diagnostics, exceptions, and logs. If identification is necessary, expose only a short, non-sensitive fingerprint. 5. Update the documentation to instruct users never to paste API keys into agent conversations or other recorded channels. 6. Prefer injecting `UPKUAJING_API_KEY` through the host platform's secret-management mechanism rather than manually displaying or editing the secret. ]]>
