分享 Rails SQL Injection 整理 网页

linjunpop · 2013年07月10日 · 最后由 libuchao 回复于 2013年07月10日 · 2878 次阅读

http://rails-sqli.org/

This page lists many query methods and options in ActiveRecord which do not sanitize raw SQL arguments and are not intended to be called with unsafe user input.

不拼接用户输入的内容到 SQL 就是了

None of them matters if you use the rails style query instead of PHP style query.

#1 楼 @libuchao #2 楼 @luikore 不拼照样有风险:

User.calculate :sum, params[:column]

木有发现框架级别的漏洞 这些都是 coding 时应该注意的 个人感觉危险最大的就可能是 select 和 calculate 了 比较容易有参杂 params 的需求

#3 楼 @ashchan 这个其实是框架在拼 SQL,非要 calculate 的话,就得判断 params 里的内容自己传参数给 calculate,千万不能直接把 params 里的内容直接传进来。

不知我这样理解对不对

#3 楼 @ashchan 一般也不会把用户输入放到 key 而不是 value 上吧...

#3 楼 @ashchan calculate 这样的计算 我更推荐在业务上规定好白名单 毕竟不能这样红果果的让客户端统计一切

需要 登录 后方可回复, 如果你还没有账号请 注册新账号