T09 · Insecure Skill Coding Practices
- Location
SKILL.md:19- Finding
Bearer Token Stored in an Unprotected Plaintext Credentials File
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 19–30 and 104–109
Vulnerability Type: Plaintext storage of a reusable authentication token
Risk Level: MediumVulnerable Code
text **Credentials file:** `{baseDir}/.credentials` ## Shared Authentication Rules Before any authenticated SecondMe operation: 1. Read `{baseDir}/.credentials` 2. If it contains valid JSON with `accessToken`, continue 3. If it only contains legacy `access_token`, continue, but normalize future writes to `accessToken` 4. If the file is missing, empty, or invalid, start the login flow in this same skill Use the resulting `accessToken` as the Bearer token for all authenticated requests below.text After success: 1. Write `{baseDir}/.credentials`, for example: ```json { "accessToken": "<data.accessToken>", "tokenType": "<data.tokenType>" } ```Technical Analysis
The skill directs the agent to persist a reusable SecondMe bearer token in a JSON file under its base directory. It does not require owner-only file permissions, ownership validation, encryption, an operating-system credential store, atomic file creation, or protection from version-control and backup exposure.
A bearer token grants access based on possession. Therefore, any process or user able to read this file may replay the token without knowing the account password. The token is subsequently accepted by the documented authenticated SecondMe endpoints.
Attack Path
- A victim completes the SecondMe authorization flow.
- The skill writes the returned
accessTokento{baseDir}/.credentialsas plaintext JSON. - A local user, compromised process, permissive backup service, or recipient of an accidentally published project archive reads the credentials file.
- The attacker extracts the
accessToken. - The attacker submits requests with `Authorization: Bearer <accessToken& ...[truncated 956 chars]
- Remediation
View remediation
Remediation Suggestions
- Store the bearer token in an operating-system keychain, protected credential service, or dedicated secret manager rather than in the project directory.
- If file-based storage is unavoidable:
- Create the file atomically with owner-only permissions such as
0600. - Ensure its parent directory is accessible only to the owning user.
- Validate file ownership and permissions before reading it.
- Refuse to read symbolic links or files owned by another user.
- Avoid temporary files containing the token.
- Create the file atomically with owner-only permissions such as
- Add
.credentialsto version-control ignore rules and explicitly exclude it from logs, diagnostics, exports, and ordinary backups. - Never display or log the token, authorization header, token-exchange response, or credentials-file contents.
- Store only fields required for authentication; do not add profile or unrelated personal data to the credentials file.
- On logout, revoke the token through a server-side revocation endpoint when available before securely removing the local credential.
- Prefer short-lived access tokens with refresh-token rotation, narrowly scoped permissions, and server-side replay detection where supported.
