T09 · Insecure Skill Coding Practices
- Location
SKILL.md:16- Finding
Unsafe Shell Sourcing and Plaintext Persistence of API Credentials
- Content
View full analysis
" > "$HOME/.config/placed/credentials" export PLACED_API_KEY= ``` ### Technical Analysis The Skill saves the Placed API key as plaintext in `~/.config/placed/credentials` without explicitly applying restrictive permissions to either the directory or the file. The resulting access permissions depend on the user's current `umask`, which may allow unintended local disclosure. More critically, the Skill later loads this file using the shell built-in `source`. Sourcing does not merely read the expected `PLACED_API_KEY` assignment; it executes every shell statement in the file in the current shell context. If another local account, process, compromised program, or synchronization mechanism can modify the credential file, it can insert arbitrary shell commands that execute when the Skill is used. Reading a dedicated Placed credential is reasonably related to authenticated API access. However, persisting it without explicit permission controls and treating the data file as executable shell code exceed the minimum privileges and behavior needed for the declared job-tracking functionality. ### Attack Path 1. The user invokes the Skill and supplies a Placed API key. 2. The Skill writes the key in plaintext to `~/.config/placed/credentials` without explicitly setting mode `600`. 3. An attacker who has gained write access to that file replaces or augments it with a command, for example: ```bash export PLACED_API_KEY="..." malicious_command ``` 4. In a later session, `PLACED_API_KEY` is absent from the envi ...[truncated 1177 chars]- Remediation
View remediation
"$HOME/.config/placed/credentials" chmod 600 "$HOME/.config/placed/credentials" ``` 4. Store only the token value rather than executable shell syntax such as `export ...`. 5. When reading the token, verify that the file is a regular file owned by the current user and is not a symbolic link. Reject files with group or world permissions. 6. Avoid placing the token directly in generated command text, logs, diagnostics, or shell history. Pass it through the environment or a protected descriptor and redact it from errors. 7. Support environment-only authentication as the default so persistent credential access is not required. 8. Document token revocation and rotation procedures for users whose credential file may have been exposed. ]]>
