简体   繁体   English

XSS Me警告-真正的XSS问题?

[英]XSS Me Warnings - real XSS issues?

I've been using the free Firefox extension XSS Me from Security Compass to test for XSS problems. 我一直在使用来自Security Compass的免费Firefox扩展XSS Me来测试XSS问题。 However, using what I understand to be safe filtering, XSS me still reports warnings. 但是,使用我理解的安全过滤功能,XSS仍会报告警告。 Are these accurate warnings or spurious? 这些准确的警告还是虚假的?

Using the code below as a testcase: 使用下面的代码作为测试用例:

<form method="post" action="">
<input type="text" name="param" value="<?php echo htmlentities($_POST['param'])?>">
<input type="submit">
</form>
<?php echo htmlentities($_POST['param'])?>

I run some nasties by hand but none of them are executed in the browser, and using Charles debugging proxy I can see that the response is encoded as expected. 我手动执行一些检查,但没有一个在浏览器中执行,使用Charles调试代理,我可以看到响应已按预期进行编码。

However, XSS Me reports a number of warnings, as if it can see the unencoded string in the HTML source: alt text http://img696.imageshack.us/img696/8850/xss.png 但是,XSS Me报告了许多警告,好像它可以在HTML源代码中看到未编码的字符串一样: 替代文本http://img696.imageshack.us/img696/8850/xss.png

Looking in Charles at the same time, I can see the strings are encoded and should be safe eg &lt;IMG SRC=&quot;jav ascript:document.vulnerable=true;&quot;&gt; 同时在Charles中查看,我可以看到字符串已编码并且应该是安全的,例如&lt;IMG SRC=&quot;jav ascript:document.vulnerable=true;&quot;&gt;

  • Is there a vulnerability I haven't fixed? 我有没有解决的漏洞?
  • Are these rogue warning messages? 这些是流氓警告消息吗?
  • And if so, is another Firefox extension (Firebug?) conflicting with XSS Me? 如果是这样,另一个Firefox扩展(Firebug?)是否与XSS Me冲突?

I work at Security Compass and am the lead developer for the Exploit Me tools. 我在Security Compass工作,并且是Exploit Me工具的首席开发人员。

You're right that XSS Me is reporting a warning because these attack strings seem (to XSS Me) to have come back from the server completely unencoded. 您说对了,XSS Me正在报告警告,因为(对于XSS Me)这些攻击字符串似乎是完全未经编码从服务器返回的。 Another parser/JavaScript engine (like IE 6/7/8, Safari, or Chrome) might execute this code even though Firefox's parser and JavaScript engine don't. 另一个解析器/ JavaScript引擎(例如IE 6/7/8,Safari或Chrome)也可以执行此代码,即使Firefox的解析器和JavaScript引擎不执行。

XSS Me submits two requests: XSS Me提交了两个请求:

  • One request where we detect exploitation using FireFox's JavaScript engine, which we call "errors" 我们要求使用FireFox的JavaScript引擎检测利用的请求,我们称其为“错误”
  • A second request where we detect exploitation by simply grepping for the attack string in the HTML response page 我们通过简单地在HTML响应页面中grep攻击字符串来检测攻击的第二个请求

The warning you're getting is caused by this second request. 您收到的警告是由第二个请求引起的。

I can help you get to the root cause of this issue if you can do the following: 如果可以执行以下操作,我可以帮助您找到此问题的根本原因:

  1. Use packet sniffing software (ie Wireshark http://www.wireshark.org/ ) to detect the attack string rather than Charles. 使用数据包嗅探软件(即Wireshark http://www.wireshark.org/ )来检测攻击字符串,而不是Charles。 Sometimes proxies have a way of modifying or otherwise altering requests 有时代理可以修改或以其他方式更改请求

  2. In Firefox, can you go to tools->addons and disable all the extensions except XSS Me? 在Firefox中,您可以转到工具->附件并禁用除XSS Me以外的所有扩展吗? That way you can be sure no other extension is changing the response (or request) before it gets to XSS Me. 这样,您可以确保没有其他扩展在到达XSS Me之前更改响应(或请求)。

  3. View the source of the response page in Firefox to see if the unencoded string appears 在Firefox中查看响应页面的源,以查看是否出现未编码的字符串

If you'd like to send me an email (tom@securitycompass.com) with those results I'd be happy to help figure this out. 如果您想将包含这些结果的电子邮件发送给我(tom@securitycompass.com),我将很乐意帮助您解决此问题。 If it's a bug in XSS Me (which I certainly hope not) then I can patch it and get a new build out. 如果这是XSS Me中的错误(我当然希望不是),那么我可以对其进行修补并重新构建。

Thanks, 谢谢,

Tom 汤姆

I am pretty sure this is a false positive. 我很确定这是一个误报。 I think you should get a better xss testing tool. 我认为您应该获得更好的xss测试工具。 Acuentix has a very good and free xss scanner: http://www.acunetix.com/cross-site-scripting/scanner.htm . Acuentix有一个非常好的免费的xss扫描器: http ://www.acunetix.com/cross-site-scripting/scanner.htm。 Wapiti and w3af are open source and are also great scanners. Wapiti和w3af是开源的,也是出色的扫描仪。

In php the best xss filter is: 在php中最好的xss过滤器是:

htmlspeicalchars($_POST['param'],ENT_QUTOES);

The reason why you also have to decode quotes is becuase you don't need <> to exploit some xss. 之所以还必须对引号进行解码,是因为您不需要<>来利用某些 xss。 for instance this is vulnerable to xss: 例如,这很容易受到xss的攻击:

print('<A HREF="http://www.xssed.com/'.htmlspecialchars($_REQUEST[xss]).'">link</a>');

You don't need <> to execute javascript in this case because you can use onmouseover, here is an example attack: 在这种情况下,您不需要<>来执行javascript,因为您可以使用onmouseover,这是一个示例攻击:

$_REQUEST[xss]='" onMouseOver="alert(/xss/)"';

the ENT_QUOTES takes care of the double quotes. ENT_QUOTES处理双引号。

If the field isn't suppose to have any HTML in it, you might want to try something like strip_tags($strings) . 如果该字段中未包含任何HTML,则可能需要尝试诸如strip_tags($strings)类的东西。 It will strip out (most) HTML tags from the string. 它将从字符串中去除(大多数)HTML标记。

I say most because I believe it isn't perfect, and as other people will tell you, HTML parsers are probably best for stripping out HTML. 我之所以这么说是因为我认为它并不完美,正如其他人会告诉您的那样,HTML解析器可能是剥离HTML的最佳选择。 But it should be sufficent in most cases. 但这在大多数情况下应该足够了。

I' m testing it at my server and looks like a bug in the extension. 我正在服务器上对其进行测试,看起来像扩展中的错误。 I don't believe that any other extension is making conflicts with the "XSS ME" extension. 我不相信任何其他扩展都会与“ XSS ME”扩展产生冲突。

BTW, with htmlentities you don't cover all the possibilities to insert XSS, so consider using some kind of anti XSS library :) 顺便说一句,使用htmlentities,您无法涵盖插入XSS的所有可能性,因此请考虑使用某种反XSS库:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM