Session Loss and Session Fixation in ColdFusion

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:

http://example.com/index.cfm?CFID=1&CFTOKEN=2

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 this.name="apples" and this.name="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 this.name="apples" to this.name="fruit" and this.name="oranges" to this.name="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().



Related Entries

This entry was:

 Download FuseGuard WAF for ColdFusion

Trackbacks

Trackback Address: 815/1D58EF3EE0A01D5A17F7291F542A5867

Comments

On 03/04/2013 at 5:30:30 AM EST Julian Halliwell wrote:
1
Hi Pete

There's another scenario where the session fixation patch can lead to session loss: conditional manual setting of session cookies. See http://cfsimplicity.com/4/coldfusion-security-hotfix-changes-session-behaviour

Post a Comment




  



Spell Checker by Foundeo

Recent Entries



foundeo


did you hack my cf?