T09 · Insecure Skill Coding Practices
- Location
README.md:148- Finding
Full API Keys Exposed Through Troubleshooting Commands
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a coherent Kimi setup guide, but it includes unsafe API-key handling that could expose a user’s credentials.
Review before installing. The skill appears to do what it claims, but avoid printing API keys, avoid putting real keys directly in shared config files, use a restricted secret file or secret manager, and rotate any key that may have been displayed in logs, screenshots, or support transcripts. Run the API test script only when you are comfortable sending a test prompt and bearer token to the Moonshot/Kimi endpoints.
README.md:148Full API Keys Exposed Through Troubleshooting Commands
references/config-examples.md:220Documentation Encourages Persistent Plaintext API-Key Storage
The declared purpose is a setup guide, but the content also directs users to validate secrets, print environment variables, and perform live network connectivity tests against external APIs. That mismatch matters because an agent may invoke the skill in a low-risk help context while actually causing secret handling and outbound transmission behaviors the user did not explicitly authorize.
The guide instructs users to append a live API key directly into a dotfile using shell redirection. Although common in developer workflows, this encourages long-lived secret persistence in plaintext and may expose credentials through backups, misconfigured permissions, shared accounts, or accidental publication.
Or add to .env file:
echo 'MOONSHOT_API_KEY="sk-your-moonshot-key-here"' >> ~/.env
This repeats the same unsafe secret persistence pattern for the Kimi Code key. Storing bearer credentials in plaintext dotfiles without guidance on permissions or secret management increases the chance of credential compromise.
Or add to .env:
echo 'KIMICODE_API_KEY="sk-your-kimicode-key-here"' >> ~/.env
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
## Environment Variables Setup
### Using .env file
Create or edit `~/.env`:
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
Test endpoint directly:
curl -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "kimi-k2.5", "messages": [{"role": "user", "content": "test"}]}'
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
Test endpoint directly:
curl -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "kimi-k2.5", "messages": [{"role": "user", "content": "test"}]}'
The skill includes shell commands and operational steps but does not declare any tool scope or allowed-tools restrictions. In an agent ecosystem, this increases the chance that a model or orchestrator will treat the skill as documentation while still enabling command execution, creating an unnecessary pathway for unintended shell actions.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
1. Visit https://platform.moonshot.cn
2. Register an account
3. Navigate to API Keys section
4. Create a new API key
5. Copy the key (starts with `sk-...`)
### Kimi Code
The troubleshooting steps recommend echoing API keys directly to the terminal, which can expose secrets through terminal history, screen sharing, logs, or shoulder-surfing. Even if intended for debugging, instructing users to print credentials is unsafe handling of secrets.
The guide recommends sending a real authenticated request to an external provider without warning that the API key and prompt content are being transmitted off-system. In agent-assisted environments, users may not realize that 'test' steps have privacy, billing, and data-governance consequences.
This duplicate finding refers to the same authenticated curl example that transmits a bearer token and prompt content externally. The danger is contextual: the test step is operational, not merely descriptive, and lacks adequate warning about data egress and secret use.
Test API endpoint directly:
curl -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "kimi-k2.5", "messages": [{"role": "user", "content": "test"}]}'
This duplicate finding refers to the same authenticated curl example that transmits a bearer token and prompt content externally. The danger is contextual: the test step is operational, not merely descriptive, and lacks adequate warning about data egress and secret use.
Test API endpoint directly:
curl -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "kimi-k2.5", "messages": [{"role": "user", "content": "test"}]}'
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
Create or edit ~/.env:
# Moonshot AI (Kimi K2.5)
The documentation tells users to persist API keys in shell startup files, which can increase credential exposure through dotfile syncing, backups, shell history during editing, or accidental sharing of home-directory configuration. While common in developer docs, it lacks guidance on safer secret storage and file-permission hygiene, so it is a legitimate security weakness in the instructions.
This example shows API keys embedded directly in application configuration, which creates a clear risk of credential leakage via source control, shared config files, logs, backups, screenshots, or support bundles. Although the note says this is 'less secure,' it does not clearly warn against accidental exposure in shared or committed configs, so the finding is valid.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# Test Moonshot API
echo " Testing Moonshot API..."
response=$(curl -s -X POST "https://api.moonshot.cn/v1/chat/completions" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
No suspicious patterns detected.