T09 · Insecure Skill Coding Practices
- Location
SKILL.md:36- Finding
Credential File Is Stored Without Mandatory Access-Control Safeguards
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 36-48
Vulnerability Type: Plaintext sensitive-data storage with unspecified file permissions
Risk Level: MediumVulnerable Code Snippet
markdown ## Credential Storage AK/SK and Token are read from the same local config file. - **Path**: `~/.chanjing/credentials.json` (overridable by env `CHANJING_CONFIG_DIR`) - **Format**: ```json { "app_id": "Your Access Key", "secret_key": "Your Secret Key", "access_token": "Optional, auto-generated", "expire_in": 1721289220 }text Related instructions at `SKILL.md:97-103` direct users to populate and subsequently reopen this file: ```markdown 3. **Ask user to configure local file** `~/.chanjing/credentials.json` (or `$CHANJING_CONFIG_DIR/credentials.json`) with `app_id` and `secret_key`. 4. **Secret handling rule**: - Do not ask user to paste AK/SK in chat. - If user shares secret in chat anyway, remind them to rotate keys and continue with local-command-only flow. 5. **After setting**: - Re-open the local file to confirm non-empty `app_id` and `secret_key`. - Then proceed to target Chanjing action.Technical Analysis
The Skill directs users or an implementing agent to store a long-lived Chanjing Secret Key and an access token in a plaintext JSON file. This storage is consistent with the Skill's declared credential-management purpose, but the instructions do not require the containing directory or file to have restrictive permissions.
The resulting permissions depend on the user's umask, the editor or command used to create the file, and whether the path already exists. A permissive configuration could make the credential file readable by other local users or processes. The instructions also do not require ownership validation, symbolic-link rejection, or atomic replacement when updating the token. Consequently, an attacker with local filesystem acce ...[truncated 1912 chars]
- Remediation
View remediation
Remediation Suggestions
-
Require the credential directory to be owned by the current user and have mode
0700. -
Require
credentials.jsonto be a regular file owned by the current user with mode0600. -
Provide safe local setup commands that use a restrictive umask, for example:
sh umask 077 mkdir -p "${CHANJING_CONFIG_DIR:-$HOME/.chanjing}" chmod 700 "${CHANJING_CONFIG_DIR:-$HOME/.chanjing}" -
Before every read or write, reject symbolic links, unexpected file types, incorrect ownership, and paths outside the intended configuration directory.
-
Write refreshed tokens to a securely created temporary file in the same directory, set mode
0600, flush it, and atomically rename it over the credential file. -
Avoid logging the request body, Secret Key, or access token. Ensure errors and summaries redact all credential values.
-
Prefer an operating-system credential store or secret manager for the Secret Key where supported. If JSON compatibility is required, retain only the minimum necessary fields.
-
Document credential rotation and revocation procedures for cases where unsafe permissions or accidental disclosure are detected.
-
Validate that
CHANJING_CONFIG_DIRresolves to a user-approved local directory before accessing it.
-
