rip*_*her 3 java security xss jsf richedit
我在全 JSF 平台上使用 Rich Editor 作为用户输入文本框。我试图避免对此文本字段的 XSS 攻击。
要求是
<显示<,所以问题是,由于我们必须正确显示值,所以我们输入escape=false了输出文本,但它随后变得容易受到 XSS 攻击。
我尝试使用 jsoup 来过滤 HTML 标签,但似乎输入会自动编码并且无法使用 jsoup 。
所以我的问题如下。
escape=false?您应该在输出富文本的任何页面上实施内容安全策略。
这使您可以有效地阻止浏览器执行内联脚本。目前,Chrome 和 Firefox 等现代浏览器都支持它。
这是通过页面的 HTTP 响应标头完成的。
例如
Content-Security-Policy: script-src 'self' https://apis.google.com
Run Code Online (Sandbox Code Playgroud)
如果用户设法将内联 JavaScript 注入到您的页面中,将阻止执行内联 JavaScript(它将被忽略并发出警告),但将允许脚本标记引用您自己的服务器或https://apis.google.com. 这可以根据您的需要进行定制。
您可以将其与 HTML 清理程序结合使用,以去除任何恶意标签,以实现皮带和大括号方法,并保护不支持 CSP 的浏览器。
Google 现在已在 Gmail 中实施 CSP,以确保收到的任何 HTML 电子邮件都无法尝试任何偷偷摸摸的行为来发起 XSS 攻击。
更新:在上次检查时,Gmail 中的 CSP 似乎相当薄弱,允许script-src具有unsafe-inline和unsafe-eval:
内容安全策略:脚本 src https://clients4.google.com/insights/consumersurveys/ https://www.google.com/js/bg/ 'self' 'unsafe-inline' 'unsafe-eval' https://mail.google.com/_/scs/mail-static/ https://hangouts.google.com/ https://talkgadget.google.com/ https://*.talkgadget.google.com/ https://www.googleapis.com/appsmarket/v2/installedApps/ https://www-gm-opensocial.googleusercontent.com/gadgets/js/ https://docs.google.com/static/doclist/client/ https://www.google.com/tools/feedback/ https://s.ytimg.com/yts/jsbin/ https://www.youtube.com/iframe_api https://ssl.google-analytics .com/ https://apis.google.com/_/scs/abc-static/ https://apis.google.com/js/ https://clients1.google.com/complete/ https://apis .google.com/_/scs/apps-static/_/js/ https://ssl.gstatic.com/inputtools/js/ https://ssl.gstatic.com/cloudsearch/static/o/js/ https://ssl.gstatic.com/inputtools/js/ https://ssl.gstatic.com/cloudsearch/static/o/js/ ://www.gstatic.com/feedback/js/ https://www.gstatic.com/common_sharing/static/client/js/ https://www.gstatic.com/og/_/js/;frame- src https://clients4.google.com/insights/consumersurveys/ https://calendar.google.com/accounts/ '自我' https://accounts.google.com/ https://apis.google.com/ u/ https://apis.google.com/_/streamwidgets/ https://clients6.google.com/static/ https://content.googleapis.com/static/ https://mail-attachment.googleusercontent。 com/ https://www.google.com/calendar/ https://calendar.google.com/calendar/ https://docs.google.com/ https://drive.google.com https://* .googleusercontent.com/docs/securesc/ https://feedback.googleusercontent.com/resources/ https://www.google.com/tools/feedback/ https://support.google.com/inapp/ https:// /*.googleusercontent.com/gadgets/ifr https://hangouts.google.com/ https://talkgadget.google.com/ https://*.talkgadget.google.com/ https://www-gm- opensocial.googleusercontent.com/gadgets/ https://plus.google.com/ https://wallet.google.com/gmail/ https://www.youtube.com/embed/ https://clients5.google。 com/pagead/drt/dn/ https://clients5.google.com/ads/measurement/jn/ https://www.gstatic.com/mail/ww/ https://www.gstatic.com/mail/ intl/ https://clients5.google.com/webstore/wall/ https://ci3.googleusercontent.com/ https://apis.google.com/additnow/ https://www.gstatic.com/mail/促销/ https://notifications.google.com/ https://mail- payments.google.com/mail/ payments/;report-uri https://mail.google.com/mail/cspreport;object-src https ://mail-attachment.googleusercontent.com/swfs/ https://mail-attachment.googleusercontent.com/attachment/
| 归档时间: |
|
| 查看次数: |
4188 次 |
| 最近记录: |