Is there a definitive anti-XSS library for PHP?

后端 未结 7 2162
长发绾君心
长发绾君心 2020-12-14 08:14

I already know how XSS works, but finding out all the many different ways to inject malicious input is not an option.

I saw a couple libraries out there, but most of

7条回答
  •  -上瘾入骨i
    2020-12-14 08:30

    HTMLPurifier is the undenied best option for cleansing HTML input, and htmlspecialchars should be applied to anything else.

    But XSS vulnerabilities should not be cleaned out, because any such submissions are garbage anyway. Rather make your application bail and write a log entry. The best filter set to achieve XSS detection is in the mod_security core rules.

    I'm using an inconspicious but quite thorough attribute detection here in new input(), see _xss method.

提交回复
热议问题