你好,我在下面的查询中使用 quoteInto
$select->from('users')
->where($adapter->quoteInto('eu.username LIKE ?',"%".$param['name']."%"));
当我传递任何类似 'or -1=-1' 或类似想法的东西时
' or 1=1--
' or 1--
' or 1
\" or '1'
' or 1=1--
' OR ''='
' or 'a'='a
') or ('a'='a
'; exec master..xp_cmdshell 'ping 10.10.1.2'--
';
当我回显我的查询时,所有这些东西都放在我查询的 LIKE
子句中。我只想问,在引用我的查询后,我的查询是安全的,不会受到 sql 注入(inject)的影响吗?
最佳答案
是的,通过使用数据库适配器引用函数,您可以免受 SQL 注入(inject)攻击。
当您使用 quoteInto
时,Zend 将调用 Zend_Db_Adapter::quote方法来转义值字符串。
From Zend Docs:
The quote() method accepts a single argument, a scalar string value. It returns the value with special characters escaped in a manner appropriate for the RDBMS you are using, and surrounded by string value delimiters.
为了使您的应用程序更安全,您还应该将 Zend_Form
与利用可用元素的元素一起使用 Zend Filters和 Zend Validators .元素验证将发现问题并避免垃圾数据库调用,过滤器将清理您的数据!
关于php - 使用 quoteInto 之后,我可以免受 SQL 注入(inject)攻击吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21581387/