gpt4 book ai didi

sql - 如果使用 hibernate ,SQL 注入(inject)的安全性有多少

转载 作者:行者123 更新时间:2023-12-03 22:23:57 26 4
gpt4 key购买 nike

是否 Hibernate谨防SQL injection attack ?如果我使用 hibernate ,那么我是否完全免受 SQL 注入(inject)攻击?听说使用Hibernate执行 dynamic SQL statement使用用户输入构建可以允许攻击者修改语句的含义或执行任意 SQL commands .

最佳答案

Does Hibernate guard against SQL injection attack?



不,它不会保护写错的 , 所以你在编写查询时需要小心。始终使用准备好的语句样式,例如考虑下面的 高品质 查询,
String query1 = "select * from MyBean where id = "+ id;
String query2 = "select * from MyBean where id = :id";

query1 ** 仍然容易受到 **SQL 注入(inject) 的攻击其中 查询2 不是。

所以简而言之 hibernate 提供了许多方法来保护自己免受 SQL Injection attacks 的伤害。 .

关于sql - 如果使用 hibernate ,SQL 注入(inject)的安全性有多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9596424/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com