T09 · Insecure Skill Coding Practices
- Location
SKILL.md:202- Finding
Plaintext Credential Storage and Disclosure in Command Output
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 202-233
Vulnerability Type: Plaintext sensitive-data storage and credential disclosure
Risk Level: HighVulnerable Code
bash if [ -f "$CACHE_FILE" ]; then accessToken=$(jq -r '.accessToken // empty' "$CACHE_FILE") vehicleToken=$(jq -r '.vehicleToken // empty' "$CACHE_FILE") if [ -n "$accessToken" ] && [ -n "$vehicleToken" ]; then echo "认证信息已存在" echo "accessToken: $accessToken" echo "vehicleToken: $vehicleToken" else echo "认证信息不完整,请提供 vehicleToken####accessToken" fi else echo "未找到认证信息,请提供 vehicleToken####accessToken" fibash # 解析用户输入的 token(格式为 vehicleToken####accessToken) AUTH_INPUT="xxxxxx####xxxxx" vehicleToken=$(echo "$AUTH_INPUT" | awk -F '####' '{print $1}') accessToken=$(echo "$AUTH_INPUT" | awk -F '####' '{print $2}') # 保存到缓存文件(默认使用 PROD 环境) cat > ~/.nokey_vehicle_info_cache.json << EOF { "accessToken": "$accessToken", "vehicleToken": "$vehicleToken", "env": "PROD", "last_updated": "$(date -Iseconds)" } EOFTechnical Analysis
The documented implementation prints both authentication tokens directly to standard output and stores them in an unencrypted JSON file. The cache creation does not set a restrictive
umaskor explicitly apply mode0600. Consequently, effective permissions depend on the user's environment and may allow other local accounts or processes to read the file.Printing the values can additionally expose them through terminal scrollback, shell automation logs, agent transcripts, CI logs, monitoring systems, or support bundles. These are bearer-style credentials, so possession may be sufficient to issue requests without further proof of identity.
The file contains both credentials required by the API:
accessToken, transmitted in theAuthorizationheader.vehicleToken, transmitted in the request ...[truncated 1270 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove all commands that print complete token values. Display only a fixed confirmation or a minimally redacted fingerprint.
- Avoid collecting credentials through persistent conversation history where possible. Use a dedicated secret-input or credential-management mechanism.
- Store credentials in an operating-system keychain, secret service, or narrowly scoped credential store rather than a plaintext JSON file.
- If a local file is unavoidable, create it with restrictive permissions before writing:
bash CACHE_FILE="$HOME/.nokey_vehicle_info_cache.json" umask 077 tmp=$(mktemp "${CACHE_FILE}.XXXXXX") || exit 1 chmod 600 "$tmp" || exit 1 - Write validated JSON to the temporary file and atomically rename it to the destination.
- Reject symbolic links and verify that any existing cache is a regular file owned by the current user.
- Implement token expiration, rotation, deletion, and revocation procedures.
- Ensure logs, errors, API responses, and diagnostic output redact authorization material.
