Credential Hygiene Validator
Checks whether credentials and tokens in config files are stored
with reasonable hygiene. Catches common mistakes before they become
incidents.
What it checks
- 1. File permissions -- config files should be 600 or 700, not world-readable
- Plaintext tokens -- scans for hex tokens, JWTs (base64url with dots), Bearer strings, and API keys
- Git repo contamination -- whether the config directory sits inside a git working tree
- Gitignore coverage -- whether .gitignore excludes credential paths
- Log file leaks -- tokens appearing in log output (checks all formats: hex, JWT, Bearer per RFC 6750)
- Token age -- warns if tokens have not been rotated recently
- Atomic write safety -- checks if config backup exists (indicator of safe write patterns)
When to use it
- - After setting up a new tool or service
- Before pushing dotfiles to a public repo
- As part of a regular security hygiene review
- When onboarding a new machine
- After rotating credentials, to confirm the old token is gone
Example prompts
- - "Check if my OpenClaw tokens are stored safely"
- "Audit my dotfiles for leaked credentials"
- "Is my config directory in a git repo?"
- "Check file permissions on my credentials"
- "Are my tokens showing up in any log files?"
Checks run
CODEBLOCK0
Notes
- - Read-only checks, does not modify any files
- Token patterns match hex, JWT (header.payload.signature), base64url,
and Bearer headers case-insensitively per RFC 6750
- - Works with any tool that stores credentials in dotfiles
- Aligns with T-ACCESS-003 in the OpenClaw threat model
References
凭据卫生验证器
检查配置文件中的凭据和令牌是否以合理的卫生方式存储。在常见错误演变为安全事件之前将其捕获。
检查内容
- 1. 文件权限 -- 配置文件应为600或700,不可全局可读
- 明文令牌 -- 扫描十六进制令牌、JWT(带点的base64url)、Bearer字符串和API密钥
- Git仓库污染 -- 配置目录是否位于Git工作树内
- Gitignore覆盖 -- .gitignore是否排除了凭据路径
- 日志文件泄露 -- 日志输出中出现的令牌(检查所有格式:十六进制、JWT、符合RFC 6750的Bearer)
- 令牌时效 -- 若令牌近期未轮换则发出警告
- 原子写入安全 -- 检查是否存在配置备份(安全写入模式的指示器)
使用时机
- - 设置新工具或服务后
- 将点文件推送到公共仓库前
- 作为定期安全卫生审查的一部分
- 配置新机器时
- 轮换凭据后,确认旧令牌已清除
示例提示
- - 检查我的OpenClaw令牌是否安全存储
- 审计我的点文件是否存在凭据泄露
- 我的配置目录是否在Git仓库中?
- 检查我的凭据文件权限
- 我的令牌是否出现在任何日志文件中?
执行的检查
bash
1. 文件权限
stat -c %a %n ~/.openclaw/openclaw.json
预期结果:600
2. 明文令牌(符合RFC 7235的完整token68字符集)
grep -rnP (token\s
:\s)[^]{8,}|[Bb]earer\s+[\w\-\.+/=~]{16,}|[a-f0-9]{32,} \
~/.openclaw/ --include=*.json 2>/dev/null
3. Git仓库检查
git -C ~/.openclaw rev-parse --is-inside-work-tree 2>/dev/null
预期结果:错误(不在仓库中)
4. Gitignore覆盖
grep -q .openclaw ~/.gitignore 2>/dev/null && echo 已覆盖 || echo 未覆盖
5. 日志文件泄露(完整token68字符集)
grep -rnP [Bb]earer\s+[\w\-\.+/=~]{16,}|[a-f0-9]{32,} \
~/.openclaw/logs/ --include=*.log 2>/dev/null
6. 令牌时效(检查配置文件修改时间)
find ~/.openclaw/openclaw.json -mtime +90 -print 2>/dev/null
若有输出:令牌已超过90天未轮换
7. 备份文件是否存在(原子写入指示器)
ls ~/.openclaw/openclaw.json.bak 2>/dev/null && echo 存在备份 || echo 无备份
注意事项
- - 只读检查,不会修改任何文件
- 令牌模式匹配十六进制、JWT(header.payload.signature)、base64url和Bearer头(不区分大小写,符合RFC 6750)
- 适用于任何将凭据存储在点文件中的工具
- 与OpenClaw威胁模型中的T-ACCESS-003保持一致
参考