T09 · Insecure Skill Coding Practices
- Location
SKILL.md:16- Finding
Unsafe Execution and Insecure Storage of API Credentials
- Content
View full analysis
"Please provide your Placed API key (get it at https://placed.exidian.tech/settings/api)" Then save it for future sessions: ```bash mkdir -p "$HOME/.config/placed" echo "export PLACED_API_KEY=" > "$HOME/.config/placed/credentials" export PLACED_API_KEY= ``` ### Technical Analysis The `source` command interprets the entire credentials file as shell code. A credential file should be treated as a data file containing only an opaque token; executing it grants every command in that file the privileges of the user running the Skill. The setup instructions also place the user-provided key directly into shell commands without a safe quoting or validation mechanism. If the placeholder is replaced with a value containing command substitution, shell metacharacters, or additional commands, the shell may execute those elements while saving or exporting the key. The directory and file are created without explicit permission controls. Their resulting modes depend on the user's current `umask`. This can expose the plaintext API key to other local accounts on systems configured with permissive defaults. Reading a credential is necessary for the declared authenticated API functionality, but executing a credential file as code and relying on ambient permission defaults exceed the minimum privileges and behavior required. ### Attack Path A practical exploitation path is: 1. An attacker gains the ability to create or modif ...[truncated 1677 chars]- Remediation
View remediation
"$credentials_file" chmod 600 "$credentials_file" ``` 3. Never interpolate a user-supplied key directly into executable shell text. Read it into a quoted variable, preferably without terminal echo: ```bash IFS= read -r -s -p "Placed API key: " PLACED_API_KEY printf '\n' export PLACED_API_KEY ``` 4. Validate the token against the documented format and reject values containing line breaks or control characters. Do not print the token in logs, command output, or error messages. 5. Prefer an operating-system credential manager or secret store over a plaintext file when available. 6. Before reading the file, consider verifying that it is a regular file owned by the current user and is not writable by group or other users. Avoid following an attacker-controlled symbolic link when creating or replacing it. ]]>
