Pete Freitag Pete Freitag

Session Loss and Session Fixation in ColdFusion


I often find myself explaining how the session fixation security hotfix (APSB11-04) might cause session loss under certain circumstances, so I figured it was time for a blog entry explaining it.

Ok, first what is session fixation?

A session fixation vulnerability exists when an attacker can direct the victim to use a specific session identifier. So for example, suppose I say hey follow this link:

Now when you visit this link, if CF allows you to use that new session identifier to maintain valid session, you have a session fixation problem. The attacker can now mirror the session id on his computer and also have access to your session.

How does ColdFusion session fixation protection work?

ColdFusion now checks to see if the CFID/CFTOKEN passed in the url, cookie, form, etc are valid for the current ColdFusion application. If the CFIDE/CFTOKEN passed do not correspond to a valid session in the CF application, then a new set of CFID/CFTOKEN is generated and set as cookies.

So how does this lead to session loss?

The only circumstances I'm aware of which causes session loss is due to having multiple ColdFusion applications that reside on the same domain, with different application names.

So assume I have a domain with two ColdFusion applications /apples/ and /oranges/ each folder has its own Application.cfc or Application.cfm with a different application name (eg"apples" and"oranges").

Now consider the following condition:

  1. Request /apples/
  2. Successfully logs in under /apples/
  3. Makes a request under /oranges/
  4. Makes a request back to /apples/ (they appear to be logged out)

And here's what happens:

  1. User is given a set of cookies CFID=1 CFTOKEN=1
  2. Session variable is set to keep user authenticated with session CFID=1 CFTOKEN=1
  3. CF see's CFID=1 CFTOKEN=1 and says that is NOT a valid session for the Application "oranges", here's a new set of session ids: CFID=2 CFTOKEN=2
  4. CF see's CFID=2 CFTOKEN=2 and says that is NOT a valid session for the Application "apples" here's a new set of session ids: CFID=3 CFTOKEN=3, you are still technically logged in under CFID=1 and CFTOKEN=1 but your cookies no longer correspond to that session, so for all intensive purposes you are logged out of /apples/

So how do you prevent the session loss?

There are a few ways you can do this:

  1. Set a path on the CFID and CFTOKEN cookies so the browser sends the correct cookie to the correct domain, you can do this in OnSessionStart if you specify this.setclientcookies=false. You can see an example of how to set the session cookies in my blog entry on HttpOnly session cookies.
  2. You can set both application names to be equivalent, that is change"apples" to"fruit" and"oranges" to"fruit" this will cause the two applications to also share application and session scopes, so that may not be a good idea if your applications clash on naming.
  3. You can disable the session fixation patch in ColdFusion by adding the JVM argument -Dcoldfusion.session.protectfixation=false to your server. This is a good way to find out if the session fixation patch is indeed causing your problem, or if it is something else. I recently helped a client with session loss, and their problem actually ended up being on the load balancer so it is handy to test using this before making code changes. But keep in mind that when you do this you are giving up some security.

How can I further protect myself from session fixation

This patch doesn't fully protect you from session fixation attacks, you really should rotate session id's after a successful login, and terminate the session on logout. You can do this with two new functions on ColdFusion 10, SessionRotate() and SessionInvalidate().

Like this? Follow me ↯

Session Loss and Session Fixation in ColdFusion was first published on March 01, 2013.

If you like reading about coldfusion, session, fixation, or security then you might also like:

FuseGuard Web App Firewall for ColdFusion

The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.


Hi Pete

There's another scenario where the session fixation patch can lead to session loss: conditional manual setting of session cookies. See
by Julian Halliwell on 03/04/2013 at 3:30:30 AM UTC

Post a Comment