I can't really imagine any case where setting empty strings as session
keys is a sensible thing to do. I therefore think we should add some
basic validation on the key. Perhaps we should have a minimum length of
5-8 characters, because it would be just as problematic if it were only
one or two characters. This doesn't make it impossible to have weak
session keys, but it is a very basic hardening that would protect us from
such a bug in the future.
Without having looked at the code, my first idea is that this belongs in
the session backends somewhere. This breaks backwards compatibility, but
given the rationale I think a mention in the release notes is sufficient.
--
Ticket URL: <https://code.djangoproject.com/ticket/24915>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24915#comment:1>
* status: new => assigned
* owner: nobody => sp1ky
--
Ticket URL: <https://code.djangoproject.com/ticket/24915#comment:2>
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/4807
Changed _session_key attribute to a property and implemented basic
validation in the setter. The session key must be 'truthy' and
at least 8 characters long. Otherwise, the value is set to None
--
Ticket URL: <https://code.djangoproject.com/ticket/24915#comment:3>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/24915#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f4416b1a8b92e492707a6261b7a1132f8550457f" f4416b1]:
{{{
#!CommitTicketReference repository=""
revision="f4416b1a8b92e492707a6261b7a1132f8550457f"
Fixed #24915 -- Added stricter session key validation
Changed _session_key attribute to a property and implemented basic
validation in the setter. The session key must be 'truthy' and
at least 8 characters long. Otherwise, the value is set to None.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24915#comment:5>
Comment (by erikr):
@sp1ky: thanks for the patch. This patch might qualify under the Google
Patch Rewards programme: http://www.google.com/about/appsecurity/patch-
rewards/
As the patch author, you can try to submit it.
A patch only qualifies once it has been shipped in a release, so you will
have to wait with your submission until 1.9 is actually released. If you
do submit, I'd make sure to mention the blogpost about the vulnerability,
as it shows this is actually a real potential problem that we've now, at
least partially, tackled for the future.
--
Ticket URL: <https://code.djangoproject.com/ticket/24915#comment:6>
Comment (by timgraham):
In my experience you don't need to wait until the release ships to submit
to Google.
--
Ticket URL: <https://code.djangoproject.com/ticket/24915#comment:7>
Comment (by sp1ky):
Cool, thanks for the tip @timgraham, @erikr. I'll fire a message off to
the Patch Rewards program and see what happens!
--
Ticket URL: <https://code.djangoproject.com/ticket/24915#comment:8>