codeprobe-security
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStandalone Mode
独立模式
If invoked directly (not via the orchestrator), you must first:
- Read for the output contract, execution modes, and constraints.
../codeprobe/shared-preamble.md - Load applicable reference files from based on the project's tech stack.
../codeprobe/references/ - Default to mode unless the user specifies otherwise.
full
如果直接调用(不通过编排器),您必须先执行以下步骤:
- 阅读文件,了解输出协议、执行模式和约束条件。
../codeprobe/shared-preamble.md - 根据项目的技术栈,加载目录下的适用参考文件。
../codeprobe/references/ - 除非用户另行指定,否则默认使用模式。
full
Security Vulnerability Scanner
安全漏洞扫描器
Domain Scope
适用范围
This sub-skill detects security vulnerabilities across these categories:
- Injection — SQL injection, command injection, LDAP/NoSQL injection
- Authentication & Authorization — Missing auth, weak credentials, hardcoded secrets, JWT issues
- Cross-Site Scripting (XSS) — Unescaped output, dangerous HTML rendering
- Mass Assignment — Unprotected model attribute assignment
- Cross-Site Request Forgery (CSRF) — Missing tokens, unprotected state-changing routes
- Insecure Deserialization — Unsafe deserialization of untrusted data
- Sensitive Data Exposure — Secrets in logs, committed .env files, leaked stack traces
- Broken Access Control — IDOR, missing policy/gate checks
- Security Misconfiguration — Debug mode in production, permissive CORS, default credentials
该子技能可检测以下类别的安全漏洞:
- 注入 — SQL injection、command injection、LDAP/NoSQL injection
- 认证与授权 — 缺失认证机制、弱凭据、硬编码密钥、JWT相关问题
- Cross-Site Scripting (XSS) — 未转义输出、危险HTML渲染
- 批量赋值 — 未受保护的模型属性赋值
- Cross-Site Request Forgery (CSRF) — 缺失令牌、未受保护的状态变更路由
- 不安全反序列化 — 对不可信数据进行不安全反序列化
- 敏感数据泄露 — 日志中的密钥、已提交的.env文件、泄露的堆栈跟踪
- 访问控制失效 — IDOR、缺失策略/网关检查
- 安全配置错误 — 生产环境启用调试模式、宽松的CORS设置、默认凭据
What It Does NOT Flag
不会标记的内容
- Internal admin tools with IP-restricted access — these have a different threat model and the restriction may be intentional.
- Test files using hardcoded values — test fixtures with fake credentials, tokens, and API keys are expected and appropriate.
- Development-only configuration files clearly marked as such (e.g., ,
.env.example, files indocker-compose.dev.yml).tests/fixtures/ - Dependencies with known CVEs — this sub-skill analyzes source code, not dependency manifests. Use dedicated tools (e.g., ,
npm audit) for dependency scanning.composer audit
- IP限制访问的内部管理工具 — 这类工具的威胁模型不同,IP限制可能是有意设置的。
- 使用硬编码值的测试文件 — 测试用例中的假凭据、令牌和API密钥是合理且符合预期的。
- 明确标记为仅用于开发的配置文件(例如、
.env.example、docker-compose.dev.yml目录下的文件)。tests/fixtures/ - 存在已知CVE的依赖项 — 该子技能仅分析源代码,不扫描依赖清单。请使用专用工具(如、
npm audit)进行依赖项扫描。composer audit
Detection Instructions
检测说明
Injection
注入
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Raw SQL with string concatenation/interpolation | Search for SQL keywords ( | Critical |
| | Search for | Critical |
| Shell command construction with unsanitized input | Search for | Critical |
| LDAP/NoSQL injection vectors | Search for LDAP filter construction with string concatenation, MongoDB query construction with user input in | Critical |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| 带有字符串拼接/插值的原生SQL | 搜索SQL关键字( | 严重 |
| 包含用户输入的 | 搜索 | 严重 |
| 使用未净化输入构造Shell命令 | 搜索 | 严重 |
| LDAP/NoSQL注入向量 | 搜索带有字符串拼接的LDAP过滤器构造、在 | 严重 |
Authentication & Authorization
认证与授权
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Missing auth middleware on routes that modify data | Scan route definitions (e.g., | Critical |
| Role checks done in view/frontend but not backend | Search for role/permission checks in frontend templates or JavaScript (e.g., | Major |
| Hardcoded secrets/API keys in source code | Search for patterns: | Critical |
| Weak password policy | Look for user registration/password-change logic. Check whether password validation enforces minimum length (8+ chars), complexity, or uses a validation library. Flag if passwords are accepted without any validation rules. | Major |
| JWT without expiration | Search for JWT creation/signing code. Check whether the payload includes an | Major |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| 修改数据的路由缺失认证中间件 | 扫描路由定义(如 | 严重 |
| 仅在视图/前端进行角色检查而未在后端执行 | 搜索前端模板或JavaScript中的角色/权限检查(如 | 主要 |
| 源代码中的硬编码密钥/API密钥 | 搜索以下模式: | 严重 |
| 弱密码策略 | 查找用户注册/密码修改逻辑。检查密码验证是否强制要求最小长度(8个字符以上)、复杂度,或是否使用了验证库。如果密码未经过任何验证规则就被接受,则进行标记。 | 主要 |
| 无过期时间的JWT | 搜索JWT创建/签名代码。检查载荷是否包含 | 主要 |
Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| | Search for | Major |
| | Search for | Major |
| | Search for | Major |
| Missing Content-Security-Policy | Check for CSP headers in middleware, web server config, or meta tags. If no CSP is configured anywhere in the project, flag as a defense-in-depth gap. | Minor |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| Laravel Blade中包含用户数据的 | 在 | 主要 |
| React中使用不可信数据的 | 在 | 主要 |
| Vue中使用不可信数据的 | 在 | 主要 |
| 缺失内容安全策略(CSP) | 检查中间件、Web服务器配置或元标签中的CSP头。如果项目中未配置任何CSP,则标记为深度防御缺口。 | 次要 |
Mass Assignment
批量赋值
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Laravel model without | Search for Eloquent model classes (extending | Major |
| Accepting | Search for | Critical |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| 未设置 | 搜索Eloquent模型类(继承自 | 主要 |
| 将 | 搜索 | 严重 |
Cross-Site Request Forgery (CSRF)
Cross-Site Request Forgery (CSRF)
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Forms without CSRF tokens | Search for | Major |
| API routes without proper auth that modify state | Check API routes (POST/PUT/PATCH/DELETE) that lack both CSRF protection AND authentication middleware. Stateless APIs with token auth are fine; session-based APIs without CSRF tokens are not. | Major |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| 缺失CSRF令牌的表单 | 搜索带有 | 主要 |
| 修改状态且未正确认证的API路由 | 检查既无CSRF保护又无认证中间件的API路由(POST/PUT/PATCH/DELETE)。使用令牌认证的无状态API是安全的;基于会话且无CSRF令牌的API则不安全。 | 主要 |
Insecure Deserialization
不安全反序列化
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| | Search for | Critical |
| | Search for | Major |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| 对用户输入执行 | 搜索 | 严重 |
| 在类eval上下文中使用未验证的 | 搜索对外部数据执行 | 主要 |
Sensitive Data Exposure
敏感数据泄露
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| Passwords/tokens in log statements | Search for logging calls ( | Critical |
| | Check whether | Critical |
| Secrets in config files vs environment variables | Search config files for hardcoded credentials, API keys, database passwords. Flag values that should come from environment variables but are instead hardcoded in tracked config files. | Major |
| Error messages leaking stack traces in production config | Check error/exception handling configuration. Look for | Major |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| 日志语句中的密码/令牌 | 搜索日志调用( | 严重 |
| .env文件已提交至git | 检查 | 严重 |
| 配置文件中的密钥而非环境变量 | 搜索配置文件中的硬编码凭据、API密钥、数据库密码。标记应来自环境变量但却硬编码在已追踪配置文件中的值。 | 主要 |
| 生产配置中泄露堆栈跟踪的错误信息 | 检查错误/异常处理配置。查找 | 主要 |
Broken Access Control
访问控制失效
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| IDOR — using user-supplied ID without ownership check | Search for route parameters or request params (e.g., | Critical |
| Missing policy/gate checks on resource access | In frameworks with authorization systems (Laravel policies, Django permissions, Express middleware), check whether CRUD operations on user-owned resources include authorization checks. Flag controller actions that read/modify resources without policy or permission verification. | Major |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| IDOR——使用用户提供的ID但未检查所有权 | 搜索路由参数或请求参数(如 | 严重 |
| 资源访问缺失策略/网关检查 | 在带有授权系统的框架(Laravel策略、Django权限、Express中间件)中,检查用户拥有资源的CRUD操作是否包含授权检查。标记未经过策略或权限验证就读取/修改资源的控制器操作。 | 主要 |
Security Misconfiguration
安全配置错误
| ID Prefix | What to Detect | How to Detect | Severity |
|---|---|---|---|
| | Search for | Major |
| Permissive CORS | Search for CORS configuration. Flag | Major |
| Default credentials in configuration | Search for usernames like | Critical |
| ID前缀 | 检测内容 | 检测方式 | 严重程度 |
|---|---|---|---|
| 生产配置中 | 在看似生产配置的文件(非 | 主要 |
| 宽松的CORS设置 | 搜索CORS配置。在非公开API场景中,标记 | 主要 |
| 配置中的默认凭据 | 在配置文件、种子文件或初始化代码中搜索用户名如 | 严重 |
ID Prefix & Fix Prompt Examples
ID前缀与修复提示示例
All findings use the prefix, numbered sequentially: , , etc.
SEC-SEC-001SEC-002所有检测结果均使用前缀,并按顺序编号:、等。
SEC-SEC-001SEC-002Fix Prompt Examples
修复提示示例
- "In (line 34), replace
UserController@updatewith$request->all()to prevent mass assignment on the$request->only(['name', 'email'])field. Also addis_adminto the$fillable = ['name', 'email']model if not already present."User - "Wrap the user input at line 55 of in a parameterized query: change
app/Services/SearchService.phptoDB::select(\"SELECT * FROM products WHERE name LIKE '%$search%'\")."DB::select('SELECT * FROM products WHERE name LIKE ?', [\"%{$search}%\"]) - "In , add auth middleware to the
routes/api.phproute at line 22: changePOST /api/orderstoRoute::post('/orders', [OrderController::class, 'store'])."Route::post('/orders', [OrderController::class, 'store'])->middleware('auth:sanctum') - "Move the hardcoded API key at line 15 of to an environment variable: replace
config/services.phpwith'key' => 'sk-live-abc123...'and add'key' => env('STRIPE_SECRET_KEY')toSTRIPE_SECRET_KEY=.".env.example
- "在(第34行)中,将
UserController@update替换为$request->all(),以防止对$request->only(['name', 'email'])字段进行批量赋值。如果is_admin模型尚未设置User,请添加该属性。"$fillable = ['name', 'email'] - "将第55行的用户输入包装在参数化查询中:将
app/Services/SearchService.php修改为DB::select(\"SELECT * FROM products WHERE name LIKE '%$search%'\")."DB::select('SELECT * FROM products WHERE name LIKE ?', [\"%{$search}%\"]) - "在中,为第22行的
routes/api.php路由添加认证中间件:将POST /api/orders修改为Route::post('/orders', [OrderController::class, 'store'])."Route::post('/orders', [OrderController::class, 'store'])->middleware('auth:sanctum') - "将第15行的硬编码API密钥移至环境变量:将
config/services.php替换为'key' => 'sk-live-abc123...',并在'key' => env('STRIPE_SECRET_KEY')中添加.env.example。"STRIPE_SECRET_KEY=