2012-02-22 129 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解析器。