T09 · Insecure Skill Coding Practices
- Location
SKILL.md:88- Finding
Bria credentials are stored without restrictive filesystem permissions
- Content
View full analysis
"$HOME/.bria/credentials" echo "AUTHENTICATED" break fi ``` The API key is subsequently added through another temporary credential file: ```bash if [ -n "$BRIA_API_KEY" ]; then grep -v '^api_token=' "$HOME/.bria/credentials" > "$HOME/.bria/credentials.tmp" 2>/dev/null || true printf 'api_token=%s\n' "$BRIA_API_KEY" >> "$HOME/.bria/credentials.tmp" mv "$HOME/.bria/credentials.tmp" "$HOME/.bria/credentials" fi ``` ### Technical Analysis The Skill writes an OAuth access token, refresh token, and API token to a plaintext file under the user's home directory. It does not set a restrictive `umask`, assign mode `0700` to the credential directory, or assign mode `0600` to the credential and temporary files. The resulting permissions depend entirely on the process's inherited `umask`. Under an unsafe or unusually permissive configuration, the credentials may be readable by other local accounts or processes. The temporary credential file inherits the same weakness and contains the reusable API token before being renamed over the primary file. Accessing a dedicated Bria credential file is functionally necessary for authenticated API calls and does not by itself exceed the declared purpose. The insecure creation and storage controls, however, expose more privilege than is necessary. ### Attack Path 1. A user follows the authentication workflow described in `SKILL.md`. 2. The shell creates `~/.bria/credentials` and `~/.bria/credentials.tmp` without explic ...[truncated 1007 chars]- Remediation
View remediation
"$tmp_file" mv -f "$tmp_file" "$HOME/.bria/credentials" chmod 600 "$HOME/.bria/credentials" ``` 4. Register a cleanup trap so temporary credential files are removed on interruption or failure. 5. Where available, store long-lived refresh and API tokens in the operating system's credential manager rather than a plaintext file. 6. Avoid truncating the credential file when a token is invalid. Delete it securely or replace it atomically while preserving restrictive permissions. ]]>
