php-auth-audit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePHP 鉴权机制审计(Auth Audit)
PHP Authentication Mechanism Audit (Auth Audit)
分析 PHP Web 项目源码,识别认证与授权链路,判断每条路由的鉴权状态,并检测鉴权绕过/越权/IDOR 风险。
Analyze PHP Web project source code, identify authentication and authorization links, determine the authentication status of each route, and detect risks of authentication bypass/permission escalation/IDOR.
CRITICAL:完整分析(强制)
CRITICAL: Complete Analysis (Mandatory)
- 必须处理所有在 中出现的路由
php-route-mapper - 必须识别认证链:Session/JWT/中间件/自定义校验函数
- 必须输出路由-鉴权映射表(不做省略)
- 对所有可疑点给出:位置证据 + 数据流链 + 可利用性分析 + 验证 PoC + 修复建议
- Must process all routes appearing in
php-route-mapper - Must identify authentication chains: Session/JWT/middleware/custom validation functions
- Must output route-authentication mapping table (no omissions)
- For all suspicious points, provide: location evidence + data flow chain + exploitability analysis + verification PoC + repair suggestions
运行模式(强制:与流水线阶段对齐)
Runtime Modes (Mandatory: Align with Pipeline Stages)
此技能支持两种模式,用于解决“尚未生成 trace 之前无法引用 EVID_*”的问题:
-
(推荐用于流水线阶段 1)
STATIC_MAPPING- 只生成 (以及可选的
auth_mapping_{timestamp}.md)auth_README_{timestamp}.md - 允许缺少 的
php-route-tracer证据点引用EVID_* - 必须给出:鉴权状态分级(✅/⚠️/❌/❓)与 P0/P1 分桶依据(不需要 PoC)
- 只生成
-
(推荐用于流水线阶段 4,trace 已存在)
TRACE_AUDIT- 生成完整的 ,并强制逐条引用 trace 契约中的
auth_audit_report_{timestamp}.md证据点EVID_* - PoC/修复建议必须齐全
- 生成完整的
This skill supports two modes to solve the problem of "cannot reference EVID_* before trace is generated":
-
(Recommended for Pipeline Stage 1)
STATIC_MAPPING- Only generate (and optional
auth_mapping_{timestamp}.md)auth_README_{timestamp}.md - Allows missing references to evidence points from
EVID_*php-route-tracer - Must provide: authentication status classification (✅/⚠️/❌/❓) and P0/P1 bucket criteria (no PoC required)
- Only generate
-
(Recommended for Pipeline Stage 4, trace exists)
TRACE_AUDIT- Generate complete , and forcefully reference
auth_audit_report_{timestamp}.mdevidence points from the trace contract one by oneEVID_* - PoC/repair suggestions must be complete
- Generate complete
漏洞分级
Vulnerability Severity Rating
详见:
shared/SEVERITY_RATING.mdSee:
shared/SEVERITY_RATING.md输入依赖
Input Dependencies
建议输入(与 一致;合并流水线时读总报告中等价章节):
shared/IO_PATH_CONVENTION.md- (独立落盘时常为
routes_{timestamp}.md)route_mapping/routes_{timestamp}.md - (独立落盘时常为
params_{timestamp}.md)route_mapping/params_{timestamp}.md
可选:
source_path
Recommended Input (consistent with ; read equivalent sections in the total report when merging pipelines):
shared/IO_PATH_CONVENTION.md- (when stored independently, usually
routes_{timestamp}.md)route_mapping/routes_{timestamp}.md - (when stored independently, usually
params_{timestamp}.md)route_mapping/params_{timestamp}.md
Optional:
source_path
识别鉴权实现(必做)
Authentication Implementation Identification (Mandatory)
按框架识别:
- Laravel:
middleware('auth'|'can'|'role:')Auth::check()/Auth::user()- Policies/Gates:、
Gate::allows->can({value}) - 路由保护:
Route::middleware([{value}])->group({value})
- Symfony:
- security.yaml / access_control
- 、
denyAccessUnlessGrantedisGranted - voter/policy
- 原生 PHP:
- +
session_start判断$_SESSION - /
if (!isset($_SESSION['user']))requireLogin() - 自定义函数:
checkAuth/authorize/hasRole/isAdmin
Identify by framework:
- Laravel:
middleware('auth'|'can'|'role:')Auth::check()/Auth::user()- Policies/Gates: ,
Gate::allows->can({value}) - Route protection:
Route::middleware([{value}])->group({value})
- Symfony:
- security.yaml / access_control
- ,
denyAccessUnlessGrantedisGranted - voter/policy
- Native PHP:
- +
session_startjudgment$_SESSION - /
if (!isset($_SESSION['user']))requireLogin() - Custom functions:
checkAuth/authorize/hasRole/isAdmin
路由-鉴权映射(必做)
Route-Authentication Mapping (Mandatory)
对每条路由输出以下状态:
- ✅ 公开:显式允许,无鉴权检查
- ✅ 受保护:存在完整认证/授权检查
- ⚠️ 仅认证:只校验登录态,无角色/资源级授权
- ❌ 无鉴权:没有任何鉴权链路命中
- ❓ 不确定:动态权限/复杂自定义逻辑导致难判(仍必须写出证据点)
并输出风险类型:,包括:
AUTH- 认证绕过(登录态校验被绕过)
- 授权绕过/越权(角色校验缺失或错误)
- IDOR(对象访问缺少所有权/归属校验)
Output the following status for each route:
- ✅ Public: Explicitly allowed, no authentication checks
- ✅ Protected: Complete authentication/authorization checks exist
- ⚠️ Authentication-only: Only verifies login status, no role/resource-level authorization
- ❌ No authentication: No authentication links are hit
- ❓ Uncertain: Difficult to judge due to dynamic permissions/complex custom logic (evidence points must still be provided)
And output risk type: , including:
AUTH- Authentication bypass (login status verification is bypassed)
- Authorization bypass/permission escalation (role verification is missing or incorrect)
- IDOR (object access lacks ownership/attribution verification)
可疑模式检测(必做,给出证据链)
Suspicious Pattern Detection (Mandatory, Provide Evidence Chain)
1) 路径/URI 匹配导致鉴权绕过
1) Authentication Bypass Caused by Path/URI Matching
在 PHP 中常见根因:
- 用原始 或
$_SERVER['REQUEST_URI']结果做白名单匹配,但路径未规范化parse_url - 编码/大小写/重复斜杠/尾部字符差异导致匹配失败(实际路由进入受保护 handler)
必须输出:
- 白名单检查位置与代码片段
- 绕过请求(PoC)与命中的 handler 证据
Common root causes in PHP:
- Use raw or
$_SERVER['REQUEST_URI']results for whitelist matching, but the path is not normalizedparse_url - Matching failure caused by encoding/case/duplicate slashes/trailing character differences (actual route enters protected handler)
Must output:
- Whitelist check location and code snippet
- Bypass request (PoC) and evidence of the hit handler
2) 仅校验登录态,缺少角色/资源授权
2) Only Verify Login Status, Missing Role/Resource Authorization
必须输出:
- 路由的“认证检查”位置
- “授权检查缺失”位置(例如只判断 后直接执行敏感操作)
user!=null
Must output:
- Location of the route's "authentication check"
- Location of "missing authorization check" (e.g., directly execute sensitive operations after only judging )
user!=null
3) IDOR/越权
3) IDOR/Permission Escalation
必须输出:
- 敏感对象 id 来自哪里(GET/POST/URL)
- 用于查询/更新的“归属校验”是否存在(WHERE 里是否包含 user_id/owner_id)
- 未校验的原因与可达性
Must output:
- Where the sensitive object id comes from (GET/POST/URL)
- Whether "ownership verification" for query/update exists (whether user_id/owner_id is included in the WHERE clause)
- Reason for missing verification and accessibility
报告输出(按运行模式)
Report Output (By Runtime Mode)
输出到:
{output_path}/auth_audit/
├── auth_audit_report_{timestamp}.md
├── auth_mapping_{timestamp}.md
└── auth_README_{timestamp}.md强制规则:
- :必须生成
STATIC_MAPPING;auth_mapping_{timestamp}.md可以省略或生成空壳(并标注:仅分桶映射,不含 trace 证据)auth_audit_report_{timestamp}.md - :必须生成完整三文件,并要求 trace 证据点齐全
TRACE_AUDIT
Output to:
{output_path}/auth_audit/
├── auth_audit_report_{timestamp}.md
├── auth_mapping_{timestamp}.md
└── auth_README_{timestamp}.mdMandatory Rules:
- : Must generate
STATIC_MAPPING;auth_mapping_{timestamp}.mdcan be omitted or generated as an empty shell (marked as: bucket mapping only, no trace evidence)auth_audit_report_{timestamp}.md - : Must generate all three files, and require complete trace evidence points
TRACE_AUDIT
文件1:主报告 auth_audit_report_{timestamp}.md
auth_audit_report_{timestamp}.mdFile 1: Main Report auth_audit_report_{timestamp}.md
auth_audit_report_{timestamp}.md包含:
- 鉴权框架识别(含版本/实现证据)
- 鉴权架构概览(middleware/函数/handler)
- 风险统计
- 每条风险的完整漏洞结构(编号/分级/数据流/PoC/修复)
Includes:
- Authentication Framework Identification (including version/implementation evidence)
- Authentication Architecture Overview (middleware/functions/handlers)
- Risk statistics
- Complete vulnerability structure for each risk (ID/severity/data flow/PoC/repair)
文件2:映射表 auth_mapping_{timestamp}.md
auth_mapping_{timestamp}.mdFile 2: Mapping Table auth_mapping_{timestamp}.md
auth_mapping_{timestamp}.md只列路由与鉴权状态、所需角色/条件(不要放漏洞详细分析)。
但必须新增分桶字段(用于流水线阶段 3 选路):
- :
p_bucket或P0P1- :❌ 无鉴权
P0 - :⚠️ 仅认证,或检测到存在授权绕过/越权/IDOR 风险(即使鉴权状态显示为“仅认证”,也要在
P1里说明为什么进入 P1)p1_reason
- :一段简短静态依据(如“仅登录态,缺少 hasRole/authorize 或缺少 owner_id 校验”)
p1_reason
Only list routes, authentication status, required roles/conditions (do not include detailed vulnerability analysis).
But must add bucket fields (for route selection in Pipeline Stage 3):
- :
p_bucketorP0P1- : ❌ No authentication
P0 - : ⚠️ Authentication-only, or detected authorization bypass/permission escalation/IDOR risks (even if authentication status shows "authentication-only", explain why it enters P1 in
P1)p1_reason
- : A brief static basis (e.g., "Only login status, missing hasRole/authorize or missing owner_id verification")
p1_reason
文件3:说明文档 auth_README_{timestamp}.md
auth_README_{timestamp}.mdFile 3: Documentation auth_README_{timestamp}.md
auth_README_{timestamp}.md只说明方法论、工具与验证指南,不包含具体漏洞细节。
Only explain methodology, tools and verification guidelines, do not include specific vulnerability details.
PoC 验证模板(强制)
Mandatory PoC Verification Template
必须区分至少以下场景:
- 未登录访问(无 cookie/session/JWT)
- 普通用户访问(普通账号 cookie/JWT)
- 管理员/高权限对照(如适用)
PoC 必须是可执行 HTTP 请求代码块,并且路由路径必须使用真实路由规则。
Must distinguish at least the following scenarios:
- Unauthenticated access (no cookie/session/JWT)
- Regular user access (regular account cookie/JWT)
- Admin/high-privilege control (if applicable)
PoC must be an executable HTTP request code block, and the route path must use real route rules.
证据引用(按运行模式强制)
Evidence Reference (Mandatory by Runtime Mode)
- :不强制引用 trace 的
STATIC_MAPPING证据点(只需输出鉴权分级与 P0/P1 分桶依据)。EVID_* - :每条疑似鉴权风险必须逐项引用 trace 输出中的证据(允许状态标记为待验证,但证据引用必须存在):
TRACE_AUDIT
- :路由进入受保护 handler 的路径匹配证据(对应 trace 的分支路径证据)
EVID_AUTH_PATH_PROTECTED_MATCH - :登录态/Token 解码结果如何被判断的证据(对应 trace 中 session/JWT 读取与条件分支)
EVID_AUTH_TOKEN_DECODE_JUDGMENT - :权限判断函数或条件语句(如
EVID_AUTH_PERMISSION_CHECK_EXEC)的执行证据(trace sink 定位或分支证据)hasRole/authorize - :IDOR 归属校验(WHERE/条件)是否包含 owner_id/user_id 的证据(trace 中最终查询条件或状态更新语句)
EVID_AUTH_IDOR_OWNERSHIP_CONDITION
- : No mandatory requirement to reference
STATIC_MAPPINGevidence points from trace (only need to output authentication classification and P0/P1 bucket criteria).EVID_* - : Each suspected authentication risk must reference evidence from trace output item by item (status can be marked as pending verification, but evidence references must exist):
TRACE_AUDIT
- : Evidence of path matching for routes entering protected handlers (corresponding to branch path evidence in trace)
EVID_AUTH_PATH_PROTECTED_MATCH - : Evidence of how login status/Token decoding results are judged (corresponding to session/JWT reading and conditional branches in trace)
EVID_AUTH_TOKEN_DECODE_JUDGMENT - : Evidence of execution of permission judgment functions or conditional statements (such as
EVID_AUTH_PERMISSION_CHECK_EXEC) (trace sink location or branch evidence)hasRole/authorize - : Evidence of whether IDOR ownership verification (WHERE/condition) includes owner_id/user_id (final query condition or status update statement in trace)
EVID_AUTH_IDOR_OWNERSHIP_CONDITION
tracer 证据缺失处理(强制)
Tracer Evidence Missing Handling (Mandatory)
- :不适用(分桶依据以静态代码证据为准)。
STATIC_MAPPING - :若 trace 契约校验失败或无法定位 1~4 任一关键证据点:该风险只能标记为
TRACE_AUDIT,不得给出⚠️待验证或“确定可绕过”的结论。✅已确认可利用
- : Not applicable (bucket criteria are based on static code evidence).
STATIC_MAPPING - : If trace contract verification fails or any of the key evidence points 1~4 cannot be located: the risk can only be marked as
TRACE_AUDIT, and conclusions like⚠️Pending Verificationor "definitely bypassable" must not be given.✅Confirmed Exploitable