Live data from Hacker News

It's All About Time – Remote timing attacks in PHP

blog.ircmaxell.com

1–10 of 52 posts

Re: It's All About Time – Remote timing attacks in PHP

#2
I've looked into timing attacks in the past but failed to exploit one. Even running php locally from the command line, eliminating any possibility of network randomness, I couldn't get even a few bytes with any amount of certainty.

Not saying it's not an issue, but I'm not so sure it's a big deal either.

Re: It's All About Time – Remote timing attacks in PHP

#3
post #2

I've looked into timing attacks in the past but failed to exploit one. Even running php locally from the command line, eliminating any possibility of network randomness, I couldn't get even a few bytes with any amount of certainty. Not saying it's not an issue, but I'm not so sure it's a big deal either.

I wrote a tool a while ago for testing network based timing attacks. Getting the measurement right is really hard, just taking the average doesn't generally work while the 10th percentile measurement is much better. I did find PHP fairly hard to exploit though, but I was trying over a network which much more difficult than locally.

The code for the tool (and a presentation pdf) is here if you're interested: https://github.com/aj-code/TimingIntrusionTool5000

Re: It's All About Time – Remote timing attacks in PHP

#4
post #3
post #2

I've looked into timing attacks in the past but failed to exploit one. Even running php locally from the command line, eliminating any possibility of network randomness, I couldn't get even a few bytes with any amount of certainty. Not saying it's not an issue, but I'm not so sure it's a big deal either.

I wrote a tool a while ago for testing network based timing attacks. Getting the measurement right is really hard, just taking the average doesn't generally work while the 10th percentile measurement is much better. I did find PHP fairly hard to exploit though, but I was trying over a network which much more difficult than locally. The code for the tool (and a presentation pdf) is here if you're interested: https://g…

Even taking the straight minimum may be better.

Re: It's All About Time – Remote timing attacks in PHP

#5
> NOTE In general, it's not possible to prevent length leaks. So it's OK to leak the length.

I would imagine that you can prevent length leaks by looping through the characters of the known value and then returning that comparison with an additional check of length.

function timingSafeEquals($safe, $user) {

    $safeLen = strlen($safe);
    $userLen = strlen($user);

    $result = 0;
    for ($i = 0; $i 

Re: It's All About Time – Remote timing attacks in PHP

#6
Interesting article, I never took the time to really think about this.

For optimal security, OP mentions that we should fix the underlying code, but I kind of disagree. Understanding all the underlying code is a lot of work and, except for extremely secure application, is not really needed. Also, hindering performance for security is not always the way to go (he mentions returning only at the end).

If you have ultra-secure tasks to do, you might want to do something like calculating the execution time of the function and sleep()'ing to add padding. Example code (doesn't work):

function login(){

  execstart = utime()
  // whatever code
  execduration = utime() - execstart;
  sleep( execduration % 100 ); // pad on at 100 boundary
}

You'd have to carefully choose your padding so the execution time is (normally) not revealed in the code.

Re: It's All About Time – Remote timing attacks in PHP

#7
post #6

Interesting article, I never took the time to really think about this. For optimal security, OP mentions that we should fix the underlying code, but I kind of disagree. Understanding all the underlying code is a lot of work and, except for extremely secure application, is not really needed. Also, hindering performance for security is not always the way to go (he mentions returning only at the end). If you have ultra-…

I don't know how to do [code] tags

Re: It's All About Time – Remote timing attacks in PHP

#8
post #3

Earlier quoted context omitted.

I wrote a tool a while ago for testing network based timing attacks. Getting the measurement right is really hard, just taking the average doesn't generally work while the 10th percentile measurement is much better. I did find PHP fairly hard to exploit though, but I was trying over a network which much more difficult than locally. The code for the tool (and a presentation pdf) is here if you're interested: https://g…

Even taking the straight minimum may be better.

You'd think so! But that's not what I found, I found the minimum, max, and average were all crap. Even the median wasn't very good compared to the 10th percentile (which I got the idea from for here http://www.cs.rice.edu/~dwallach/pub/crosby-timing2009.pdf)

Re: It's All About Time – Remote timing attacks in PHP

#9
post #5

> NOTE In general, it's not possible to prevent length leaks. So it's OK to leak the length. I would imagine that you can prevent length leaks by looping through the characters of the known value and then returning that comparison with an additional check of length. function timingSafeEquals($safe, $user) { $safeLen = strlen($safe); $userLen = strlen($user); $result = 0; for ($i = 0; $i

The for loop duration here will vary depending on the length of the string

Re: It's All About Time – Remote timing attacks in PHP

#10
post #7
post #6

Interesting article, I never took the time to really think about this. For optimal security, OP mentions that we should fix the underlying code, but I kind of disagree. Understanding all the underlying code is a lot of work and, except for extremely secure application, is not really needed. Also, hindering performance for security is not always the way to go (he mentions returning only at the end). If you have ultra-…

I don't know how to do [code] tags

At this time, these few options are available:

https://news.ycombinator.com/formatdoc

>Text after a blank line that is indented by two or more spaces is reproduced verbatim. (This is intended for code.)

Post reply on HN