一键导入
cash-audit
Audit changed code for security sharp edges — dangerous defaults, type confusion, and silent failures
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Audit changed code for security sharp edges — dangerous defaults, type confusion, and silent failures
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Analyze artifact consistency for a change
Implement Cash tasks with a sub-agent quality gate after completion
Archive a completed change
Query openspec/documents and answer questions
Commit files related to a specific Cash change
Systematically debug a problem using a four-phase workflow
| name | cash-audit |
| description | Audit changed code for security sharp edges — dangerous defaults, type confusion, and silent failures |
| license | MIT |
| metadata | {"author":"cash","version":"1.0"} |
執行任何 Cash artifact command 前,MUST 先從目前目錄解析並驗證 Git root,再使用該 root 下的 absolute launcher;不得依賴 PATH 或外部 runtime:
cash_root="$(git rev-parse --show-toplevel)" || exit 1
cash_cli="$cash_root/.cash-skills/bin/cash"
test -x "$cash_cli" || exit 1
同一段 workflow 後續每個 artifact command MUST 使用 "$cash_cli"。
Audit changed code for security sharp edges — API design traps, dangerous defaults, and interfaces that make it easy to do the wrong thing.
Good APIs don't require developers to "be careful" to stay secure. If the correct usage requires reading docs, remembering rules, or understanding cryptography, the API has failed.
Core principle: Security should be the path of least resistance. Insecure usage should be harder than secure usage.
This skill operates in two modes depending on how it's invoked:
$cash-audit): Full 3-agent parallel analysis on current git diff. See Standalone Mode.$cash-apply when audit: true): Condensed checklist applied during implementation. See Discipline Mode.Both modes share the same Core Framework.
When invoked directly as $cash-audit:
Run git diff HEAD to get the full diff of current modifications.
If there are no changes, report "No changes to audit" and stop.
Launch 3 agents in parallel (one message, 3 tool calls). Each agent receives the full diff and analyzes it through one adversary lens.
Agent 1 — The Scoundrel (壞蛋)
A malicious developer or attacker deliberately manipulating configuration.
Search the diff for:
"none", "md5")auth_required: true + bypass_auth_for_health: true + health_check_path: "/")Agent 2 — The Lazy Developer (懶惰的開發者)
A developer who copy-pastes examples and skips documentation.
Search the diff for:
verify: false, timeout: 0, empty strings as keystimeout=0, max_attempts=0, key="" mean?Agent 3 — The Confused Developer (搞混的開發者)
A developer who misunderstands API usage.
Search the diff for:
encrypt(msg, key, nonce) — key and nonce are both strings)verify_ssl: fasle)Merge findings from all 3 agents. For each finding:
End with a brief summary of what was fixed (or confirm the code is clean).
When referenced by $cash-apply (via "$cash_cli" instructions --skill audit), do NOT launch the 3-agent workflow above. Instead, apply this condensed checklist continuously during implementation.
Before finalizing any code that involves APIs, configuration, parameters, or security-related logic, ask:
Stop and fix immediately if you notice:
false → is the "off" state safe?if value == 0 or if key.nil? → what does zero/nil MEAN in this context?Not every line of code needs audit scrutiny. Focus on:
Response language: All user-facing responses in this workflow MUST be written in Traditional Chinese unless the user explicitly requests another language. Keep shell commands, file paths, code identifiers, schema field names, and quoted source text verbatim.
| Role | Mindset | Key Questions |
|---|---|---|
| Scoundrel | Malicious, deliberate exploitation | Can I disable security via config? Downgrade algorithms? Inject values? |
| Lazy Developer | Copy-paste, skips docs, deadline pressure | Is the first example safe? Is the default secure? Do errors guide me right? |
| Confused Developer | Misunderstands usage | Can I swap params silently? Will mistakes fail loudly? Are types distinguishable? |
Letting developers choose algorithms = inviting them to choose wrong.
# Dangerous: accepts arbitrary algorithm
OpenSSL::Digest.new(algorithm).hexdigest(password) # algorithm = "md5"?
# Safe: no choice
BCrypt::Password.create(password) # can't pick wrong
Defaults that are insecure, or zero/empty values that disable security. Insecure defaults cannot be grandfathered for backwards compatibility; deprecate them loudly and require migration.
# What does timeout=0 mean? Never expire? Expire immediately?
def verify_token(token, timeout: 300)
return true if timeout == 0 # 0 = skip verification?!
end
Key question: What do timeout=0, max_attempts=0, key="", nil each mean?
Using raw bytes/strings instead of meaningful types invites type confusion.
# Dangerous: both params are strings, swappable
encrypt(message, key, nonce)
# Safe: types protect against swapping
encrypt(message, Key.new(k), Nonce.new(n))
One wrong config value = disaster, with no warning.
# A typo = security mechanism disappears
verify_ssl: fasle # not "false", might be treated as truthy?
# Dangerous combination
auth_required: true
bypass_auth_for_health: true
health_check_path: "/" # oops, entire site bypasses auth
Security errors that don't surface, or "success" masking failure.
# Silent bypass
def verify_signature(sig, data, key)
return true if key.nil? # no key = skip verification?!
end
# Return value ignored
result = crypto.verify(data, sig) # returns false but nobody checks
Security-critical values as plain strings = open door for injection and confusion.
# Dangerous: string concatenation
permissions = "read,write"
permissions += ",admin" # too easy to escalate
# Safe: use enums
permissions = Set[Permission::READ, Permission::WRITE]
| Severity | Condition | Example |
|---|---|---|
| Critical | Default or most obvious usage is insecure | verify: false is default, empty password accepted |
| High | Easy misconfiguration breaks security | Algorithm param accepts "none" |
| Medium | Uncommon but possible misconfiguration | Negative timeout has unexpected behavior |
| Low | Requires deliberate misuse | Obscure parameter combination |