Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Security: reset_session doesn't work under some conditions (session fixation possible)

#2173

Hello,

As Rails 2.3 is not stable yet I think it won't hurt anyone if I publish this security related bug as a public ticket.

This bug is similiar to #1601 reset_session Doesn't Result In New Session Id Being Applied Via Set-Cookie.

Using ActiveRecord session store and setting session variables after invoking reset_session causes session id to not change. It is common to reset session, and then set authentication related variables in session to prevent session fixation. Under ActiveRecord store this attack is not prevented.

Example controller code:


  def authenticate
    session[:lazy_load_to_get_id]
    old_session_id = request.session_options[:id]
    reset_session # standard way to prevent session fixation
    session[:old_session_id] = old_session_id
    redirect_to :action => 'privileged_action'
  end

  def privileged_action
    if session[:old_session_id] == request.session_options[:id]
      render :text => 'Hey, session fixation is possible!'
    else
      render :text => 'Looks ok'
    end
  end

CookieStore handles this scenario correctly.

Tested on 2.3-rc2 and edge rails (revision 9b8cde41bc84466bf60fc4de6af54dbeb11cc0d6).

Reported by Pawel · March 8th, 2009 @ 05:32 PM

State: resolved
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. Pratik
    Pratik
    • Assigned user set to josh

    March 8th, 2009 @ 06:05 PM

  2. Repository
    Repository

    (from [224a534400fd622dda57058d1eed349b8375e5e3]) reset_session should force a new session id to be generated [#2173 Security: reset_session doesn't work under some conditions (session fixation ...] http://github.com/rails/rails/co...

    March 10th, 2009 @ 03:46 AM

  3. josh
    josh
    • State changed from new to resolved

    March 10th, 2009 @ 03:47 AM