T09 · Insecure Skill Coding Practices
- Location
SKILL.md:103- Finding
Plaintext Credential Storage and Fragile Environment Loading
- Content
View full analysis
~/.config/moltbook-generator/.env << 'EOF' # Moltbook API(必需) MOLTBOOK_API_KEY="your_moltbook_api_key" # Get笔记配置(必需) GETNOTE_API_KEY="your_getnote_api_key" GETNOTE_CLIENT_ID="your_getnote_client_id" # 邮件配置(可选) SMTP_HOST="smtp.163.com" SMTP_PORT=465 SMTP_USER="your_email@163.com" SMTP_PASSWORD="your_smtp_password" RECIPIENT="your_email@163.com" EOF # 设置权限 chmod 600 ~/.config/moltbook-generator/.env ``` ```bash export $(cat ~/.config/moltbook-generator/.env | xargs) ``` ### Technical Analysis The documented setup stores Moltbook, GetNote, and SMTP credentials in a persistent plaintext file at a predictable location. Setting mode `600` is an appropriate mitigating control, but it does not protect the credentials from processes running as the same user, privileged users, accidental backups, or disclosure caused by incorrectly preserved permissions. The command used to load the file is also fragile. Command substitution followed by unquoted expansion performs shell word splitting and pathname expansion. `xargs` additionally changes whitespace and quote handling. Secrets containing spaces, wildcard characters, quotes, or other special characters can therefore be corrupted or split into unintended arguments to the `export` builtin. This loading construction does not, by itself, re-evaluate arbitrary shell operators from the file as executable syntax. Nevertheless, anyone able to alter the file can control which environment variables are exported to the Skill and can affect commands that trust those variables. ### Attack Path 1. A local process operating as the same user, a privileged process, or a backup/logging mechanism obtains access to `~/.config/moltbook-generator/.env`. 2. The process reads reusable Moltbook, GetNote, or SMTP credentia ...[truncated 983 chars]- Remediation
View remediation
&2 exit 1 fi set -a # shellcheck disable=SC1090 . "$ENV_FILE" set +a ``` 4. Because sourcing executes shell syntax, only use that approach with a trusted, owner-only file. For stronger isolation, parse an allowlist of expected keys without evaluating the file as shell code. 5. Use narrowly scoped API credentials, rotate exposed credentials, and avoid storing SMTP account passwords when a revocable application-specific token is available. ]]>
