by klodolph · 14y ago · 0 comments
What kind of timing attack is that? In order for there to be a timing attack, there has to be a difference in the timings.
1. You can either process the data, check the authentication code, then commit.
2. Or you can check the authentication code, process the data, then commit.
I don't see any attacks on #2 that couldn't also work on #1.
The only good thing that "authenticating last" does is that it prevents the attacker from issuing lots of requests sequentially, thus brute-forcing your authentication, but this should be solved in another way, without slowing down legitimate users and overloading your servers.
We're talking about such small amounts of time compared to the overhead of the full web stack.
Success: check authentication, process data, commit, return 2xx status.
Failure: check authentication, return 4xx status.
The reason that you don't get any information from the difference in timing between the two branches is because you already get that information from the status code.
Now on the other hand, if you use naive string comparison, different failure branches will take different amounts of time. That is a security hole, and it's not what we're talking about here.