搜索启用 httpOnly 的可能方法来获取 cookie,我找不到任何方法。但话又说回来,Firebug、Add 'N Edit Cookie 等浏览器插件如何获取 cookie?攻击者不能这样做吗?
所以我的问题是,使用 javascript 获取启用 httpOnly 的请求的 cookie 真的真的不可能吗?
p/s:是的,我知道 httpOnly 不会阻止 XSS 攻击。我也知道它对嗅探器是徒劳的。让我们只关注 javascript,一种 alert(document.cookie) 类型/pre httpOnly 时代。
最佳答案
how do browser addons like Firebug, Add 'N Edit Cookie, etc. can get the cookies?
它们是浏览器扩展,浏览器可以访问cookies;扩展拥有比 JS 代码更高级别的权限。
is it really, really impossible to get cookie of httpOnly enabled requests, using javascript?
如果您使用的浏览器(即最近的浏览器) 支持 httpOnly 并且没有关于它的安全漏洞,那么这应该是不可能的——这就是 httpOnly 的目标。
引用 wikipedia :
When the browser receives such a cookie, it is supposed to use it as usual in the following HTTP exchanges, but not to make it visible to client-side scripts.
关于cookies - HttpOnly 和 document.cookie 的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1366182/