PHP XSS 预防白名单 [英] PHP XSS Prevention WhiteListing

查看:59
本文介绍了PHP XSS 预防白名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站使用 WYSIWYG 编辑器供用户更新他们的帐户、输入评论和发送私人消息.

My site utilizes a WYSIWYG editor for users to update their accounts,enter comments, and send private messages.

编辑器 (CKEditor) 非常适合只允许用户输入有效输入,但我担心通过 TamperData 或其他方式注入.

The editor (CKEditor) is great for only allowing users to enter valid input, but I worry about injection through TamperData or other means.

如何在服务器端控制这个?

How can I control this on the server side?

我需要将特定标签列入白名单:<b><ul><ol><a><img><br>,这是否是一种安全的方法来防止XSS?

I need to whitelist specific tags: <b><ul><ol><a><img><br>, will this be a SAFE approach to preventing XSS?

推荐答案

使用 HTML Purifier:

Use HTML Purifier:

HTML Purifier 是一个符合标准的用 PHP 编写的 HTML 过滤器库.HTML Purifier 不仅会删除所有恶意代码(通常称为 XSS)经过彻底审核,安全但许可白名单.

HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist.

这篇关于PHP XSS 预防白名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆