munotes®

Authentication Protocols: Mutual Authentication and the Replay Problem

Get access to whole semester resourcesSemester Pass

Chapter Fifty-Seven

Syllabus topic Module 2, "Digital Signatures and Authentication: Authentication Protocols"

Pages 345 to 351 of 678

In one line

Two parties must each become convinced that the other is present now, not recorded earlier. Every authentication protocol in this book is a different answer to that, and every failure in one is a failure of freshness.

In the wording a student can write in an examination: an authentication protocol enables communicating parties to satisfy themselves mutually about each other's identity and to exchange session keys. Mutual authentication requires each party to be convinced of the other's identity; one-way authentication requires only the receiver to be convinced of the sender's. The central problem is replay, in which an opponent copies a message and resends it later; the countermeasures are sequence numbers, timestamps and challenge and response with a nonce.

The replay problem, and its forms

A question asking about replay wants the forms named, and there are four.

Simple replay. The opponent copies a message and replays it later.

Repetition that can be logged. A replay within a valid time window, which a receiver keeping records could detect but a stateless one cannot.

Repetition that cannot be detected. The original message was suppressed and did not arrive, so only the replay reaches the receiver, who has nothing to compare it with.

Backward replay without modification. The message is replayed back to the sender. This works whenever the two directions of a conversation are encrypted with the same key and the messages are not distinguishable by direction, and it is the attack that makes a protocol designer include the sender's identity inside every encrypted message.

The three countermeasures, and what each costs

Sequence numbers. Each party keeps the last number seen and rejects anything out of order. Cost: every party must remember the state of every conversation with every other party. For that reason sequence numbers are not generally used for authentication, although they are used inside a session once one has been established.

Timestamps. A message is accepted only if it carries a timestamp close enough to the receiver's clock. Cost: the clocks must be synchronised, and the synchronisation itself becomes a security-critical service. And a subtlety: the window must be wide enough for network delay and narrow enough to be useful, and an attacker who can delay a message can push it outside the window and cause a denial of service, or exploit the window to replay inside it.

Challenge and response. The receiver sends a fresh nonce, a number used once, and the sender must return a function of it. Cost: it needs a round trip before the real message, so it cannot be used for a store-and-forward application such as electronic mail. That limitation is the subject of the next chapter.

munotes.in345

Authentication Protocols: Mutual Authentication and the Replay Problem

The rule that follows and is worth carrying: a connection-oriented protocol can use challenge and response; a connectionless or store-and-forward one must use timestamps, because there is nobody on the other end to challenge.

Needham and Schroeder, and Denning's attack

# The Needham and Schroeder authentication protocol, and Denning's replay.

import hashlib

class Party:
    def __init__(self, name, master):
        self.name = name
        self.master = master

def enc(key, data):
    """Stand-in for a real cipher: a keyed transformation that is reversible."""
    stream = hashlib.sha256(key).digest() * ((len(data) // 32) + 1)
    return bytes(a ^ b for a, b in zip(data, stream))

dec = enc                       # exclusive-or is its own inverse

KA, KB = b"Asha's master key ..............", b"Bharat's master key ..........."
print("THE PROTOCOL AS NEEDHAM AND SCHROEDER SET IT OUT")
print()

# Message 1: Asha -> KDC
n1 = 12345
print("1. Asha to the centre, in clear:")
print("     Asha, Bharat, nonce N1 = %d" % n1)

# Message 2: KDC -> Asha, encrypted under KA
session = b"session key 2026-09-30 aaaaaaaa"
ticket = enc(KB, session + b"|Asha")
reply = enc(KA, session + b"|N1=" + str(n1).encode() + b"|Bharat|TICKET")
print()
print("2. The centre to Asha, ALL encrypted under Asha's master key:")
print("     the session key Ks, the nonce N1 back, Bharat's name, and a")
print("     TICKET for Bharat which is Ks and Asha's name encrypted under")
print("     Bharat's master key, and which Asha cannot read.")
print("     Asha decrypts and finds N1 =", dec(KA, reply).split(b"|N1=")[1].split(b"|")[0].decode())
print("     so the reply is fresh and was not substituted.")

print()
print("3. Asha to Bharat: the ticket, unchanged.")
opened = dec(KB, ticket)
print("     Bharat decrypts it with his own master key and finds")
print("       the session key, and the name", opened.split(b"|")[1].decode())

n2 = 98765
print()
print("4. Bharat to Asha, encrypted under the SESSION key: nonce N2 =", n2)
print("5. Asha to Bharat, encrypted under the session key: f(N2) =", n2 - 1)
print()
print("   Messages 4 and 5 prove Asha is PRESENT and holds Ks. Without them a")
print("   replay of message 3 alone would be accepted.")
print()

print("DENNING'S ATTACK, and why messages 4 and 5 are not enough.")
print()
print("   Suppose an attacker recorded an old run and has since recovered that")
print("   run's session key, by any means: it was short, or it leaked, or the")
print("   cipher of the day was broken. The attacker now:")
print("     replays the OLD message 3, the old ticket, to Bharat;")
print("     receives message 4, a fresh nonce, encrypted under the OLD key;")
print("     they HOLD that key, so they answer message 5 correctly.")
old_session = b"session key 2020-01-01 bbbbbbbb"
old_ticket = enc(KB, old_session + b"|Asha")
attacker_n2 = 55555
challenge = enc(old_session, str(attacker_n2).encode())
answer = enc(old_session, str(attacker_n2 - 1).encode())
print()
print("   the attacker's answer to Bharat's challenge %d is %s"
      % (attacker_n2, dec(old_session, answer).decode()))
print("   which is exactly what Bharat expects:", dec(old_session, answer).decode()
      == str(attacker_n2 - 1))
print()
print("   Bharat now believes he is talking to Asha, using a key the attacker")
print("   holds. NOTHING in messages 3, 4 and 5 carries a time, so Bharat has")
print("   no way to know the ticket is years old.")
print()
print("THE FIX, from Denning: put a TIMESTAMP in the ticket and in message 2,")
print("and have each party reject anything outside a window. Then an old ticket")
print("is recognisable as old. The cost is that every clock must be synchronised,")
print("and a party whose clock is wrong is either locked out or exposed, which")
print("is the trade Kerberos makes and which its own chapters take up.")
munotes.in346

Authentication Protocols: Mutual Authentication and the Replay Problem

THE PROTOCOL AS NEEDHAM AND SCHROEDER SET IT OUT

1. Asha to the centre, in clear:
     Asha, Bharat, nonce N1 = 12345

2. The centre to Asha, ALL encrypted under Asha's master key:
     the session key Ks, the nonce N1 back, Bharat's name, and a
     TICKET for Bharat which is Ks and Asha's name encrypted under
     Bharat's master key, and which Asha cannot read.
     Asha decrypts and finds N1 = 12345
     so the reply is fresh and was not substituted.

3. Asha to Bharat: the ticket, unchanged.
     Bharat decrypts it with his own master key and finds
       the session key, and the name Asha

4. Bharat to Asha, encrypted under the SESSION key: nonce N2 = 98765
5. Asha to Bharat, encrypted under the session key: f(N2) = 98764

   Messages 4 and 5 prove Asha is PRESENT and holds Ks. Without them a
   replay of message 3 alone would be accepted.

DENNING'S ATTACK, and why messages 4 and 5 are not enough.

   Suppose an attacker recorded an old run and has since recovered that
   run's session key, by any means: it was short, or it leaked, or the
   cipher of the day was broken. The attacker now:
     replays the OLD message 3, the old ticket, to Bharat;
     receives message 4, a fresh nonce, encrypted under the OLD key;
     they HOLD that key, so they answer message 5 correctly.

   the attacker's answer to Bharat's challenge 55555 is 55554
   which is exactly what Bharat expects: True

   Bharat now believes he is talking to Asha, using a key the attacker
   holds. NOTHING in messages 3, 4 and 5 carries a time, so Bharat has
   no way to know the ticket is years old.

THE FIX, from Denning: put a TIMESTAMP in the ticket and in message 2,
and have each party reject anything outside a window. Then an old ticket
is recognisable as old. The cost is that every clock must be synchronised,
and a party whose clock is wrong is either locked out or exposed, which
is the trade Kerberos makes and which its own chapters take up.
munotes.in347

Authentication Protocols: Mutual Authentication and the Replay Problem

Read five things out of that run.

Message 2 is the interesting one. It contains the session key, the nonce back, so Asha knows the reply is fresh; the original request, so she knows it was not altered in flight; and the ticket, which is the same session key and Asha's name encrypted under Bharat's master key. Asha cannot read the ticket and cannot alter it, which is exactly the property wanted.

Messages 4 and 5 exist to prove liveness. Bharat sends a fresh nonce under the session key and Asha returns a function of it, conventionally one less. An attacker replaying message 3 alone could not answer.

But an attacker who holds the old session key can. The run does it: the old ticket is replayed, Bharat's fresh challenge arrives encrypted under the old key, and the attacker, holding that key, returns the expected value. The program prints it and checks it. Bharat is now talking to an attacker and believes it is Asha.

Nothing in messages 3, 4 and 5 carries a time. Bharat has no way to know the ticket is years old. The protocol has a freshness check and is still replayable, because the freshness check proves only that somebody holding the key is present now, and the attacker is.

The fix is a timestamp, in the ticket and in message 2, with each party rejecting anything outside a window. That is Denning's proposal and it is what Kerberos adopts, at the price of synchronised clocks.

What the attacker needed, and what they did not

Worth stating because students overestimate the attack.

They needed a recording of an old run, and the old session key. The key might have been recovered because it was short, because the cipher of that era was later broken, because it was stored somewhere, or simply because the session ended and nobody thought a spent key mattered.

They did not need Asha's or Bharat's master key, any cryptanalysis of the current cipher, or any access to the key distribution centre.

That is the shape of most real protocol attacks: not breaking the cryptography, but using a piece of it after it was assumed to be worthless. A session key that is "finished" is still a live secret as long as any protocol will accept a message encrypted under it.

Distinctions that carry marks

Sequence numbersTimestampsChallenge and response
Needsstate per pair of partiessynchronised clocksa round trip
Suitstraffic inside an established sessionconnectionless and store-and-forwardconnection-oriented
Works for electronic mailnoyesno
Fails whenstate is losta clock drifts, or a message is delayedthere is nobody to challenge
Used inTCP sequence numbers, IPsec anti-replayKerberosTLS handshake, IKE
munotes.in348

Authentication Protocols: Mutual Authentication and the Replay Problem

Mutual authenticationOne-way authentication
Convincedboth partiesthe receiver only
Needs the other party presentyesno
Typical settinga connectionelectronic mail
Freshness bychallenge and responsetimestamp
The replayWhat it is
Simple replaya copied message resent later
Logged repetitiona replay inside the valid window
Undetectable repetitionthe original was suppressed, so only the replay arrives
Backward replaythe message is sent back to its own sender

What beginners get wrong here

Saying a nonce stops replay. It stops the replay of a message that does not contain the nonce. It does not stop an attacker who can answer the challenge, which is exactly what Denning's attack does.

Thinking the attack breaks the cipher. It breaks nothing. It uses an old session key that the protocol is still willing to accept.

Forgetting why messages 4 and 5 are there. They prove the requester is live. An answer that lists five messages without saying what the last two are for has described the protocol without explaining it.

Saying timestamps solve replay. They solve it at the cost of synchronised clocks, and the clock service then becomes security critical. That trade is Kerberos's, and it is worth naming as a trade.

Using sequence numbers for authentication. They require each party to remember state for every other party, which does not scale, which is why they are used within a session and not to establish one.

Quick revision

  • Mutual authentication convinces both parties; one-way convinces the receiver only.
  • The central problem is replay. Four forms: simple, logged repetition, undetectable repetition when the original was suppressed, and backward replay to the sender.
  • Three countermeasures: sequence numbers (state per pair, so not used to establish a session), timestamps (need synchronised clocks), challenge and response with a nonce (needs a round trip, so no good for electronic mail).
  • Needham and Schroeder, five messages: request with a nonce; the centre's reply under the requester's master key carrying the session key, the nonce, the request and a ticket; the ticket forwarded; a nonce challenge under the session key; and the response.
  • Messages 4 and 5 exist to prove the requester is live.
  • Denning's attack: an attacker with an old recording and the old session key replays the ticket, receives the challenge under that key, and answers it. Nothing in the protocol carries a time, so the receiver cannot tell.
  • The attacker needs no master key and no cryptanalysis; only an expired session key the protocol will still accept.
  • The fix is a timestamp in the ticket, which is what Kerberos does.
munotes.in349

Authentication Protocols: Mutual Authentication and the Replay Problem

Test yourself

1. What is the central problem an authentication protocol must solve? Replay: an opponent copying a valid message and resending it later, so that the receiver is convinced of the presence of a party who is not actually there. Every countermeasure in the topic is a way of establishing that a message is fresh.

2. Name the four forms of replay. Simple replay, in which a copied message is resent later; repetition that can be logged, a replay within the valid time window; repetition that cannot be detected, where the original message was suppressed so only the replay arrives; and backward replay without modification, in which the message is replayed back to its own sender.

3. Give the three countermeasures and the cost of each. Sequence numbers, which require each party to keep state for every other party and so are not used to establish a session. Timestamps, which require the parties' clocks to be synchronised, making the clock service security critical. Challenge and response with a nonce, which requires a round trip and therefore cannot be used for store-and-forward applications such as electronic mail.

4. Describe the five messages of the Needham and Schroeder protocol and say what messages 4 and 5 achieve. The requester asks the centre for a key to talk to a named party, including a nonce. The centre replies, under the requester's master key, with the session key, the nonce, the original request and a ticket containing the session key and the requester's name encrypted under the other party's master key. The requester forwards the ticket. The other party sends a nonce encrypted under the session key. The requester returns a function of that nonce. Messages 4 and 5 prove that the requester is present now and holds the session key, rather than being a replay of message 3 alone.

5. Describe Denning's attack and say why messages 4 and 5 do not prevent it. An attacker who has recorded an old run and has since obtained that run's session key replays the old ticket. The receiving party, having no way to tell the ticket's age, accepts it and issues a fresh nonce encrypted under that old session key. Because the attacker holds the key, they decrypt the nonce and return the correct response. Messages 4 and 5 prove only that somebody holding the key is present, and the attacker is; they say nothing about the key being current.

6. What did the attacker need, and what did they not need? They needed a recording of an old exchange and the session key from it, which might have been recovered because it was short, because the cipher was later broken, or because it was stored and forgotten. They needed no master key, no access to the key distribution centre and no cryptanalysis of the cipher in current use.

munotes.in350

Authentication Protocols: Mutual Authentication and the Replay Problem

7. What is the fix, and what does it cost? Include a timestamp in the ticket and in the centre's reply, and have each party reject anything outside an acceptable window, so that an old ticket is recognisable as old. The cost is that every party's clock must be synchronised and kept so, which makes the time service itself security critical; a party whose clock is wrong is either locked out or exposed. Kerberos makes exactly this trade.

munotes.in351

The rest of this subject

These notes are cut from the University's printed syllabus. Open the syllabus itself for the same subject.

Issue
Done!