Rails的方法容易受到SQL注入? [英] Rails methods vulnerable to SQL injection?

查看:245
本文介绍了Rails的方法容易受到SQL注入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是Rails的方法,这些方法容易受到SQL注入,以及以何种形式?

What are the Rails methods that are vulnerable to SQL injection, and in what form?

例如,我知道其中,用字符串参数是脆弱的:

For example, I know that where with a string argument is vulnerable:

Model.where("name = #{params[:name}") # unsafe

不过,参数化字符串或散列是不是:

But a parameterized string or hash is not:

Model.where("name = ?", params[:name]) # safe
Model.where(name: params[:name]) # safe

我主要是想了解一下其中,限制加入,但想知道,可能是攻击媒介的任何其他方法。

I'm mostly wondering about where, order, limit and joins, but would like to know about any other methods that might be attack vectors.

推荐答案

一般情况:如果你让用户输入并保存任何文字到数据库,没有逃避code,它可能会损害您的系统。特别是如果这些文字可能包含标签/ code片段。

Generally: If you let the user input and save any text into your database, without escaping code, it could harm your system. Especially if these texts may contain tags/code snippets.

这篇关于Rails的方法容易受到SQL注入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆