Challenges › Cryptography

Read the Vault's Timing

medium · 100 XP · machine with a lab · free · solves: 0

AegisGuard lost the six-digit PIN of its Model-7 vault. The vault firmware checks a PIN one digit at a time from the left and stops at the first wrong digit. Each correct leading digit adds the same fixed delay before the reply. Every reply also has random noise of 0 to 50 ms, and the network adds a little more.

Start the lab. The vault runs on host vault, TCP port 9000.

Protocol. The vault sends two banner lines when you connect. Send one command per line:

client.py opens one connection and gives you Vault.try_pin(pin), which returns the reply and the response time in seconds. Run it alone to time one PIN: python3 client.py --repeat 5 123456.

Your task.

  1. For the first position, try each digit 0 to 9 and fill the other positions with any digits.
  2. Send each guess at least 5 times and take the median time. One sample is not enough, because the noise is larger than the step. If two digits are close, measure them again with more samples.
  3. Keep the digit with the clearly highest median, then move to the next position.
  4. If no digit stands out at a position, an earlier digit is probably wrong. Measure the earlier position again.
  5. When all six digits are known, send the PIN. The vault opens and shows the flag.

Then explain for yourself how a constant-time comparison, such as Python's hmac.compare_digest, removes this signal.

Tags: learn

Try next