SECURITY ENGINEERING · PART 2 · NETWORKING FOR SECURITY · ATTACKS · 23 OF 229

ARP Spoofing and Man-in-the-Middle Attacks

How an attacker on the same local network gets between you and the router: what ARP does and why it trusts every answer, how forged ARP replies redirect traffic through the attacker, what a man in the middle can read or change, how to spot it in the ARP table and in captures, and the defenses that matter (TLS, switch protections, segmentation).

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 12

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • ARP trusts every reply
  • forged replies redirect traffic
  • TLS makes the middle useless
  • switches can block it

Notes

What ARP does

On a local network, machines deliver packets using hardware addresses called MAC addresses. To send something to the router, your laptop first needs the router's MAC address, so it broadcasts a question: who has this IP address? The router replies, and the laptop stores the answer in its ARP table. The problem is in the design. ARP was built in a trusting era and has no authentication. A machine believes whatever reply it hears.

Address Resolution Protocol
  • to send to 10.0.0.1 the laptop needs its hardware (MAC) address
  • it shouts: "who has 10.0.0.1?"
  • the router replies with its MAC
  • the laptop caches the answer in its ARP table
  • ARP has no authentication

The lie

So the attacker sends forged ARP replies, unprompted and repeatedly. To the victim: the router's address is at my MAC. To the router: the victim's address is at my MAC. Both obediently update their tables. There is no password to crack and no bug to exploit. The protocol simply allows it, which is why this attack is decades old and still works on networks that have not turned on the switch protections you will see shortly.

ARP spoofing (poisoning)
  • the attacker sends forged ARP replies, over and over: to the victim: "10.0.0.1 is at MY MAC"
  • to the router: "10.0.0.5 is at MY MAC"
  • both update their tables
  • no password, no exploit: the protocol allows it

In the middle

Now every packet between the victim and the internet passes through the attacker's machine. The attacker forwards them on, so nothing breaks and the victim notices nothing. From the middle they can read anything unencrypted, change content in transit, try to downgrade connections with SSL stripping, and answer DNS questions with false addresses. That position is called man in the middle, and ARP spoofing is the cheapest way to get it.

Man in the middle
  • the attacker forwards every packet, so nothing breaks
  • the victim notices nothing
  • now the attacker can: read plain-text traffic change it in transit try SSL stripping answer DNS with lies

What TLS changes

Here is the good news. If the connection uses TLS and the certificate is checked, being in the middle wins almost nothing. The content is unreadable. Tampering breaks the connection. Presenting a fake certificate triggers a loud browser warning. And with HSTS there is no plain HTTP request to strip. The attack still succeeds at the network level; it just has nothing to read. This is why the user habit that matters most is never clicking through a certificate warning.

With TLS, properly checked
  • content: unreadable
  • tampering: detected, the connection fails
  • a fake certificate: the browser shows a loud warning
  • HSTS: no plain HTTP to strip
  • the attack still works; it just wins almost nothing

Spot it

How do you spot it? Look at the ARP table. If the router's address and some other machine's address map to the same MAC, something is impersonating the gateway. In a packet capture you will see a steady stream of ARP replies that nobody asked for, and Wireshark flags duplicate addresses on its own. Tools like arpwatch do this continuously and alert when the MAC address for an important IP suddenly changes.

Signs of ARP spoofing
$ ip neigh        (or: arp -a)
10.0.0.1  lladdr aa:bb:cc:..66
10.0.0.66 lladdr aa:bb:cc:..66
# two IPs, one MAC: suspicious

in Wireshark:
  arp.duplicate-address-detected
  a flood of unasked ARP replies

Stop it at the switch

The real fix lives in the network equipment. Managed switches offer dynamic ARP inspection: the switch knows which address was leased to which port, through DHCP snooping, and drops any ARP reply that does not match. Port security limits how many MAC addresses a port may use. Guest Wi-Fi should enable client isolation, so guests cannot talk to each other at all. And smaller network segments mean fewer machines an attacker can reach.

Network defenses
  • Dynamic ARP Inspection: the switch drops ARP replies that do not match known leases
  • DHCP snooping: builds that trusted table
  • port security: limit MACs per port
  • client isolation on guest Wi-Fi
  • segmentation: smaller LANs

Protect yourself

You cannot fix the cafe's switch, so on a network you do not control, assume someone is in the middle. Use HTTPS everywhere and never accept a certificate warning. Use a VPN or zero-trust client so all traffic is wrapped before it touches the local network. Use encrypted DNS. And turn off file sharing and discovery services in public. This is the practical meaning of zero trust: the network gets no trust at all.

On untrusted networks
  • assume the network is hostile
  • HTTPS everywhere; never accept a certificate warning
  • a VPN or zero-trust client wraps all traffic
  • encrypted DNS
  • keep sharing and discovery services off in public

Other ways in

ARP spoofing is the classic, but the middle has other doors. An evil twin access point. A rogue DHCP server that hands out the attacker as the gateway. DNS spoofing, which is the next episode. Forged IPv6 router advertisements, on networks that forgot IPv6 is enabled. Or simply a compromised router. You do not need a separate defense for each. End-to-end encryption with verified certificates defeats them all at once.

More MITM techniques
  • evil twin Wi-Fi access point
  • rogue DHCP server: hands out the attacker as gateway
  • DNS spoofing (next episode)
  • IPv6 router advertisements on networks that ignore IPv6
  • a compromised router or proxy
  • the defense is the same: TLS

Common mistakes

Mistakes. A flat network where every laptop, printer and server shares one segment. Dynamic ARP inspection and DHCP snooping available on the switches and never enabled. Guest Wi-Fi without client isolation. Internal applications on plain HTTP, which turns a man in the middle from a nuisance into a breach. Users trained by broken internal certificates to click past warnings. And IPv6 enabled everywhere while nobody monitors it.

Avoid these
  • flat networks, everyone on one LAN
  • switch protections left off
  • guest Wi-Fi without isolation
  • internal apps on plain HTTP
  • users trained to click past certificate warnings
  • IPv6 enabled and ignored

Say it like this

In the interview: ARP has no authentication, so an attacker on the same local network can send forged replies that map the gateway's IP address to their own MAC, and become a man in the middle. I prevent it at the switch with dynamic ARP inspection and DHCP snooping, reduce exposure with segmentation and client isolation, detect it by watching for MAC changes on key addresses, and rely on TLS everywhere so interception gains nothing.

In the interview
  • "ARP has no authentication, so an attacker on the LAN sends
  • forged replies claiming the gateway's IP and becomes a man
  • in the middle. I prevent it
  • with dynamic ARP inspection and DHCP snooping, segmentation, and TLS so interception
  • gains nothing."

Interview questions

Q1What is ARP and why is it vulnerable?

The Address Resolution Protocol maps an IP address to a MAC (hardware) address on a local network. It has no authentication, so hosts accept any ARP reply, even unsolicited ones, which lets an attacker claim to own another machine’s IP address.

Q2How does ARP spoofing work?

An attacker on the same LAN repeatedly sends forged ARP replies telling the victim that the gateway’s IP is at the attacker’s MAC, and telling the gateway the same about the victim. Both update their ARP tables, so traffic flows through the attacker.

Q3What can a man in the middle do?

Read any unencrypted traffic, modify content in transit, attempt downgrade attacks such as SSL stripping, and spoof DNS answers. With properly validated TLS they can only see metadata and cause connection failures.

Q4How do you detect ARP spoofing?

Check the ARP table for the gateway IP mapping to an unexpected MAC, or two IPs sharing one MAC; look for floods of unsolicited ARP replies or duplicate-address warnings in a capture; and run tools such as arpwatch that alert on MAC changes.

Q5What is Dynamic ARP Inspection?

A managed-switch feature that validates ARP packets against a trusted table of IP-to-MAC-to-port bindings, built by DHCP snooping, and drops replies that do not match. It stops ARP spoofing at the network layer.

Q6Does HTTPS stop man-in-the-middle attacks?

It does not stop the interception itself, but with certificate validation the attacker cannot read or alter the content without triggering a warning or breaking the connection. HSTS also removes the plain HTTP request that SSL stripping relies on.

Q7How should you protect yourself on public Wi-Fi?

Treat the network as hostile: use HTTPS only and never accept certificate warnings, use a VPN or zero-trust client, use encrypted DNS, and disable file sharing and device discovery.

Q8Why does network segmentation help against MITM?

ARP spoofing only works within one broadcast domain. Smaller segments and client isolation reduce which machines an attacker can reach and impersonate, limiting the blast radius of a single compromised or malicious device.