codeprobe-security

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Standalone Mode

独立模式

If invoked directly (not via the orchestrator), you must first:
  1. Read
    ../codeprobe/shared-preamble.md
    for the output contract, execution modes, and constraints.
  2. Load applicable reference files from
    ../codeprobe/references/
    based on the project's tech stack.
  3. Default to
    full
    mode unless the user specifies otherwise.
如果直接调用(不通过编排器),您必须先执行以下步骤:
  1. 阅读
    ../codeprobe/shared-preamble.md
    文件,了解输出协议、执行模式和约束条件。
  2. 根据项目的技术栈,加载
    ../codeprobe/references/
    目录下的适用参考文件。
  3. 除非用户另行指定,否则默认使用
    full
    模式。

Security Vulnerability Scanner

安全漏洞扫描器

Domain Scope

适用范围

This sub-skill detects security vulnerabilities across these categories:
  1. Injection — SQL injection, command injection, LDAP/NoSQL injection
  2. Authentication & Authorization — Missing auth, weak credentials, hardcoded secrets, JWT issues
  3. Cross-Site Scripting (XSS) — Unescaped output, dangerous HTML rendering
  4. Mass Assignment — Unprotected model attribute assignment
  5. Cross-Site Request Forgery (CSRF) — Missing tokens, unprotected state-changing routes
  6. Insecure Deserialization — Unsafe deserialization of untrusted data
  7. Sensitive Data Exposure — Secrets in logs, committed .env files, leaked stack traces
  8. Broken Access Control — IDOR, missing policy/gate checks
  9. Security Misconfiguration — Debug mode in production, permissive CORS, default credentials

该子技能可检测以下类别的安全漏洞:
  1. 注入 — SQL injection、command injection、LDAP/NoSQL injection
  2. 认证与授权 — 缺失认证机制、弱凭据、硬编码密钥、JWT相关问题
  3. Cross-Site Scripting (XSS) — 未转义输出、危险HTML渲染
  4. 批量赋值 — 未受保护的模型属性赋值
  5. Cross-Site Request Forgery (CSRF) — 缺失令牌、未受保护的状态变更路由
  6. 不安全反序列化 — 对不可信数据进行不安全反序列化
  7. 敏感数据泄露 — 日志中的密钥、已提交的.env文件、泄露的堆栈跟踪
  8. 访问控制失效 — IDOR、缺失策略/网关检查
  9. 安全配置错误 — 生产环境启用调试模式、宽松的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
    ,
    docker-compose.dev.yml
    , files in
    tests/fixtures/
    ).
  • Dependencies with known CVEs — this sub-skill analyzes source code, not dependency manifests. Use dedicated tools (e.g.,
    npm audit
    ,
    composer audit
    ) for dependency scanning.

  • IP限制访问的内部管理工具 — 这类工具的威胁模型不同,IP限制可能是有意设置的。
  • 使用硬编码值的测试文件 — 测试用例中的假凭据、令牌和API密钥是合理且符合预期的。
  • 明确标记为仅用于开发的配置文件(例如
    .env.example
    docker-compose.dev.yml
    tests/fixtures/
    目录下的文件)。
  • 存在已知CVE的依赖项 — 该子技能仅分析源代码,不扫描依赖清单。请使用专用工具(如
    npm audit
    composer audit
    )进行依赖项扫描。

Detection Instructions

检测说明

Injection

注入

ID PrefixWhat to DetectHow to DetectSeverity
SEC
Raw SQL with string concatenation/interpolationSearch for SQL keywords (
SELECT
,
INSERT
,
UPDATE
,
DELETE
,
WHERE
) combined with string concatenation (
.
,
+
,
f"
,
${}
,
"${
), template literals, or variable interpolation. Check that user input flows into the query string without parameterization.
Critical
SEC
DB::raw()
/ raw queries with user input
Search for
DB::raw()
,
DB::select(DB::raw(
,
knex.raw()
,
sequelize.literal()
,
cursor.execute(f"
and similar raw query methods. Flag when the argument contains variables that could originate from user input (request params, form data, query strings).
Critical
SEC
Shell command construction with unsanitized inputSearch for
exec()
,
system()
,
shell_exec()
,
popen()
,
subprocess.call()
,
subprocess.run()
,
child_process.exec()
, backtick operators. Flag when the command string includes variables from user input without escaping or allowlist validation.
Critical
SEC
LDAP/NoSQL injection vectorsSearch for LDAP filter construction with string concatenation, MongoDB query construction with user input in
$where
,
$regex
, or other operators that accept arbitrary expressions.
Critical
ID前缀检测内容检测方式严重程度
SEC
带有字符串拼接/插值的原生SQL搜索SQL关键字(
SELECT
INSERT
UPDATE
DELETE
WHERE
)与字符串拼接(
.
+
f"
${}
"${
)、模板字面量或变量插值的组合。检查用户输入是否未经参数化直接流入查询字符串。
严重
SEC
包含用户输入的
DB::raw()
/原生查询
搜索
DB::raw()
DB::select(DB::raw(
knex.raw()
sequelize.literal()
cursor.execute(f"
及类似的原生查询方法。当参数包含可能来自用户输入(请求参数、表单数据、查询字符串)的变量时进行标记。
严重
SEC
使用未净化输入构造Shell命令搜索
exec()
system()
shell_exec()
popen()
subprocess.call()
subprocess.run()
child_process.exec()
、反引号运算符。当命令字符串包含来自用户输入且未转义或未经过白名单验证的变量时进行标记。
严重
SEC
LDAP/NoSQL注入向量搜索带有字符串拼接的LDAP过滤器构造、在
$where
$regex
或其他接受任意表达式的运算符中使用用户输入的MongoDB查询构造。
严重

Authentication & Authorization

认证与授权

ID PrefixWhat to DetectHow to DetectSeverity
SEC
Missing auth middleware on routes that modify dataScan route definitions (e.g.,
Route::post()
,
router.post()
,
@app.post()
) for POST/PUT/PATCH/DELETE endpoints. Check whether auth middleware is applied. Flag routes that modify data without any authentication layer.
Critical
SEC
Role checks done in view/frontend but not backendSearch for role/permission checks in frontend templates or JavaScript (e.g.,
v-if="user.isAdmin"
,
{user.role === 'admin' && ...}
) and verify that the corresponding backend endpoint also enforces the check. If backend lacks it, flag.
Major
SEC
Hardcoded secrets/API keys in source codeSearch for patterns:
api_key = "..."
,
secret = '...'
,
password = "..."
,
token = '...'
,
AWS_SECRET
,
STRIPE_KEY
, bearer tokens, and similar. Exclude
.env.example
files and test fixtures. Check for high-entropy strings assigned to variables with secret-like names.
Critical
SEC
Weak password policyLook 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
SEC
JWT without expirationSearch for JWT creation/signing code. Check whether the payload includes an
exp
(expiration) claim. Flag JWTs created without expiration or with excessively long expiration (> 24 hours for access tokens).
Major
ID前缀检测内容检测方式严重程度
SEC
修改数据的路由缺失认证中间件扫描路由定义(如
Route::post()
router.post()
@app.post()
)中的POST/PUT/PATCH/DELETE端点。检查是否应用了认证中间件。标记任何未设置认证层的修改数据路由。
严重
SEC
仅在视图/前端进行角色检查而未在后端执行搜索前端模板或JavaScript中的角色/权限检查(如
v-if="user.isAdmin"
{user.role === 'admin' && ...}
),并验证对应的后端端点是否也执行了该检查。如果后端缺失该检查,则进行标记。
主要
SEC
源代码中的硬编码密钥/API密钥搜索以下模式:
api_key = "..."
secret = '...'
password = "..."
token = '...'
AWS_SECRET
STRIPE_KEY
、Bearer令牌等。排除
.env.example
文件和测试用例。检查分配给密钥类变量的高熵字符串。
严重
SEC
弱密码策略查找用户注册/密码修改逻辑。检查密码验证是否强制要求最小长度(8个字符以上)、复杂度,或是否使用了验证库。如果密码未经过任何验证规则就被接受,则进行标记。主要
SEC
无过期时间的JWT搜索JWT创建/签名代码。检查载荷是否包含
exp
(过期时间)声明。标记未设置过期时间或过期时间过长(访问令牌超过24小时)的JWT。
主要

Cross-Site Scripting (XSS)

Cross-Site Scripting (XSS)

ID PrefixWhat to DetectHow to DetectSeverity
SEC
{!! !!}
(unescaped output) in Laravel Blade with user data
Search for
{!! ... !!}
in
.blade.php
files. Check whether the content inside originates from user input, database fields that store user-provided HTML, or request data. Exclude static content and trusted admin-only fields.
Major
SEC
dangerouslySetInnerHTML
in React with untrusted data
Search for
dangerouslySetInnerHTML
in
.jsx
/
.tsx
files. Check whether the
__html
value comes from user input, API responses without sanitization, or any source not explicitly sanitized with DOMPurify or equivalent.
Major
SEC
v-html
in Vue with untrusted data
Search for
v-html
directives in
.vue
files. Same analysis as above — flag when the bound value could contain unsanitized user input.
Major
SEC
Missing Content-Security-PolicyCheck 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前缀检测内容检测方式严重程度
SEC
Laravel Blade中包含用户数据的
{!! !!}
(未转义输出)
.blade.php
文件中搜索
{!! ... !!}
。检查其中的内容是否来自用户输入、存储用户提供HTML的数据库字段或请求数据。排除静态内容和仅受信任管理员使用的字段。
主要
SEC
React中使用不可信数据的
dangerouslySetInnerHTML
.jsx
/
.tsx
文件中搜索
dangerouslySetInnerHTML
。检查
__html
的值是否来自用户输入、未经过净化的API响应或任何未使用DOMPurify或同类工具明确净化的来源。
主要
SEC
Vue中使用不可信数据的
v-html
.vue
文件中搜索
v-html
指令。执行上述相同分析——当绑定值可能包含未净化的用户输入时进行标记。
主要
SEC
缺失内容安全策略(CSP)检查中间件、Web服务器配置或元标签中的CSP头。如果项目中未配置任何CSP,则标记为深度防御缺口。次要

Mass Assignment

批量赋值

ID PrefixWhat to DetectHow to DetectSeverity
SEC
Laravel model without
$fillable
or
$guarded
Search for Eloquent model classes (extending
Model
). Check whether each model defines either
$fillable
(allowlist) or
$guarded
(blocklist) property. Flag models that define neither.
Major
SEC
Accepting
$request->all()
into create/update
Search for
$request->all()
,
request.body
(without destructuring),
**request.data
passed directly into
Model::create()
,
Model::update()
,
Model::fill()
, or ORM create/update methods. Flag as mass assignment vector.
Critical
ID前缀检测内容检测方式严重程度
SEC
未设置
$fillable
$guarded
的Laravel模型
搜索Eloquent模型类(继承自
Model
)。检查每个模型是否定义了
$fillable
(白名单)或
$guarded
(黑名单)属性。标记未定义任何一个属性的模型。
主要
SEC
$request->all()
直接用于创建/更新操作
搜索
$request->all()
request.body
(未解构)、
**request.data
直接传入
Model::create()
Model::update()
Model::fill()
或ORM创建/更新方法的情况。标记为批量赋值风险点。
严重

Cross-Site Request Forgery (CSRF)

Cross-Site Request Forgery (CSRF)

ID PrefixWhat to DetectHow to DetectSeverity
SEC
Forms without CSRF tokensSearch for
<form
tags with
method="POST"
(or PUT/PATCH/DELETE). Check whether the form includes a CSRF token field (
@csrf
,
csrf_token()
,
csrfmiddlewaretoken
,
_token
). Flag forms missing tokens.
Major
SEC
API routes without proper auth that modify stateCheck 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前缀检测内容检测方式严重程度
SEC
缺失CSRF令牌的表单搜索带有
method="POST"
(或PUT/PATCH/DELETE)的
<form>
标签。检查表单是否包含CSRF令牌字段(
@csrf
csrf_token()
csrfmiddlewaretoken
_token
)。标记缺失令牌的表单。
主要
SEC
修改状态且未正确认证的API路由检查既无CSRF保护又无认证中间件的API路由(POST/PUT/PATCH/DELETE)。使用令牌认证的无状态API是安全的;基于会话且无CSRF令牌的API则不安全。主要

Insecure Deserialization

不安全反序列化

ID PrefixWhat to DetectHow to DetectSeverity
SEC
unserialize()
on user input
Search for
unserialize()
(PHP),
pickle.loads()
(Python),
ObjectInputStream
(Java),
Marshal.load
(Ruby). Flag when the input source is user-controlled (request body, cookies, query params, uploaded files).
Critical
SEC
JSON.parse()
without validation used in eval-like context
Search for
JSON.parse()
of external data where the parsed result is passed to
eval()
,
Function()
,
setTimeout(string)
, or used to construct code dynamically. Flag the eval-like usage, not JSON.parse itself.
Major
ID前缀检测内容检测方式严重程度
SEC
对用户输入执行
unserialize()
搜索
unserialize()
(PHP)、
pickle.loads()
(Python)、
ObjectInputStream
(Java)、
Marshal.load
(Ruby)。当输入来源为用户可控(请求体、Cookie、查询参数、上传文件)时进行标记。
严重
SEC
在类eval上下文中使用未验证的
JSON.parse()
搜索对外部数据执行
JSON.parse()
,且解析结果被传入
eval()
Function()
setTimeout(string)
或用于动态构造代码的情况。标记类eval的用法,而非
JSON.parse
本身。
主要

Sensitive Data Exposure

敏感数据泄露

ID PrefixWhat to DetectHow to DetectSeverity
SEC
Passwords/tokens in log statementsSearch for logging calls (
Log::
,
logger.
,
console.log
,
print
,
logging.
) that include variables named
password
,
token
,
secret
,
key
,
credential
,
auth
, or similar. Flag when sensitive data is written to logs.
Critical
SEC
.env
committed to git
Check whether
.gitignore
includes
.env
. If
.env
exists in the repository and is not gitignored, flag as critical. Also check for
.env.production
,
.env.staging
committed.
Critical
SEC
Secrets in config files vs environment variablesSearch 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
SEC
Error messages leaking stack traces in production configCheck error/exception handling configuration. Look for
APP_DEBUG=true
,
DEBUG=True
,
display_errors=On
, or custom error handlers that expose stack traces, file paths, or SQL queries in responses. Flag when this is in production config.
Major
ID前缀检测内容检测方式严重程度
SEC
日志语句中的密码/令牌搜索日志调用(
Log::
logger.
console.log
print
logging.
)中包含名为
password
token
secret
key
credential
auth
等变量的情况。当敏感数据被写入日志时进行标记。
严重
SEC
.env文件已提交至git检查
.gitignore
是否包含
.env
。如果
.env
存在于仓库中且未被忽略,则标记为严重问题。同时检查
.env.production
.env.staging
是否已提交。
严重
SEC
配置文件中的密钥而非环境变量搜索配置文件中的硬编码凭据、API密钥、数据库密码。标记应来自环境变量但却硬编码在已追踪配置文件中的值。主要
SEC
生产配置中泄露堆栈跟踪的错误信息检查错误/异常处理配置。查找
APP_DEBUG=true
DEBUG=True
display_errors=On
或在响应中暴露堆栈跟踪、文件路径或SQL查询的自定义错误处理程序。当此类配置出现在生产环境中时进行标记。
主要

Broken Access Control

访问控制失效

ID PrefixWhat to DetectHow to DetectSeverity
SEC
IDOR — using user-supplied ID without ownership checkSearch for route parameters or request params (e.g.,
$request->id
,
params.id
,
request.args.get('id')
) used to fetch resources without verifying the authenticated user owns the resource. Look for
Model::find($id)
without a
where('user_id', auth()->id())
or policy check.
Critical
SEC
Missing policy/gate checks on resource accessIn 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前缀检测内容检测方式严重程度
SEC
IDOR——使用用户提供的ID但未检查所有权搜索路由参数或请求参数(如
$request->id
params.id
request.args.get('id')
)用于获取资源但未验证认证用户是否拥有该资源的情况。查找未搭配
where('user_id', auth()->id())
或策略检查的
Model::find($id)
严重
SEC
资源访问缺失策略/网关检查在带有授权系统的框架(Laravel策略、Django权限、Express中间件)中,检查用户拥有资源的CRUD操作是否包含授权检查。标记未经过策略或权限验证就读取/修改资源的控制器操作。主要

Security Misconfiguration

安全配置错误

ID PrefixWhat to DetectHow to DetectSeverity
SEC
APP_DEBUG=true
in production configs
Search for
APP_DEBUG=true
,
DEBUG=True
,
debug: true
in configuration files that appear to be production configs (not
.env.example
or
.env.local
).
Major
SEC
Permissive CORSSearch for CORS configuration. Flag
Access-Control-Allow-Origin: *
or
allowed_origins: ['*']
in non-public-API contexts. Also flag
Access-Control-Allow-Credentials: true
combined with wildcard origins.
Major
SEC
Default credentials in configurationSearch for usernames like
admin
,
root
,
test
paired with passwords like
password
,
123456
,
admin
,
secret
,
changeme
in config files, seeders, or initialization code. Exclude test fixtures.
Critical

ID前缀检测内容检测方式严重程度
SEC
生产配置中
APP_DEBUG=true
在看似生产配置的文件(非
.env.example
.env.local
)中搜索
APP_DEBUG=true
DEBUG=True
debug: true
主要
SEC
宽松的CORS设置搜索CORS配置。在非公开API场景中,标记
Access-Control-Allow-Origin: *
allowed_origins: ['*']
。同时标记
Access-Control-Allow-Credentials: true
与通配符来源组合的情况。
主要
SEC
配置中的默认凭据在配置文件、种子文件或初始化代码中搜索用户名如
admin
root
test
搭配密码如
password
123456
admin
secret
changeme
的情况。排除测试用例。
严重

ID Prefix & Fix Prompt Examples

ID前缀与修复提示示例

All findings use the
SEC-
prefix, numbered sequentially:
SEC-001
,
SEC-002
, etc.
所有检测结果均使用
SEC-
前缀,并按顺序编号:
SEC-001
SEC-002
等。

Fix Prompt Examples

修复提示示例

  • "In
    UserController@update
    (line 34), replace
    $request->all()
    with
    $request->only(['name', 'email'])
    to prevent mass assignment on the
    is_admin
    field. Also add
    $fillable = ['name', 'email']
    to the
    User
    model if not already present."
  • "Wrap the user input at line 55 of
    app/Services/SearchService.php
    in a parameterized query: change
    DB::select(\"SELECT * FROM products WHERE name LIKE '%$search%'\")
    to
    DB::select('SELECT * FROM products WHERE name LIKE ?', [\"%{$search}%\"])
    ."
  • "In
    routes/api.php
    , add auth middleware to the
    POST /api/orders
    route at line 22: change
    Route::post('/orders', [OrderController::class, 'store'])
    to
    Route::post('/orders', [OrderController::class, 'store'])->middleware('auth:sanctum')
    ."
  • "Move the hardcoded API key at line 15 of
    config/services.php
    to an environment variable: replace
    'key' => 'sk-live-abc123...'
    with
    'key' => env('STRIPE_SECRET_KEY')
    and add
    STRIPE_SECRET_KEY=
    to
    .env.example
    ."
  • "在
    UserController@update
    (第34行)中,将
    $request->all()
    替换为
    $request->only(['name', 'email'])
    ,以防止对
    is_admin
    字段进行批量赋值。如果
    User
    模型尚未设置
    $fillable = ['name', 'email']
    ,请添加该属性。"
  • "将
    app/Services/SearchService.php
    第55行的用户输入包装在参数化查询中:将
    DB::select(\"SELECT * FROM products WHERE name LIKE '%$search%'\")
    修改为
    DB::select('SELECT * FROM products WHERE name LIKE ?', [\"%{$search}%\"])
    ."
  • "在
    routes/api.php
    中,为第22行的
    POST /api/orders
    路由添加认证中间件:将
    Route::post('/orders', [OrderController::class, 'store'])
    修改为
    Route::post('/orders', [OrderController::class, 'store'])->middleware('auth:sanctum')
    ."
  • "将
    config/services.php
    第15行的硬编码API密钥移至环境变量:将
    'key' => 'sk-live-abc123...'
    替换为
    'key' => env('STRIPE_SECRET_KEY')
    ,并在
    .env.example
    中添加
    STRIPE_SECRET_KEY=
    。"