What's the utility of the last two messages of Needham Schroeder Symmetric key protocol The protocol works like this 


But I can't understand what's the utility of message 4 and 5, what do they protect from?
They do not protect from replay attack if Ks gets compromised because B won't be aware anyway of its freshness.
Wikipedia says that Bob sends Alice a nonce to show that he has the key, and Alice sends back a modification of it to show that she has the key too.
Isn't it obvious that she has the key if she sent it to Bob previously?
Or is it just a sort of acknowledge (which kind of surprise me because it would be the first time I see it in these protocols)
Messages 4 and 5 are meant to protect the recipient B from a replay attack. It is a basic challenge response mechanism. Otherwise an attacker could just replay previous messages and have the very same interaction with B again. That is bad, if e.g. the message is just "increase some counter", or another message that has a lasting effect or changes a state.

This doesn't protect from a compromised Alice or if the trusted party is compromised. It only protects from an attacker controlling the network.

More explicitly: Eve has a copy of a past interaction between Alice and Bob. She has message 3, but it is encrypted and she can't extract the content. But she is able to send that same message to Bob. If Bob doesn't have a full record of every interaction in the past (and checks against all those records), he thinks it's a new one. If Eve just replays every message originally sent by Alice, Bob would have no way to detect it isn't really Alice sending those messages. Of course the interaction could be adaptive, and Bob then notices a difference, but the protocol should also work with non-adaptive messages.