User-editable HTML XSS protection (tumblr like)

早过忘川 提交于 2019-12-01 03:56:56

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

So I guess that you want to enable javascript for them but you do not want to allow manipulating cookies. This should be simple: just place it before the user's page loads:

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?)

This is also simple - cookies supports this. Its domain attribute:

Set-Cookie: name=value; path=/; domain=.example.com

auth cookies should be httponly?..

Of course - they should be for the better security.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!