T09 · Insecure Skill Coding Practices
- Location
SKILL.md:46- Finding
API Key Persisted in an Unprotected Plaintext File
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:46-55
Additional Location:README.md:72-78
Vulnerability Type: Plaintext credential storage and insecure secret provisioning
Risk Level: MediumThe Skill instructs the Agent to receive an Agnes API key through the conversation and persist it as a plaintext file without explicitly restricting the file or directory permissions.
bash mkdir -p ~/.agnes-ai echo -n "sk-your-key-here" > ~/.agnes-ai/api_key export AGNES_API_KEY="sk-your-key-here"The README provides equivalent plaintext configuration instructions:
bash mkdir -p ~/.agnes-ai echo "你的API密钥" > ~/.agnes-ai/api_keyTechnical Analysis
The security of
~/.agnes-ai/api_keydepends entirely on the user's currentumask. The instructions do not create~/.agnes-aiwith mode0700or the key file with mode0600. In environments with permissive defaults, another local account or process may be able to read the credential.The secret is also embedded directly in a shell command and is expected to be supplied through an Agent conversation. Depending on the execution environment, this can expose the credential through:
- Agent conversation histories or telemetry.
- Shell history.
- Process execution logs or command auditing.
- Backups of the plaintext configuration file.
- Access by other local users when filesystem permissions are permissive.
The script at
scripts/generate.py:30-57subsequently reads this plaintext key and uses it as a bearer credential. Anyone obtaining the key can authenticate as the user to the Agnes API.Attack Path
- The user supplies an Agnes API key in an Agent conversation as instructed.
- The Agent interpolates the literal key into an
echoorexportshell command. - The key is retained in conversation logs, command audit records, shell history, or an insufficiently protected
~/.agnes-ai/api_keyfile. - A local attac ...[truncated 703 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not request API keys through ordinary Agent conversations.
- Direct users to configure secrets through a platform secret manager, protected environment configuration, or interactive terminal input.
- If file-based storage is required, create the directory and file with explicit restrictive permissions:
bash install -d -m 0700 "$HOME/.agnes-ai" umask 077 printf '%s' "$AGNES_API_KEY_INPUT" > "$HOME/.agnes-ai/api_key" chmod 0600 "$HOME/.agnes-ai/api_key"- Avoid placing the literal secret in command-line arguments or shell history. Read it silently with an interactive secret prompt where possible.
- Do not store a second copy in
scripts/api_key, because a project or installation directory may be shared, archived, or committed accidentally. - Validate that the key file is a regular file owned by the current user and is not group- or world-readable before loading it.
- Document key rotation and revocation procedures.
- Ensure logs and error messages never contain authorization headers or key values.
