2012-02-22 131 views
1

可能重复:
What are the best practices for avoiding xss attacks in a PHP site
Examples of XSS that I can use to test my page input?例子/ PHP中类型的XSS攻击

什么是实例/类型的PHP客户端XSS攻击,我怎么能阻止他们?

+6

参见:[?XSS,我可以用它来测试我的网页输入的例子(http://stackoverflow.com/questions/7232405/examples-of-xss-that-i-can-use-在PHP网站中避免xss攻击的最佳实践](http://stackoverflow.com/questions/71328/what-are-the-best-practices-for -avoiding-xss-attacks-in-a-php-site),[XSS攻击如何运作?](http://stackoverflow.com/questions/3364427/how-xss-attack-really-works),http: //stackoverflow.com/search?q=xss+php ... – 2012-02-22 07:03:28

+0

https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet – Cheekysoft 2012-02-22 14:33:36

回答

0
  1. 纯文本为HTML。 当您忘记用htmlspecialchars转义纯文本时。 无需预防:只需在模板中使用PHP时逃脱变量。或者使用smarty/twig /等。

  2. HTML as HTML:当你允许用户创建HTML(fckeditor/tinymce/plain HTML/etc)。 使用HTML清洁剂。

  3. 将BB代码转换为HTML。 不要使用自己的基于正则表达式的解析器,只能使用FSM解析器。