So imagine the next situation:
Alice wants to initiate OTR instant messaging session with Bob but Joe is Man In The Middle.
Alice negotiates a shared secret 'X' with Joe (thinking he is Bob) using Diffie-Hellman.
Joe negotiates another shared secret 'Y' with Bob (who thinks Joe is Alice) using Diffie-Hellman.
Now Alice and Bob both know that they have established the so called "unverified OTR session", meaning that they are encrypted but none of them have verified their identities (none of them know about the existence of Joe).
So from what I understand, the Socialist Millionaire Protocol is supposed to be the solution of this problem. Alice has to match her shared secret 'X' with Bob's 'Y' and if they don't match - they will know that they have someone (Joe) in the middle, haven't they?
Anyway… Obviously X != Y because Joe is in the middle.
Now, I think I understand the steps in the Socialist Millionaire Protocol but still… I can't see what is stopping Joe from pretending in front of Alice that he is indeed Bob and use SMP to match with her their shared secret 'X' (which they both know)?
Am I missing something? What is the thing that makes OTR with SMP protected from MitM?