Petri Lehtinen <pe...@digip.org> added the comment:

For example, Django uses time independent comparison to compare signatures of 
signed cookies. A signed cookie consists of a plain-text value followed by a 
signature.

An attacker wants to construct a cookie that has a malformed value and a valid 
signature for that value. Let's assume that a signature is a string of 16 hex 
characters.

If a short-cut comparison was used, the attacker would require at most 16 tries 
to find out the first character. He first tries the signature "000...0", then 
"100...0", and so on until he notices that Django takes a slightly longer time 
to respond. Now he know what's the first character of the hash, let's assume 
it's "8". He then tries "8000...0", "810...0", and so on until he finds the 
second character. He continues this until he has the correct 16 characters. 
This takes at most 16 * 16 tries.

But because Django uses a constant-time comparison function, the attacker 
cannot guess one character at a time, and he needs 16 ** 16 tries.

In real world, 16 * 16 tries is not enough, of course. But repeating the same 
requests many times, the timing variations can be used to reveal which is the 
correct character in each step.

----------
nosy: +petri.lehtinen

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15061>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to