T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
Credential Exposure Through Documented Plaintext File Output
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 37-46
Vulnerability Type: Credential exposure
Risk Level: MediumVulnerable Code Snippet:
markdown 本技能需要API密钥。API密钥存储在 `~/.upkuajing/.env` 文件中: ```bash cat ~/.upkuajing/.env文件内容示例:
text UPKUAJING_API_KEY=your_api_key_hereAPI密钥未设置
首先检查
~/.upkuajing/.env文件中是否有 UPKUAJING_API_KEY;text ### Technical Analysis The setup instructions recommend executing `cat ~/.upkuajing/.env`, which prints the entire credential file to standard output. Although accessing the designated API key is necessary for authenticated API calls, displaying its plaintext value is not necessary to verify whether it is configured. In an AI Agent environment, command output may be copied into the current model context, conversation history, execution logs, terminal recordings, observability platforms, or debugging traces. The file could also acquire additional variables in the future, causing the command to expose more than the intended API key. This behavior exceeds minimum privilege because a non-revealing presence check would be sufficient. ### Attack Path 1. An Agent or user follows the documented environment-check procedure. 2. The command `cat ~/.upkuajing/.env` is executed. 3. The plaintext API key appears in terminal output and potentially in Agent context or retained logs. 4. A party with access to those records extracts the key. 5. The exposed key is reused to access account APIs or invoke paid query endpoints. ### Impact Assessment Exposure grants the attacker the same API privileges assigned to the key. Depending on the associated account, this may include: - Performing paid API queries and consuming the account balance. - Retrieving account-related information exposed by authenticated endpoints. - Creating payment-order URLs or accessing other authenticated platform operations. - Associating unauthorized activity w ...[truncated 175 chars]- Remediation
View remediation
Remediation Suggestions
-
Remove the instruction to print the complete
.envfile. -
Use a non-revealing check that reports only whether the variable exists, for example:
bash python -c "import os; print('configured' if os.getenv('UPKUAJING_API_KEY') else 'not configured')" -
If checking the file fallback is required, parse only the variable name and return a Boolean result without printing its value.
-
Redact API keys from command output, exceptions, telemetry, and Agent responses.
-
Advise users to rotate the key immediately if it has already appeared in conversation history or logs.
-
