I think that if $_COOKIE[SECUREPAGES_SESSID] is found on an unsecured page load then the session should be destroyed.

function securepages_prevent_hijack_init() {
...
  // If the cookie exists on an unsecured page then there's a chance for the
  // session to be stolen.  Destroy the session.
  elseif (!securepages_is_secure() && isset($_COOKIE[SECUREPAGES_SESSID])) {
    watchdog('security',
    t('Session hijack attempt detected for user %user!',
    array('%user' => $user->name)));

    session_destroy();
    $user = drupal_anonymous_user();
    sess_regenerate();
    drupal_access_denied();
    exit();
  }

Comments

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new1011 bytes

Try this.

grendzy’s picture

Status: Needs review » Needs work

Can you explain how this might occur? The secure flag on the cookie would normally prevent this. Are there any known conditions where this flag isn't honored?

damienmckenna’s picture

It's a pretty far reaching case and would probably have to have other things involved (XSS, maybe) but isn't it worth the few extra lines of code just to close off a possible gap, however probable?