[Django] #31412: database timing attack against sessions

51 views
Skip to first unread message

Django

unread,
Mar 31, 2020, 4:58:08 PM3/31/20
to django-...@googlegroups.com
#31412: database timing attack against sessions
--------------------------------------------+------------------------
Reporter: Brian May | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
CVE-2019-16782 was assigned to Ruby Rack. Basically, an attacker, can
conduct a timing attack by sending specially crafted session ids and
timing how long it takes for the database to lookup the session. From this
the attacker can guess valid session ids.

To me it looks like Django, by default, stores sessions on the database
(using django.contrib.sessions.backends.db) in a very similar manner. Does
this also mean it is vulnerable to the same timing attack?

--
Ticket URL: <https://code.djangoproject.com/ticket/31412>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 31, 2020, 5:07:16 PM3/31/20
to django-...@googlegroups.com
#31412: database timing attack against sessions
----------------------------------+--------------------------------------

Reporter: Brian May | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by Brian May):

The security issue referenced here is already public, I don't see any
issues with making this bug report public also. Apologies if I got this
wrong.

--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:1>

Django

unread,
Mar 31, 2020, 6:04:36 PM3/31/20
to django-...@googlegroups.com
#31412: database timing attack against sessions
----------------------------------+--------------------------------------

Reporter: Brian May | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by Simon Charette):

Looking at
[https://github.com/rack/rack/commit/7fecaee81f59926b6e1913511c90650e76673b38
Rack patch] I think this might have a bit of overlap with #21076
([https://github.com/django/django/pull/8736 PR]). If session ID were
hashed it wouldn't be possible to use timing attacks on the btree-index to
statistically walk your way to a valid session ID.

--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:2>

Django

unread,
Mar 31, 2020, 7:06:36 PM3/31/20
to django-...@googlegroups.com
#31412: database timing attack against sessions
----------------------------------+--------------------------------------

Reporter: Brian May | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by Brian May):

Replying to [comment:2 Simon Charette]:


> Looking at
[https://github.com/rack/rack/commit/7fecaee81f59926b6e1913511c90650e76673b38
Rack patch] I think this might have a bit of overlap with #21076
([https://github.com/django/django/pull/8736 PR]). If session ID were
hashed it wouldn't be possible to use timing attacks on the btree-index to

statistically walk your way to a valid session ID. It might be time to
revive that old PR.

Agreed.

The Rack solution become complicated because (a) they wanted to preserve
existing sessions and (b) for reasons I don't understand they decided to
split the session id into a "public" session id and a "private" session id
where the names "public" (meaning non-hashed id) and "private" (meaning
hashed id) don't mean what you might expect (they both need to remain
secret).

--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:3>

Django

unread,
Apr 1, 2020, 12:49:17 AM4/1/20
to django-...@googlegroups.com
#31412: database timing attack against sessions
----------------------------------+--------------------------------------

Reporter: Brian May | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Simon Charette):

* cc: Simon Charette (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:4>

Django

unread,
Apr 1, 2020, 2:03:48 AM4/1/20
to django-...@googlegroups.com
#31412: Database timing attack against sessions.
----------------------------------+--------------------------------------

Reporter: Brian May | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by felixxm):

* cc: Florian Apolloner, Paul McMillan (added)


Comment:

We discussed this

--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:5>

Django

unread,
Apr 7, 2020, 1:31:52 PM4/7/20
to django-...@googlegroups.com
#31412: Database timing attack against sessions.
----------------------------------+--------------------------------------
Reporter: Brian May | Owner: Mark
Type: Bug | Status: assigned
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Mark):

* owner: nobody => Mark
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:6>

Django

unread,
Apr 8, 2020, 10:21:14 AM4/8/20
to django-...@googlegroups.com
#31412: Database timing attack against sessions.
----------------------------------+--------------------------------------
Reporter: Brian May | Owner: (none)

Type: Bug | Status: new
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Mark):

* owner: Mark => (none)
* status: assigned => new


Comment:

I deassigned myself because I noticed this issue wasn't accepted yet.

I ''am'' picking up #21076 and looking into updating and improving
[https://github.com/django/django/pull/8736 PR#8736]

--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:7>

Django

unread,
Apr 23, 2020, 9:47:08 AM4/23/20
to django-...@googlegroups.com
#31412: Database timing attack against sessions.
----------------------------------+--------------------------------------
Reporter: Brian May | Owner: (none)
Type: Bug | Status: closed
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => wontfix


Comment:

Thank you for the report.

After consideration, the Django Security Team conclude that this is not a
practical attack vector.

Work on the related hardenings, such as the referenced tickets should
continue.

--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:8>

Django

unread,
Jan 31, 2021, 1:07:33 PM1/31/21
to django-...@googlegroups.com
#31412: Database timing attack against sessions.
----------------------------------+--------------------------------------
Reporter: Brian May | Owner: (none)
Type: Bug | Status: closed
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by shamrin):

Carlton, could you please share Django Security Team reasoning about the
impractically of session timing attack?

This page shows up if you search for general session storage
implementation advice (not specific to Django). It would be nice to learn
the details, if you can share them.

--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:9>

Django

unread,
Feb 2, 2021, 4:19:34 AM2/2/21
to django-...@googlegroups.com
#31412: Database timing attack against sessions.
----------------------------------+--------------------------------------
Reporter: Brian May | Owner: (none)
Type: Bug | Status: closed
Component: contrib.sessions | Version: 3.0
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by Carlton Gibson):

Alexey, what was missing was a demonstration of how this might be
exploited. Yes, work on the related tickets but this wasn't something we
need to pick up as a security issue.

If that is not correct, a proof-of-concept sent privately to
secu...@djangoproject.com as per the
[https://docs.djangoproject.com/en/dev/internals/security/ Reporting
security issues guidance] is appreciated.

--
Ticket URL: <https://code.djangoproject.com/ticket/31412#comment:10>

Reply all
Reply to author
Forward
0 new messages