记一次网站ID越权修复过程

1.ID遍历
某网站id可遍历,可越权查看别人的实验报告:

2.定位问题:
网站使用thinkCMF框架
通过index.php 定位到网站位于application目录下:

根据URL参数 的特征g=&m=index&a=jump_result&test_id=1533
定位到 test_id 应该位于 index 相关类的jump_result 方法
在Visual Code 用Ctrl Shift F检索application的jump_result 方法,快速定位到问题:

在查询test_id时没有校验身份:

Where条件仅使用test_id作为查询条件。

3.修复

增加身份校验:

$test = M('test')->where(array(['test_id'=>$test_id,'user_id'=>$data['user_id']]))->find();

同时查询test_id和当前用户的user_id即可。
再次尝试越权访问,已无法查看别人的成绩:

Leave a Reply

Your email address will not be published. Required fields are marked *