我在How to prevent SQL Injection in hibernate?看到了HQL SQL注入主题。但我无法理解Query.setParameter("<parameter name>",<parameter value>)
消除SQL注入,
如果恶意用户将true = true
传递给以下HQL,String hqlString = "from Item item where name= '"+nameValue+"'";
然后他也可以将它传递给query.setString("name"+ nameValue)
!
setString()及其所有姐妹方法是否都有任何过滤器来检查SQL注入?
答案 0 :(得分:1)
JDBC或Hibernate驱动程序将在执行查询之前适当地转义此数据;确保数据仅用作数据。
在执行查询之前,驱动程序将转义如下字符: