php - 使用 quoteInto 之后,我可以免受 SQL 注入(inject)攻击吗?

标签 php mysql zend-framework sql-injection

你好,我在下面的查询中使用 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 FiltersZend Validators .元素验证将发现问题并避免垃圾数据库调用,过滤器将清理您的数据!

关于php - 使用 quoteInto 之后,我可以免受 SQL 注入(inject)攻击吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21581387/

相关文章:

php - 比较字段并获取百分比

mysql - 为什么 INNER JOIN 在包含匹配数据的两个表上返回空集?

Java/MySQL dao 存储空值和空指针异常 - 保持简单

php - 将字符串分解为没有空元素的数组?

javascript - 从 PHP 中的拆分文本中获取出现次数最多的前 5 个内容

php - SQL SELECT 到多个表

php - Zend|Db\Sql|表达式在 Zend SL 语句中不起作用

php - 从 MySQL 数据库输出一个 longblob 的空 PHP

ZEND 中的 MySql SHOW 查询

linux - 通过 cron 执行脚本时使用 Zend Lucene 的 PHP iconv 错误,但不在命令行上