Opened 5 years ago

Closed 5 years ago

#1485336 closed Bugs (fixed)

Cookies should be set as 'secure' over SSL

Reported by: mkj Owned by:
Priority: 5 Milestone: 0.2-beta
Component: Security Version: 0.2-alpha
Severity: normal Keywords:
Cc:

Description

Even if a website is set up using SSL, an active attacker can steal cookies unless the cookies have been set 'secure' - see http://fscked.org/blog/fully-automated-active-https-cookie-hijacking

Roundcube doesn't set cookies as secure. It looks like the only place that needs changing is the second setcookie() in
session.inc

Something like

setcookie(session_name(), $random, $lifetime, $cookie['path'], $cookie['domain'],  $_SERVER["HTTPS"]);

might be the way to go? (I haven't used PHP much so am guessing from the docs).

Change History (6)

comment:1 Changed 5 years ago by alec

  • Milestone changed from later to 0.2-beta

comment:2 Changed 5 years ago by robin

Index: program/include/session.inc
===================================================================
--- program/include/session.inc (revision 1760)
+++ program/include/session.inc (working copy)
@@ -184,7 +184,8 @@
   $lifetime = $cookie['lifetime'] ? time() + $cookie['lifetime'] : 0;

   setcookie(session_name(), '', time() - 3600);
-  setcookie(session_name(), $random, $lifetime, $cookie['path'], $cookie['domain']);
+  setcookie(session_name(), $random, $lifetime, $cookie['path'], $cookie['domain'],
+                       $_SERVER['HTTPS'] && ($_SERVER['HTTPS']!='off'));

   return true;
 }

I have no test-RC running over https so cannot test that. Over http this doesn't have any impact.

comment:3 Changed 5 years ago by mkj

I've tested that patch here (with roundcube 0.1.1 though) and it sets the logged-in sessionid cookie as secure, but doesn't set the initial pre-login session cookie as secure. I'm not sure if that really matters though? Does the pre-login session cookie get used for anything?

session_set_cookie_params() could be used to setup the initial cookie as secure I think.

comment:4 Changed 5 years ago by tensor

I guess the prelogin cookie should also be secured.

comment:5 Changed 5 years ago by robin

Pre-login does not need to be 'secured'. Session cookie security fixed in [d0b973cf].

comment:6 Changed 5 years ago by robin

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.