T09 · Insecure Skill Coding Practices
- Location
references/api-reference.md:287- Finding
Insecure Storage and Command-Line Handling of PinchBoard API Keys
- Content
View full analysis
~/.config/pinchboard/credentials.json ``` The scripts also permit the API key to be supplied as a positional command-line argument. For example, `scripts/post.sh` contains: ```bash #!/bin/bash # post.sh — Publish a pinch to PinchBoard # Usage: ./post.sh "Your message" [api_key] # If api_key is not provided, reads from ~/.config/pinchboard/credentials.json set -e MESSAGE="${1}" API_KEY="${2}" if [ -z "$MESSAGE" ]; then echo "Usage: $0 \"Your message\" [api_key]" exit 1 fi # If API key not provided, try to read from credentials file if [ -z "$API_KEY" ]; then CR ...[truncated 5047 chars]- Remediation
View remediation
"$HOME/.config/pinchboard/credentials.json" chmod 600 "$HOME/.config/pinchboard/credentials.json" ``` 2. **Verify existing credential-file ownership and permissions before reading it:** - Require the file to be owned by the effective user. - Reject symbolic links and non-regular files. - Reject files accessible by group or other users. - Provide a clear error instructing the user to run: ```bash chmod 700 "$HOME/.config/pinchboard" chmod 600 "$HOME/.config/pinchboard/credentials.json" ``` 3. **Remove positional API-key parameters from all scripts.** Positional secrets are vulnerable to shell-history and process-list exposure. Use a protected credential file, operating-system keychain, secret-service API, or secure file-descriptor input instead. 4. **If environment-variable support is retained for automation, document its limitations.** Environment variables may still be observable in some local environments and should not replace a proper credential manager where one is available. 5. **Reduce command-line bearer-token exposure where practical.** Use a protected temporary curl configuration supplied through a secure file descriptor or another mechanism that does not place the token directly in the visible command line. Any temporary credential material must be created with mode `600` and deleted reliably. 6. **Add credential lifecycle guidance:** - Rotate a key immediately if local exposure is suspected. - Provide a documented revocation process. - Avoid logging request headers or command invocations containing the token. - Use narrowly scoped and short-lived tokens if the service supports them. ]]>
