无法通过 ColdFusion 在浏览器中禁用 HttpOnly 标志

Could not disable HttpOnly flag in browser via ColdFusion

在我们的应用程序中,我们使用 J2EE 会话变量进行会话管理。我们最近从 ColdFusion 9 迁移到 ColdFusion 2018。迁移后,注销功能不起作用。我们发现,在 ColdFusion 2018 中,cookie JSESSIONID 并未从浏览器中清除,因为 HttpOnly 标志已在浏览器中设置为 true。

我们尝试通过以下方式在浏览器中禁用此 HttpOnly 标志,

By disabling HttpOnly flag and Global Script Protection in CF admin.
By modifying the jvm.config via CF admin by adding "-Dcoldfusion.sessioncookie.httponly=false".

但是这样 HttpOnly 标志在浏览器中仍然显示为已启用。因此,客户端脚本无法清除 cookie JSESSIONID,因此注销功能无法正常工作。

在 CF2018 中,有什么方法可以在浏览器中禁用 cookie JSESSIONID 的 HttpOnly 标志吗?

注:

在 CF9 中,浏览器中禁用了 cookie JSESSIONID 的 HttpOnly 标志。 我们使用的是CF2018企业版(试用版,还没过期)。 更新 CF 管理中的设置后重新启动 CF 服务。

您可能必须重构您的应用程序以解决许多开箱即用的 CF 9 无法处理的 OWASP 漏洞。根据您的受众,您应该让第 3 方针对您的代码库执行安全渗透测试。

您将需要重构您的注销过程。您不应该在 jsessionid cookie 上禁用 httpOnly,这是为了防止跨站点脚本攻击。

https://www.owasp.org/index.php/HttpOnly

According to the Microsoft Developer Network, HttpOnly is an additional flag included in a Set-Cookie HTTP response header. Using the HttpOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).

https://docs.microsoft.com/en-us/previous-versions//ms533046(v=vs.85)?redirectedfrom=MSDN

使用 JEE 会话 ID 时,您需要将此添加到注销过程的一部分:

<cfset getPageContext().getSession().invalidate()>

然后重定向到另一个页面,例如您的登录屏幕。这将删除 jsessionid cookie 并实际上使服务器上的 JEE 会话无效。