T09 · Insecure Skill Coding Practices
- Location
redditrank_tui/config.py:29- Finding
API Key Persisted Without Explicit Restrictive File Permissions
- Content
View full analysis
"$RR_CONFIG" else echo "{\"api_key\": \"$API_KEY\"}" > "$RR_CONFIG" fi ``` The setup script also exposes the complete credential in terminal output at `setup.sh:185` and `setup.sh:200`: ```bash echo -e " Key: ${CYAN}$API_KEY${NC}" ... echo -e " ${DIM}export REDDITRANK_API_KEY=$API_KEY${NC}" ``` ### Technical Analysis The application stores the RedditRank API key as plaintext in `~/.redditrank/config.json`. Neither the Python implementation nor the shell setup script explicitly creates the configuration directory with mode `0700` or the credential file with mode `0600`. Consequently, access permissions depend on the user's current umask and any pre-existing directory or file permissions. Under a permissive umask or an incorrectly permissioned existing configuration path, another local user may be able to read the API key. Printing the complete key to the terminal additionally exposes it to terminal recording, screenshots, copied logs, or surrounding automation that captures standard output. ### Attack Path 1. A user runs `setup.sh` or completes TUI onboarding, causing the API key to be written to `~/.redditrank/config.json`. 2. The process runs under a permissive umask, or the configuration direct ...[truncated 925 chars]- Remediation
View remediation
"$RR_CONFIG" chmod 600 "$RR_CONFIG" ``` 4. Do not display the complete API key after creation. Show only a masked value and the configuration path. 5. Prefer an operating-system credential store or keyring where available. 6. On startup, detect and warn about configuration files that are readable or writable by group or other users. ]]>
