使用 JRun/ColdFusion 强制使用 HttpOnly cookie

发布于 2024-07-25 02:23:44 字数 375 浏览 7 评论 0原文

我们需要确保 CF7 站点上的所有 cookie 均设置为 HttpOnly。

我们使用 jsessionid 来控制我们的会话,JRun 不会将其创建为 HttpOnly。

虽然可以修改现有的 cookie 来添加此设置,但我们需要从一开始就将其设置为 HttpOnly。

有什么建议么?


相关问题:为 HTTPS cookie 设置安全标志。

We need to ensure that all cookies on a CF7 site are set as HttpOnly.

We are using jsessionid to control our sessions, and JRun does not create this as HttpOnly.

Whilst it is possible to modify an existing cookie to add this setting, we need to have it set to HttpOnly from the start.

Any suggestions?

Related Question: Setting Secure flag for HTTPS cookies.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

策马西风 2024-08-01 02:23:44

来自:http://www.petefreitag.com/item/764.cfm

运行 CF 8 或更低版本并使用 Application.cfc

<cfcomponent>
  <cfset this.sessionmanagement = true>
  <cfset this.setclientcookies = false>
  <cffunction name="onSessionStart">
      <cfheader name="Set-Cookie" value="CFID=#session.CFID#;path=/;HTTPOnly">
      <cfheader name="Set-Cookie" value="CFTOKEN=#session.CFTOKEN#;path=/;HTTPOnly">
  </cffunction>
<cfcomponent>

确保已指定 setclientcookies = false。

如果使用 Application.cfm

如果您仍在使用 Application.cfm 文件,则可以使用以下内容:

<cfapplication setclientcookies="false" sessionmanagement="true" name="test">
<cfif NOT IsDefined("cookie.cfid") OR NOT IsDefined("cookie.cftoken")>
   <cfheader name="Set-Cookie" value="CFID=#session.CFID#;path=/;HTTPOnly">
   <cfheader name="Set-Cookie" value="CFTOKEN=#session.CFTOKEN#;path=/;HTTPOnly">
</cfif>

From: http://www.petefreitag.com/item/764.cfm

Running CF 8 or Lower and using Application.cfc

<cfcomponent>
  <cfset this.sessionmanagement = true>
  <cfset this.setclientcookies = false>
  <cffunction name="onSessionStart">
      <cfheader name="Set-Cookie" value="CFID=#session.CFID#;path=/;HTTPOnly">
      <cfheader name="Set-Cookie" value="CFTOKEN=#session.CFTOKEN#;path=/;HTTPOnly">
  </cffunction>
<cfcomponent>

Make sure you have setclientcookies = false specified.

If Using Application.cfm

If you are still using an Application.cfm file, you can use the following:

<cfapplication setclientcookies="false" sessionmanagement="true" name="test">
<cfif NOT IsDefined("cookie.cfid") OR NOT IsDefined("cookie.cftoken")>
   <cfheader name="Set-Cookie" value="CFID=#session.CFID#;path=/;HTTPOnly">
   <cfheader name="Set-Cookie" value="CFTOKEN=#session.CFTOKEN#;path=/;HTTPOnly">
</cfif>
胡大本事 2024-08-01 02:23:44

首先,热烈欢迎所有 PCI DSS 难民! Appscan、Webinspect、Hailstorm 和 NTOSpider 逃犯也受到邀请。 请坐在这里,我为您准备了蛋糕:

虽然对 Peter 来说为时已晚,但实际上可以让 JRun 按照他的要求从一开始就生成 HTTPOnly(且安全)cookie。 查找jrun-web.xml 文件。 它可能位于

C:\JRun4\servers\servername\cfusion-ear\cfusion-war\WEB-INF\ 之类的目录中。

您必须将以下内容添加到 cookie-config 部分

<cookie-config>
    <cookie-path>/;HttpOnly</cookie-path>
</cookie-config>

如果您的网站是 HTTPS,您还应该启用安全 cookie 选项。 但要小心,它是服务器范围的,而不是特定于应用程序的。 所以它可能不适合您的共享环境:

<cookie-config>
    <cookie-secure>true</cookie-secure>
    <cookie-path>/;HttpOnly</cookie-path>
</cookie-config>

如果您没有陷入MX7或CF8,有一个官方设置 CF9.01 Dcoldfusion.sessioncookie.httponly

我已经在 ColdFusion MX 上对此进行了测试7、它按预期工作。 我躲开了Appscan。

First, a warm welcome to all PCI DSS refugees! Appscan, Webinspect, Hailstorm and NTOSpider fugitives are also invited. Take a seat right over here, I have cake for you:

While too late for Peter, it is in fact possible to have JRun generate HTTPOnly (and secure) cookies from the start as he asked. Look for the jrun-web.xml file. It will probably be in a directory like

C:\JRun4\servers\servername\cfusion-ear\cfusion-war\WEB-INF\.

You have to add the following to the cookie-config section:

<cookie-config>
    <cookie-path>/;HttpOnly</cookie-path>
</cookie-config>

If your site is HTTPS, you should also enable the secure cookie option. But be careful, its server wide, not application specific. So it may not be suitable for your shared environment:

<cookie-config>
    <cookie-secure>true</cookie-secure>
    <cookie-path>/;HttpOnly</cookie-path>
</cookie-config>

If you are not stuck in MX7 or CF8, there is an official setting for this in CF9.01 Dcoldfusion.sessioncookie.httponly

I've tested this on ColdFusion MX7 and it works as expected. Dodged Appscan I did.

从此见与不见 2024-08-01 02:23:44

<块引用>

我们的目标是确保第一个请求的安全(并通过扫描),因此如果这篇文章涵盖了这一点,那么它将解决问题。

如果我错了,请纠正我,但听起来如果请求通过 HTTP 传入,您需要重定向到 HTTPS。 在请求发送到 ColdFusion 之前,您是否无法通过 URL 重写规则捕获此问题?

The goal is for the first request to be secure (and pass the scanning), so if this post covers that then it will solve the problem.

Correct me if I'm wrong, but it sounds like you need to redirect to HTTPS if a request comes in over HTTP. Can you not catch this with a URL rewriting rule, before the request is sent to ColdFusion at all?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文