Hi internals,
I'd like to propose this RFC to introduce a time-constant string comparison function: https://wiki.php.net/rfc/timing_attack
I will not open the voting before January 7 to account for holidays.
Best regards
Rouven
Hi Rouven,
On Mon, Dec 23, 2013 at 2:08 AM, Rouven Weßling me@rouvenwessling.dewrote:
I'd like to propose this RFC to introduce a time-constant string
comparison function: https://wiki.php.net/rfc/timing_attackI will not open the voting before January 7 to account for ho
As you mentioned in code, users should not use when known or user supplied
string
is null.
How about add E_NOTICE
error for that case?
If user shouldn't then we are better to warn them.
Comparison is good since it always does the same operation based on user
supplied
string. (Unless compiler does optimizations that I don't expect)
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hi,
On Mon, Dec 23, 2013 at 1:08 AM, Rouven Weßling me@rouvenwessling.dewrote:
Hi internals,
I'd like to propose this RFC to introduce a time-constant string
comparison function: https://wiki.php.net/rfc/timing_attack
On the whole it looks okay.
The special branch for known_len == 0 && user_len != 0
can be avoided by
doing something like this:
mod_len = max(known_len, 1);
And then use j % mod_len
instead of j % known_len
to avoid a division
by zero; since x mod 1
always yields 0
you will always be comparing
against the null byte of the known string.
I will not open the voting before January 7 to account for holidays.
Best regards
Rouven
--
Tjerk
Hi!
I'd like to propose this RFC to introduce a time-constant string
comparison function: https://wiki.php.net/rfc/timing_attack
I wonder how practical this would be. There are probably many side
channels in PHP related to how PHP manages memory, copies variables,
processes opcodes, etc. so I wonder if providing such function for PHP
API would practically add anything or if you should be doing crypto that
sensitive in PHP anyway?
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
Hi!
I'd like to propose this RFC to introduce a time-constant string
comparison function: https://wiki.php.net/rfc/timing_attackI wonder how practical this would be. There are probably many side
channels in PHP related to how PHP manages memory, copies variables,
processes opcodes, etc. so I wonder if providing such function for PHP
API would practically add anything or if you should be doing crypto that
sensitive in PHP anyway?
One of the chaps on SO done a bit of testing, it appears that without
usleep in php land you cannot avoid cpu spikes, and so cannot get a
reliable vector of attack unless the server side code has been prepared
to be attacked. But this is only testing.
I see the things you see, however, probably better to do something than
nothing I think, this is technically the correct thing to do, and is
simple enough, so I say do it ...
Cheers
Joe
Hi Stas.
I'd like to propose this RFC to introduce a time-constant string
comparison function: https://wiki.php.net/rfc/timing_attackI wonder how practical this would be. There are probably many side
channels in PHP related to how PHP manages memory, copies variables,
processes opcodes, etc. so I wonder if providing such function for PHP
API would practically add anything or if you should be doing crypto that
sensitive in PHP anyway?
Indeed, a managed language like PHP will never be able to guarantee safety in this regard. However while you may be able to gain information about the length of the known string, I doubt it will be possible to exploit the string comparison itself (getting byte for byte closer to the hash).
As for your last point, you don't need to do terribly sensitive crypo for this to make sense. Any password hash comparison will do.
That there's a need for this sort of thing is probably demonstrated by the fact, that this is already used by major framework like Joomla! and Symfony2, but implemented in pure PHP which suffers even more from the issues you describe. Also PHP core does something like this already, but only in the narrow use case of password_verify.
One of the chaps on SO done a bit of testing, it appears that without usleep in php land you cannot avoid cpu spikes, and so cannot get a reliable vector of attack unless the server side code has been prepared to be attacked. But this is only testing.
Do you have a link to that discussion? It'd probably be interesting to read in the context of this discussion.
Best regards
Rouven