T09 · Insecure Skill Coding Practices
- Location
SKILL.md:16- Finding
Unsafe Sourcing and 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 evaluates the entire credential file as shell code. A credential file should be treated as data, but this implementation turns it into an executable code-loading mechanism. If an attacker or compromised process gains write access to `~/.config/placed/credentials`, arbitrary shell commands placed in that file will execute with the privileges of the user running the Skill. The storage commands do not explicitly set restrictive permissions. The resulting directory and file permissions depend on the user's current `umask`; an insufficiently restrictive configuration could expose the bearer token to other local users. Possession of that token permits authenticated access to the user's Placed account through the documented API. The placeholder also instructs the Agent to insert the supplied key directly into shell syntax without quoting or validating it. If a supplied value contains shell metacharacters, command substitutions, whitespace, or quotes, it can alter the generated command or execute unintended commands. Reading a Placed API credential is necessary for the declared functionality, but evaluating the credential file as code and omitting explicit access controls exceed the minimum ...[truncated 2300 chars]- Remediation
View remediation
"$credential_file" chmod 600 "$credential_file" ``` 3. **Never insert user-provided credentials directly into generated shell syntax.** Receive the value through a protected input mechanism, assign it using safe quoting, and write it with `printf '%s\n'`. 4. **Validate the token format** against the provider's documented character set and length. Reject newlines, control characters, shell metacharacters, and structurally invalid values. 5. **Prefer an operating-system credential manager** such as macOS Keychain, Windows Credential Manager, or Secret Service/libsecret instead of a plaintext file. 6. **Avoid displaying or logging the token.** Ensure verbose shell tracing is disabled while credentials are handled and redact authorization headers from diagnostics. 7. **Check existing credential-file ownership and permissions** before reading it. Refuse to use files owned by another account or files writable by group or other users. 8. **Support revocation and rotation.** Advise users to revoke and replace the Placed API key if the credential file may have been exposed. ]]>
