2013-01-08 30 views
1

我不知道这是否算作一个XSS这种XSS,但它造成的错误如何解决Rails中

我有一个IMAGE_TAG和:alt标签是由用户生成的

然而,使用sanitize/h/html_escape不会与此(从OWASP- here

';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> 

时帮助210
:alt => (the string above) 

图像的输出一团糟

有没有办法解决这个XSS?

我使用的是最新的轨道,红宝石

回答

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正确解析,然后包含单引号逐字的字符串。)

0

ü可以通过过滤器修复“'和>只是这三个字符是不够的