T09 · Insecure Skill Coding Practices
- Location
SKILL.md:93- Finding
API Token Stored in a Plaintext File Without Enforced Access Permissions
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 93–96 and 108–114
Vulnerability Type: Plaintext sensitive-data storage with environment-dependent file permissions
Risk Level: MediumVulnerable Code
Lines 93–96:
bash mkdir -p ~/.config/tripai-skill echo "your_api_key" > ~/.config/tripai-skill/api_keyLines 108–114:
bash if [ -n "$TRIPAI_API_KEY" ]; then mkdir -p ~/.config/tripai-skill echo "$TRIPAI_API_KEY" > ~/.config/tripai-skill/api_key fi TRIPAI_API_KEY="$(cat ~/.config/tripai-skill/api_key 2>/dev/null)"Technical Analysis
The documented setup and execution process stores
TRIPAI_API_KEYas plaintext in~/.config/tripai-skill/api_key. Neither the containing directory nor the credential file is assigned an explicit restrictive permission mode.The resulting permissions therefore depend on the user's current
umask, pre-existing directory permissions, and whether the destination file already exists. In a shared or incorrectly configured environment, another local user or process may be able to read the token. Redirecting with>truncates or creates the file but does not securely correct the permissions of an existing file.The usage instructions also automatically persist a token supplied through the environment. This expands the token's lifetime from the current process environment to persistent storage without an explicit user decision at execution time.
Attack Path
- A user exports a valid Ctrip API token through
TRIPAI_API_KEY. - The documented command writes the token to
~/.config/tripai-skill/api_key. - The file inherits environment-dependent permissions, or retains unsafe permissions if it already exists.
- A local user or process with access to the file reads the plaintext token.
- The attacker submits requests to the Ctrip skill endpoint using the stolen token.
Exploitation requires local access to the victim's environm ...[truncated 706 chars]
- A user exports a valid Ctrip API token through
- Remediation
View remediation
Remediation Suggestions
-
Create the credential directory with owner-only permissions:
bash mkdir -p ~/.config/tripai-skill chmod 700 ~/.config/tripai-skill -
Create or normalize the credential file with mode
600before writing the token:bash install -m 600 /dev/null ~/.config/tripai-skill/api_key printf '%s\n' "$TRIPAI_API_KEY" > ~/.config/tripai-skill/api_key -
Use
printfinstead ofechoto avoid implementation-specific handling of token values beginning with options or containing escape sequences. -
Do not automatically persist an environment-provided token during every invocation. Use the environment value directly and read the file only as a fallback.
-
Prefer an operating-system credential manager or secret store where available.
-
Validate existing credential-file ownership and permissions before reading it. Reject files owned by another user or accessible by group and other users.
-
Document token revocation and rotation procedures for users who suspect local disclosure.
-
