security-review

A code-security review guide covering common risks such as injection, weak login protection, unauthorized access, and sensitive-data exposure. It is written in Chinese and includes rules and examples for safer code.

In plain words
What is it for?
Use it when reviewing new features, authentication, database queries, file handling, third-party dependencies, or external API integrations, and when investigating a security report.
Why use it?
It helps find security problems before code reaches users or helps assess the impact of a reported vulnerability. It focuses on mistakes that can expose data, bypass permissions, or let attackers run unwanted commands.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/security-review
Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill security-review
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,430 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00028 $0.02430
Opus 5 $0.00014 $0.01215
Sonnet 5 $0.00006 $0.00486
Haiku 4.5 $0.00003 $0.00243

Measured 2d ago against content hash 5b8ea0e94cae, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

security-review scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

# 反例:os.system 拼接
skills/security-review/SKILL.md · 210 lines

How it starts

The opening of the file, as written. The whole thing — 210 lines — stays where its author put it; the contents beside it link to each section on GitHub.

安全审查

何时用

  • 新功能上线前做安全审查。
  • 代码涉及用户输入处理、认证鉴权、数据库查询、文件操作时。
  • 接到安全漏洞报告,需要定位和评估影响范围时。
  • 引入第三方依赖或集成外部 API 前。

核心规则

1. 输入即不可信:防注入(SQL / 命令 / XSS)

规则: 所有来自外部的数据(HTTP 参数、请求体、文件内容、消息队列、环境变量)默认不可信;SQL 查询用参数化语句,系统命令用参数列表而非字符串拼接,HTML 输出做转义。

为什么: AI 生成数据库查询时极容易回退到字符串拼接:"SELECT * FROM users WHERE id=" + userId。在 userId 为 "1 OR 1=1" 时整张表被泄露,为 "1; DROP TABLE users--" 时数据被删除。2023 年 OWASP Top 10 注入漏洞仍居首位,AI 代码贡献了相当比例的新增漏洞。

怎么做:

# 反例:字符串拼接
query = f"SELECT * FROM users WHERE name='{name}'"
cursor.execute(query)

# 正例:参数化查询
cursor.execute("SELECT * FROM users WHERE name = %s", (name,))
# 反例:os.system 拼接
os.system(f"ffmpeg -i {filename} output.mp4")

# 正例:参数列表,不经 shell 解释
subprocess.run(["ffmpeg", "-i", filename, "output.mp4"], check=True)
  • 前端输出用模板引擎的自动转义(如 Jinja2 的 {{ var }}),禁止用 innerHTML = userInput

2. 认证与会话:加盐哈希、有效期、防爆破

规则: 密码存储用 bcrypt/Argon2(禁用 MD5/SHA1/SHA256 直接哈希);session token 和 JWT 设置合理有效期并支持服务端撤销;登录接口做频率限制防爆破。

为什么: AI 实现用户注册时,最常见的错误是 hashlib.sha256(password.encode()).hexdigest() 存库。SHA256 无盐、速度极快,彩虹表或 GPU 暴力破解成本极低;一旦数据库泄露,大量账号密码几分钟内被还原。另一个常见问题:AI 生成的 JWT 不设 exp 字段,token 一旦泄露永久有效,撤销无从实现。

怎么做:

import bcrypt

# 存储:自动加盐
hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))

# 验证
bcrypt.checkpw(password.encode(), hashed)
import jwt
from datetime import datetime, timedelta, timezone

token = jwt.encode({
    "sub": user_id,
    "exp": datetime.now(timezone.utc) + timedelta(hours=1),  # ✅ 设有效期
    "jti": str(uuid4()),                                      # ✅ 支持黑名单撤销
}, SECRET_KEY, algorithm="HS256")
  • 登录接口接入 rate limiter(如 flask-limiter),同 IP 5 次失败后锁定 15 分钟。

3. 越权检查:服务端逐操作校验,不只前端隐藏

规则: 每个修改/查询敏感数据的 API,都在服务端校验"当前登录用户是否有权访问这条数据"(对象级权限,OWASP BOLA/IDOR);前端隐藏按钮或菜单不构成权限控制。

为什么: AI 生成 CRUD API 时极少主动加资源所有权校验,只校验"用户是否已登录",不校验"用户是否拥有这条记录"。攻击者只需将 URL 中的 id=123 改为 id=124 就能访问或修改其他人的数据(IDOR 漏洞)。这类漏洞在 AI 生成的代码中出现频率极高,因为 AI 习惯生成通用模板而非针对业务的细粒度鉴权。

Read the full file on GitHub · 210 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 210 lines · 28 tokens per session scan A 5b8ea0e94cae

Subscribe to this mod's changes

security-review is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (6 stars, last pushed 2mo ago), licensed MIT. It adds 28 tokens to every session and 2,430 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

chinese-documentation

中文文档排版参考——中英文空格、全半角标点、术语保留、链接格式、中文文案排版指北约定。仅在用户显式 /chinese-documentation 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

chinese-git-workflow

国内 Git 平台配置参考——Gitee、Coding.net、极狐 GitLab、CNB 的 SSH/HTTPS/凭据/CI 接入差异与镜像同步配置。仅在用户显式 /chinese-git-workflow 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 69 tokens

brainstorming

在任何创造性工作之前必须使用此技能——创建功能、构建组件、添加功能或修改行为。在实现之前先探索用户意图、需求和设计。.

jnMetaCode/superpowers-zh · 40 tokens

chinese-code-review

中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 62 tokens

chinese-commit-conventions

中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。.

jnMetaCode/superpowers-zh · 65 tokens

mcp-builder

MCP 服务器构建方法论 — 系统化构建生产级 MCP 工具,让 AI 助手连接外部能力.

jnMetaCode/superpowers-zh · 32 tokens