I was reading the Wiki entry for Replay attacks. It mentions that timestamps can be used as a countermeasure against such attacks:

Timestamping is another way of preventing a replay attack. Synchronization should be achieved using a secure protocol. For example, Bob periodically broadcasts the time on his clock together with a MAC. When Alice wants to send Bob a message, she includes her best estimate of the time on his clock in her message, which is also authenticated. Bob only accepts messages for which the timestamp is within a reasonable tolerance. The advantage of this scheme is that Bob does not need to generate (pseudo-) random numbers, with the trade-off being that replay attacks, if they are performed quickly enough i.e. within that 'reasonable' limit, could succeed.

I am not an expert in this, in fact, I am very new to these concepts but that sounds extremely unsafe.

  1. In reality, how easy is it to get within the reasonable limit?
  2. What are the most commonly used countermeasures against this type of attack? Tokens?
  1. This solely depends on the tolerance itself. Usually, a few microseconds of skew will be reasonable to tolerate as long as the time heartbeat is in reasonably short intervals.

  2. Nonces; a special kind of “token” - by the way, time stamps can be abstracted to being a token as well:)


I wrote a timestamp based anti replay mechanism into an api i wrote. The client would generate a timestamp, hash it and send to the server. When one of the servers stopped talking to the time server and drifted, the system started rejecting requests. This actually gives you an attack vector, if you can change the time, you can create a denial of service.

Your timestamp needs to allow sufficient time to get between machines that generate them and validate them. This sounds obvious but consider if your recieving application needs to wake up sometimes after sleeping due to lack of requests, that additional time could result in the request being dropped.

If implemented properly, it is effective, you need to ensure your timestamp cannot be modified in transit or the attacker can manipulate them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.