Feature #21697
open
Set secure flag of the session cookie depending on original request
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.
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
Updated by Go MAEDA almost 11 years ago
- 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
- Is duplicate of Feature #20935: Set autologin cookie as secure by default when using https added
Updated by Anonymous almost 11 years ago
The issue #20935 doesn't seem to fix _redmine_session cookie.
Updated by Go MAEDA almost 11 years ago
- Status changed from Closed to Reopened
Updated by Go MAEDA almost 11 years ago
- Is duplicate of deleted (Feature #20935: Set autologin cookie as secure by default when using https)
Updated by Go MAEDA almost 11 years ago
- Related to Feature #20935: Set autologin cookie as secure by default when using https added
Updated by Go MAEDA almost 11 years ago
- Resolution deleted (
Duplicate)
Updated by Mahesha Matharage almost 11 years ago
This issue cannot simulate in the Dev environment.
Updated by Anonymous almost 11 years ago
Steps to simulate task¶
- Set up redmine on host A, HTTP-port 80
- Set up reverse proxy on host B, SSL-port 443
- Get Redmine page via address http://A/redmine
- Get Redemin page via address https://B/redmine
Desired behaviour¶
- Browser receives header
Set-Cookie: _redmine_session=...--...; path=/redmine/from domain A - Browser receives header
Set-Cookie: _redmine_session=...--...; path=/redmine/; secure; HttpOnlyfrom domain B
Updated by Toshi MARUYAMA about 9 years ago
- Description updated (diff)
Updated by Go MAEDA almost 4 years ago
Updated by Popa Marius over 3 years ago
Needs to be added to redmine site too
Updated by Axel B. about 1 month ago
Any updates on this one (after eleven years)? In Redmine 6.1 this is still an issue!
Updated by Ahesh Lakmal 10 days ago
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?