gpt4 book ai didi

security - 用户可编辑的 HTML XSS 保护(类似 tumblr)

转载 作者:行者123 更新时间:2023-12-02 20:17:08 25 4
gpt4 key购买 nike

我希望我的服务有这样的功能:作者可以完全自定义页面,但不能窃取用户的cookie。

Tumblr 遇到了一些麻烦,但成功解决了它们 http://www.riyazwalikar.com/2012/07/stored-persistent-xss-on-tumblr.html

所以我需要解决方案

  1. 不加节制
  2. 用户-作者可以完全访问页面的 html 代码,不需要白名单过滤和模板语言(这就是现在的工作方式:( )
  3. 没有机会窃取彼此的 cookie(在其他作者的页面上)
  4. 集中身份验证数据库
  5. 理想:无需在每个作者页面上进行身份验证

据我了解 tumblr:

  1. 独立的域无法访问彼此的 Cookie
  2. 用户仍然在每个子域上进行身份验证(如何???www.tumblr.com js 可以访问主 session cookie?安全吗?)
  3. auth cookie 应该是 httponly 吗?..

我能为用户提供安全舒适的解决方案吗?cookie 盗窃是完全访问 html 的主要问题吗?

最佳答案

I want my service to have such a feature: author can fully customize the page, but can't steal users' cookies.

所以我猜您想为它们启用 javascript,但又不想允许操作 cookie。这应该很简单:只需将其放在用户页面加载之前即可:

if (document.__defineGetter__)
{
document.__defineGetter__("cookie", function () { return ""; } );
document.__defineSetter__("cookie", function () { } );
}
else // IE
{
Object.defineProperty(document, "cookie",
{
get: function () { return ""; },
set: function () { return true; },
});
}
<小时/>

users are still authenticated on each subdomain (HOW??? www.tumblr.com js has access to main session cookies? Is that secure?)

这也很简单——cookies 支持这一点。它的 domain 属性:

Set-Cookie: name=value; path=/; domain=.example.com
<小时/>

auth cookies should be httponly?..

当然 - 它们应该是为了更好的安全性。

关于security - 用户可编辑的 HTML XSS 保护(类似 tumblr),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16267847/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com