Diffie-Hellman public values must be authenticated. This toy transcript shows Eve replacing both public values and getting two different half-secrets.
highlighted = computed this step
Why unauthenticated DH is attackable
Plain DH only proves arithmetic agreement with whoever supplied the public value. If Eve can replace public values, Alice and Bob do not share with each other.
authentication is missing
Eve injects her public value
Eve chooses e=10 and sends E=9 in place of both public values.
E=510mod23=9
Alice shares with Eve
Alice computes E to her a power and lands on 3. Eve computes the same value from A.
96mod23=3
Bob shares with Eve
Bob computes E to his b power and lands on 6. Eve also computes that half-secret from B.
915mod23=6
The real shared secret never forms
Without Eve, Alice and Bob would have shared 2. In this transcript, Alice has 3 and Bob has 6 instead.
real shared=2but3=6
Summary
Unauthenticated DH lets Eve form two different shared values: 3 with Alice and 6 with Bob. NOTE: toy-modulus; no-side-channel; no-production; never-roll-your-own. Exact arithmetic on a deliberately tiny toy modulus; real DH uses 2048+ bit groups inside authenticated reviewed protocols.