Skip to content

Commit e5daacf

Browse files
committed
issue2551370 - prefix session cookie with __Secure- over https
Limit use of roundup session cookie to HTTPS protocol by adding __Secure- prefix. Automatic testing includes http behavior only. Https behavious has been manually tested only. Need to be able to spin up an https server using wsgiref to test https behavior in CI. issue 2551373 opened to track automatic testing of https behavior.
1 parent b7cdf7b commit e5daacf

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Features:
4545
one-by-one (using the check function) but instead offload the
4646
permission checks to the database. For SQL backends this performs the
4747
filtering in the database. (Ralf Schlatterbeck)
48+
- issue2551370 - mark roundup session cookie with __Secure-
49+
prefix. (John Rouillard)
4850

4951
2024-07-13 2.4.0
5052

doc/upgrading.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ to::
133133
at the top of both files. The icing macro used in other tracker
134134
templates was renamed to frame in this tracker template.
135135

136+
More secure session cookie handling (info)
137+
------------------------------------------
138+
139+
This affects you if you are accessing a tracker via https. The name
140+
for the cookie that you get when logging into the web interface has a
141+
new name. When upgrading to Roundup 2.5 all users will have to to log
142+
in again. The cookie now has a ``__Secure-`` prefix to prevent it
143+
from being exposed/used over http.
144+
145+
If your tracker is using the unencrypted http protocol, nothing has
146+
changed.
147+
148+
See
149+
https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#cookie_prefixes
150+
for details on this security measure.
136151

137152

138153
.. index:: Upgrading; 2.3.0 to 2.4.0

roundup/cgi/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ def __init__(self, client):
190190
self.session_db = client.db.getSessionManager()
191191

192192
# parse cookies for session id
193-
self.cookie_name = 'roundup_session_%s' % \
194-
re.sub('[^a-zA-Z]', '', client.instance.config.TRACKER_NAME)
193+
if self.client.secure:
194+
cookie_template = '__Secure-roundup_session_%s'
195+
else:
196+
cookie_template = 'roundup_session_%s'
197+
self.cookie_name = cookie_template % \
198+
re.sub('[^a-zA-Z]', '', client.instance.config.TRACKER_NAME)
195199
cookies = LiberalCookie(client.env.get('HTTP_COOKIE', ''))
196200
if self.cookie_name in cookies:
197201
try:

test/test_liveserver.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ def create_login_session(self, username="admin", password="sekrit",
176176
return session
177177
return session, response
178178

179+
def test_cookie_attributes(self):
180+
session, _response = self.create_login_session()
181+
182+
cookie_box = session.cookies._cookies['localhost.local']['/']
183+
cookie = cookie_box['roundup_session_Roundupissuetracker']
184+
185+
# check cookie attributes. This is an http session, so
186+
# we can't check secure or see cookie with __Secure- prefix 8-(.
187+
self.assertEqual(cookie.name, 'roundup_session_Roundupissuetracker')
188+
self.assertEqual(cookie.expires, None) # session cookie
189+
self.assertEqual(cookie._rest['HttpOnly'], None) # flag is present
190+
self.assertEqual(cookie._rest['SameSite'], 'Lax')
179191

180192
def test_query(self):
181193
current_user_query = (

0 commit comments

Comments
 (0)