Project

General

Profile

Actions

Feature #21697

open

Set secure flag of the session cookie depending on original request

Feature #21697: Set secure flag of the session cookie depending on original request

Added by Anonymous almost 11 years ago. Updated 10 days ago.

Status:
Reopened
Priority:
Normal
Assignee:
-
Category:
Security
Target version:
-
Resolution:

Description

The default configuration of redmine sends session cookie open for any connection type. This allows an attacker to steal the session cookie and access one's redmine session.

It is possible to secure the cookie by changing the option in application.rb file.

config.session_store :cookie_store, :key => '_redmine_session', :secure => true

But this will prevent users from accessing system via plain HTTP protocol in local network.

Let Redmine set secure cookie flag depending on request scheme and X-Forwarded-Proto HTTP-header.


Files

21697-secure-session-cookie.patch (3.65 KB) 21697-secure-session-cookie.patch Ahesh Lakmal, 2026-11-26 15:26

Related issues 1 (0 open — 1 closed)

Related to Redmine - Feature #20935: Set autologin cookie as secure by default when using httpsClosedJean-Philippe LangActions

Updated by Go MAEDA almost 11 years ago Actions #1

  • Status changed from New to Closed
  • Resolution set to Duplicate

Fixed by #20935. Please try Redmine 3.2.0.

Updated by Go MAEDA almost 11 years ago Actions #2

  • Is duplicate of Feature #20935: Set autologin cookie as secure by default when using https added

Updated by Anonymous almost 11 years ago Actions #3

The issue #20935 doesn't seem to fix _redmine_session cookie.

Updated by Go MAEDA almost 11 years ago Actions #4

  • Status changed from Closed to Reopened

Updated by Go MAEDA almost 11 years ago Actions #5

  • Is duplicate of deleted (Feature #20935: Set autologin cookie as secure by default when using https)

Updated by Go MAEDA almost 11 years ago Actions #6

  • Related to Feature #20935: Set autologin cookie as secure by default when using https added

Updated by Go MAEDA almost 11 years ago Actions #7

  • Resolution deleted (Duplicate)

Updated by Mahesha Matharage almost 11 years ago Actions #9

This issue cannot simulate in the Dev environment.

Updated by Anonymous almost 11 years ago Actions #10

Steps to simulate task

  1. Set up redmine on host A, HTTP-port 80
  2. Set up reverse proxy on host B, SSL-port 443
  3. Get Redmine page via address http://A/redmine
  4. Get Redemin page via address https://B/redmine

Desired behaviour

  1. Browser receives header Set-Cookie: _redmine_session=...--...; path=/redmine/ from domain A
  2. Browser receives header Set-Cookie: _redmine_session=...--...; path=/redmine/; secure; HttpOnly from domain B

Updated by Toshi MARUYAMA about 9 years ago Actions #11

  • Description updated (diff)

Updated by Go MAEDA almost 4 years ago Actions #12

You can set secure attribute to the cookie by adding the following line to config/additional_environments.rb to force access over HTTPS.

config.force_ssl = true if Rails.env.production?

Updated by Popa Marius over 3 years ago Actions #13

Needs to be added to redmine site too

https://observatory.mozilla.org/analyze/redmine.org

Session cookie set without using the Secure flag or set over HTTP

Updated by Axel B. about 1 month ago Actions #14

Any updates on this one (after eleven years)? In Redmine 6.1 this is still an issue!

Updated by Ahesh Lakmal 10 days ago Actions #15

The attached patch sets the secure flag of the session cookie when the request is made over HTTPS. It uses request.ssl?, so it also works behind a reverse proxy that sets X-Forwarded-Proto, and access over plain HTTP keeps working without config.force_ssl.
This is the same behavior as the autologin cookie, whose secure flag already follows request.ssl? when autologin_cookie_secure is not set in configuration.yml.
Integration tests are added for HTTPS, for a reverse proxy with X-Forwarded-Proto, and for HTTP.

I also tested it in production mode behind an nginx TLS proxy and with Puma terminating TLS. Over HTTPS, the session cookie is no longer sent on plain HTTP requests and can no longer be overwritten by a cookie set over HTTP. HTTP-only installations keep working, existing sessions get the flag on their next HTTPS request, and API requests still create no session.
The change also applies to 6.0-stable, 6.1-stable and 7.0-stable, and the new tests pass there.

Would this approach be acceptable?

Actions

Also available in: PDF Atom