T09 · Insecure Skill Coding Practices
- Location
scripts/audit.cjs:55- Finding
Authentication Token Disclosure in Audit Output
- Content
View full analysis
Vulnerability Details
File Location:
scripts/audit.cjs, lines 55–59 and 108
Vulnerability Type: Sensitive credential exposure through terminal and log output
Risk Level: MediumVulnerable Code
js if (token.length < 32 || isDefault) { const masked = token.length > 8 ? token.slice(0, 8) + '...' : token || '(空)'; findings.push({ key: 'gateway.auth.token', current: masked, suggested: '至少 32 位强随机字符串', reason: 'Token 过短或为默认值,存在认证风险', action: '请手动生成并替换为至少 32 位的强随机 token' }); }The resulting value is later printed:
js console.log(` 当前值: ${item.current}`);Technical Analysis
The script reads
gateway.auth.tokenfrom~/.openclaw/openclaw.jsonand includes part or all of that credential in an audit finding. Tokens longer than eight characters disclose their first eight characters, while tokens containing eight or fewer characters are disclosed completely.Displaying credential material is unnecessary for determining whether the token is weak. Audit output may be retained in shell history captures, CI/CD logs, support bundles, terminal recordings, or centralized monitoring systems. This expands access to the token beyond users authorized to read the original configuration file.
Attack Path
- An OpenClaw installation is configured with a weak or default authentication token.
- An operator invokes
node scripts/audit.cjs. - The script reads the token from
~/.openclaw/openclaw.json. - Because the token is short or recognized as a default, the script stores either the complete token or its first eight characters in a finding.
printFindings()writes that value to standard output.- A user or service able to access captured audit output obtains the token or a useful token prefix.
- If the complete token was exposed, an attacker may attempt direct authentication. If only a prefix was exposed, the attacker may use it to reduce the search space for guessing or brute-force attacks.
...[truncated 624 chars]
- Remediation
View remediation
Remediation Suggestions
- Never include token characters in findings or diagnostic output.
- Replace the
currentvalue with a non-sensitive status such as"(configured but weak)". - Avoid reporting exact token length unless operationally necessary.
- Ensure future logging and exception paths do not serialize the configuration object or authentication values.
- Treat existing audit logs as potentially sensitive. Restrict access and remove retained output containing exposed tokens where appropriate.
- Rotate any token that may already have been printed to shared terminals, CI/CD logs, support bundles, or centralized logging systems.
A safer implementation would be:
js if (token.length < 32 || isDefault) { findings.push({ key: 'gateway.auth.token', current: '(configured but weak)', suggested: 'At least 32 cryptographically random characters', reason: 'The token is too short or uses a default value', action: 'Generate and install a strong random token without printing it' }); }
