#36901: Centralize mitigations against timing attacks targeting user enumeration
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Afenomamy
Type: | Status: assigned
Cleanup/optimization |
Component: contrib.auth | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Afenomamy):
So my plan is :
1 - Create two utility functions called **get_user_with_mitigation** and
**aget_user_with_mitigation** inside django.contrib.auth.__init__.py.
2 - Update **django.contrib.auth.handlers.modwsgi.check_password** to use
''get_user_with_mitigation''
3 - Refactor authenticate and aauthenticate in
**
django.contrib.auth.backends.py** to use ''get_user_with_mitigation and
aget_user_with_mitigation'' .
NB :
- For **Attribute Safety**: getattr(user, 'is_active', True) will be
used to ensure compatibility with custom user models that do not define
an is_active field. This will resolve the reported AttributeError.
- For **Performance:** make_password will be called directly for
the dummy hashing. This avoids the overhead of instantiating a UserModel
instance simply to call set_password().
--
Ticket URL: <
https://code.djangoproject.com/ticket/36901#comment:6>