Security Audit
Run scripts/audit.py before every commit, push, or skill publish. No exceptions.
When to run
| Trigger | Command |
|---|
| Before INLINECODE1 | INLINECODE2 |
| Before INLINECODE3 |
python3 {skill_dir}/scripts/audit.py --last-commit |
| Before
clawhub publish <path> |
python3 {skill_dir}/scripts/audit.py <skill_path> |
| Ad-hoc scan any path |
python3 {skill_dir}/scripts/audit.py <path> |
INLINECODE8 = INLINECODE9
Exit codes
- -
0 = clean - INLINECODE11 = HIGH or MEDIUM findings (block publish/push)
- INLINECODE12 = usage error
What it detects
| Severity | Pattern |
|---|
| 🔴 HIGH | API keys, secrets, passwords, JWT tokens, WooCommerce keys, AWS keys, private key blocks, bearer tokens, .env files |
| 🟡 MEDIUM |
Absolute
/home/<user>/ paths,
/root/ paths, refresh tokens,
node_modules/ committed |
| 🔵 LOW | Hardcoded IPs, long base64 strings |
Rules
- 1. HIGH findings = hard block. Never commit or publish with HIGH findings. Rotate any exposed secret immediately.
- MEDIUM findings = fix before publish. Replace absolute paths with relative or env-var defaults. Remove
node_modules/. - LOW findings = review. Not blocking but investigate.
- False positives: If a match is a variable name or safe placeholder (not an actual value), document why it's safe in a comment and re-run.
After finding a real secret
- 1. Do NOT push the commit. If already pushed: rotate the secret immediately, then rewrite history or delete the file from git.
- Rotate in the provider portal (TikTok Dev, AWS IAM, WooCommerce, etc.)
- Move to env var:
process.env.SECRET_NAME or read from a local config file outside the repo. - Add the config file path to
.gitignore. - Report to Aladdin immediately with severity and what was exposed.
Skill publish checklist
Before clawhub publish:
- - [ ]
audit.py <skill_path> returns 0 (clean) - [ ]
node_modules/ not present in skill folder - [ ] No absolute paths to user home directories
- [ ] No hardcoded business-specific IDs or credentials
- [ ]
package.json name matches skill folder name - [ ] SKILL.md description updated if renamed
安全审计
每次提交、推送或发布技能前,必须运行 scripts/audit.py,无一例外。
何时运行
| 触发条件 | 命令 |
|---|
| 执行 git commit 前 | python3 {skilldir}/scripts/audit.py --staged |
| 执行 git push 前 |
python3 {skilldir}/scripts/audit.py --last-commit |
| 执行 clawhub publish
前 | python3 {skilldir}/scripts/audit.py path> |
| 临时扫描任意路径 | python3 {skill_dir}/scripts/audit.py |
{skill_dir} = /home/aladdin/.openclaw/workspace/skills/skill-security-audit
退出码
- - 0 = 干净
- 1 = 存在高危或中危发现(阻止发布/推送)
- 2 = 使用错误
检测内容
| 严重级别 | 模式 |
|---|
| 🔴 高危 | API密钥、机密信息、密码、JWT令牌、WooCommerce密钥、AWS密钥、私钥块、Bearer令牌、.env文件 |
| 🟡 中危 |
绝对路径 /home//、/root/ 路径、刷新令牌、已提交的 node_modules/ |
| 🔵 低危 | 硬编码IP、长base64字符串 |
规则
- 1. 高危发现 = 硬性阻止。 绝不允许在存在高危发现的情况下提交或发布。立即轮换任何已暴露的机密信息。
- 中危发现 = 发布前修复。 将绝对路径替换为相对路径或环境变量默认值。移除 node_modules/。
- 低危发现 = 审查。 不阻止但需调查。
- 误报处理: 如果匹配项是变量名或安全占位符(非实际值),请在注释中说明其安全性原因,然后重新运行。
发现真实机密信息后的处理
- 1. 不要推送该提交。 如果已推送:立即轮换该机密信息,然后重写历史记录或从git中删除该文件。
- 在提供商门户(TikTok开发者平台、AWS IAM、WooCommerce等)中轮换。
- 迁移至环境变量:process.env.SECRET_NAME 或从仓库外的本地配置文件中读取。
- 将配置文件路径添加到 .gitignore。
- 立即向Aladdin报告,说明严重级别和暴露的内容。
技能发布检查清单
执行 clawhub publish 前:
- - [ ] audit.py path> 返回0(干净)
- [ ] 技能文件夹中不存在 node
modules/[ ] 无指向用户主目录的绝对路径[ ] 无硬编码的业务特定ID或凭据[ ] package.json 中的名称与技能文件夹名称一致[ ] 如果已重命名,更新SKILL.md中的描述