Mybatis中SQL注入攻击的3种方式,真是防不胜防!
Hollis
共 2661字,需浏览 6分钟
· 2021-07-13
前言
一、Mybatis的SQL注入
<select id="queryAll" resultMap="resultMap">
SELECT * FROM NEWS WHERE ID = #{id}
</select>
1、模糊查询
Select * from news where title like ‘%#{title}%’
select * from news where tile like concat(‘%’,#{title}, ‘%’)
2、in 之后的多个参数
Select * from news where id in (#{ids})
id in
<foreach collection="ids" item="item" open="("separatosr="," close=")">
#{ids}
</foreach>
3、order by 之后
二、实战思路
三、总结
1、Mybatis框架下审计SQL注入,重点关注在三个方面like,in和order by 2、xml方式编写sql时,可以先筛选xml文件搜索$,逐个分析,要特别注意mybatis-generator的order by注入 3、Mybatis注解编写sql时方法类似 4、java层面应该做好参数检查,假定用户输入均为恶意输入,防范潜在的攻击
有道无术,术可成;有术无道,止于术 欢迎大家关注Java之道公众号 好文章,我在看❤️
评论