1

我不知道它是否算作 XSS,但它会导致错误

我有一个 image_tag 并且:alt标签是由用户生成的

但是,使用sanitize//对此无济于事(来自hOWASP-此处html_escape

';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";
alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--
></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>

做的时候

:alt => (the string above)

图像的输出搞砸了

有没有办法修复这个 XSS?

我正在使用最新的导轨,红宝石

4

2 回答 2

1

由于 Rails 3.2.8 以及CVE-2012-3464的修复,Rails 转义助手转义双引号和单引号。

如果您实际上使用的是正确的版本,则应该没问题。

>> ERB::Util.h '\';alert(String.fromCharCode(88,83,83))//\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">\'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>'
=> "&#39;;alert(String.fromCharCode(88,83,83))//&#39;;alert(String.fromCharCode(88,83,83))//&quot;;alert(String.fromCharCode(88,83,83))//&quot;;alert(String.fromCharCode(88,83,83))//--&gt;&lt;/SCRIPT&gt;&quot;&gt;&#39;&gt;&lt;SCRIPT&gt;alert(String.fromCharCode(88,83,83))&lt;/SCRIPT&gt;"

(注意:上述原始字符串中的反斜杠需要存在,以便 Ruby 正确解析字符串,然后逐字逐句地包含单引号。)

于 2013-01-08T09:37:03.890 回答
0

你可以通过过滤器来修复它“'和>这三个字符就足够了

于 2013-01-09T07:13:24.327 回答