xml中的SQL注入

大家通常知道xml中大部分会导致外部实体注入,但是,xml也会出现SQL注入;

在xml中正常的sql语句写法有两种:

第一:

<select id="selectById" resultType="bean.user" >

select * from users where id = #id#</select>

第二:

<select id="selectById" resultType="bean.user" >

select * from users where id = '$id$'</select>

在使用第一种写法的时候,id的value会以参数的形式注入到sql语句中,类似于预编译;

但是使用第二种写法的时候,id的value就会以字符串的形式直接插入到sql语句中,从而很容易导致sql注入。

posted @ 2016-09-01 19:01  ermei  阅读(1607)  评论(0编辑  收藏  举报