Kohana SQL 准备语句安全
在 Kohana 准备好的声明文档上,它指出
尽管所有参数都被转义以防止 SQL 注入,但验证/清理您的输入仍然是一个好主意。
从我读到的准备好的语句来看,我的印象是绑定参数可以防止 SQL 注入。如果不是这种情况,在绑定变量之前我应该使用什么清理/转义方法?
On the Kohana prepared statement documentation it states
Although all parameters are escaped to prevent SQL injection, it is still a good idea to validate/sanitize your input.
From what I read on prepared statements, I was under the impression that binding parameters prevented SQL injection. If this is not the case, what sanitization/escaping method should I be using before binding the variables?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为当他们说“验证/清理仍然是一个好主意”时,他们的意思是使用 Valid 类或/和 Validation 类......以确保您在数据库中插入正确的数据。
有关 Kohana 验证的更多信息:http://kohanaframework.org/3.2/guide/kohana/安全/验证
更新:
您还应该研究 XSS:http://kohanaframework.org/3.2/guide/kohana/security/xss
I think when they say "it is still a good idea to validate/sanitize", they mean to use Valid class or/and Validation class... To make sure you get the right data inserted in your DB.
More info on Validation in Kohana: http://kohanaframework.org/3.2/guide/kohana/security/validation
UPDATE:
You should also look into XSS: http://kohanaframework.org/3.2/guide/kohana/security/xss
Kohana 为不同的数据库类型提供了数据库抽象。并非所有具体数据库都可能有准备好的语句,因此它们将被模拟。特定数据库的一些本机转义功能甚至可能被破坏。
您永远不会知道,不仅有一层安全性总是好的。
另一层是您的脚本实际上接收到有意义的数据。例如,名字字符串大小为 8 兆字节。无论数据库用它做什么都没有意义。
Kohana provides a db abstraction to different database types. Not all concrete databases might have prepared statements so they will get simulated. Some native escaping functions for specific databases might even be broken.
As you never know, it's always good to not only have one layer of security.
Another layer is that your script actually receives data that makes sense. E.g. a first-name string that is 8 megabyte large for example. Won't make sense regardless what the database is doing with it.