Use HMAC and constant-time comparison functions where needed in Django
|Reported by:||lukeplant||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Various places in Django use MD5/SHA1 based methods as a kind of MAC (Message Authentication Code). HMAC is a much better alternative.
In most cases, we need to maintain backwards compatibility with existing signed values, by falling back to the existing MD5/SHA1 method. This means we will continue to have potential weaknesses, but by only generating HMACs from now on, we can phase out support for these old values over time, using the normal deprecation method. This should give plenty of time for the old hashes to expire naturally anyway.
In addition, in all these places, and some others, the MACs are tested for validity using simple string equality, which potentially opens us up to timing-based attacks to discover the tokens.
Change History (7)
comment:1 Changed 4 years ago by lukeplant
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 4 years ago by gabrielhurley
- Has patch set
- milestone set to 1.3
- Triage Stage changed from Unreviewed to Accepted
comment:3 Changed 4 years ago by lukeplant
- Resolution set to fixed
- Status changed from new to closed