Computer >> Hướng Dẫn Máy Tính >  >> Kết Nối Mạng >> An Ninh Mạng

ARP trong an ninh mạng: Cơ chế, rủi ro ARP Poisoning & phòng chống

Address Resolution Protocol (ARP) – Từ nguyên lý đến tấn công & bảo vệ

ARP (Address Resolution Protocol) là giao thức lớp 2 (Data Link) ánh xạ địa chỉ IP (Layer 3) sang địa chỉ MAC (Layer 2) trong mạng Ethernet/Wi-Fi. Thiết bị gửi broadcast "Who has 192.168.1.1? Tell 192.168.1.5" – thiết bị sở hữu IP trả lời unicast "192.168.1.1 is at aa:bb:cc:dd:ee:ff". Kết quả lưu trong ARP cache (bảng ARP).

1. Tại sao ARP không an toàn?

  • Stateless: Không xác thực gói ARP reply – chấp nhận mọi reply (daemon gratuitous ARP).
  • No encryption/integrity: Dễ spoof, replay.
  • Cache poisoning: Cập nhật entry sai → traffic bị chuyển hướng.

2. ARP Spoofing / ARP Poisoning (MITM trong LAN)

  1. Kẻ tấn công gửi ARP Reply giả liên tục đến:
    • Victim: "Gateway IP (192.168.1.1) is at MAC_Attacker"
    • Gateway: "Victim IP (192.168.1.5) is at MAC_Attacker"
  2. Cả hai cập nhật ARP cache sai → traffic victim ↔ gateway đi qua máy attacker.
  3. Attacker có thể: sniff (Wireshark), modify (inject script, downgrade HTTPS), drop (DoS), replay.

3. Công cụ tấn công phổ biến

  • ettercap (CLI/GUI), bettercap (modular, Go), arpspoof (dsniff suite), Cain & Abel (Windows), MITMf (framework).

4. Hậu quả

  • Đánh cắp credential (HTTP, FTP, Telnet, POP3, IMAP không mã hóa).
  • Session hijacking (cookie theft).
  • SSL Stripping (hạ cấp HTTPS → HTTP) – kết hợp HSTS bypass.
  • Malware injection vào file download, cập nhật phần mềm.
  • DoS: drop tất cả gói tin victim ↔ gateway.

5. Phòng chống & Phát hiện

LớpBiện phápCông cụ/Tính năng
Mạng (Switch)Dynamic ARP Inspection (DAI)Cisco: ip arp inspection vlan 10 – validate ARP packets qua DHCP Snooping binding database.
DHCP SnoopingXây dựng binding table (IP-MAC-VLAN-Port) – cơ sở cho DAI.
IP Source Guard / Port SecurityChỉ cho traffic từ IP/MAC đã học (DHCP snooping) hoặc static binding.
Host/EndpointStatic ARP entries (cho gateway quan trọng)arp -s 192.168.1.1 aa-bb-cc-dd-ee-ff (Windows/Linux) – bất tiện quản trị.
ARP monitoring toolsarpwatch, XArp, Wireshark (detect duplicate IP/MAC), OSSEC/Wazuh rule ARP spoof.
Kernel hardeningLinux: net.ipv4.conf.all.arp_ignore=1, arp_announce=2, net.ipv4.conf.all.accept_gratuitous_arp=0.
Mã hóaHTTPS/TLS (HSTS, Certificate Pinning)Ngăn sniffing credential, session cookie ngay cả khi MITM thành công.
VPN / Zero Trust Network AccessMã hóa end-to-end, bypass ARP layer cho traffic nhạy cảm.

6. IPv6 – Neighbor Discovery Protocol (NDP)

IPv6 thay ARP bằng NDP (ICMPv6). Tương tự có NDP Spoofing. Phòng chống: RA Guard, DHCPv6 Guard, Secure Neighbor Discovery (SEND).

7. Tóm tắt quy trình ứng phó sự cố ARP Poisoning

  1. Phát hiện: Alert từ DAI, arpwatch, SIEM rule (duplicate MAC, gratuitous ARP flood).
  2. Xác định port switch của attacker (từ binding table / MAC address table).
  3. Cô lập port (shutdown / quarantine VLAN).
  4. Clear ARP cache trên victim & gateway: arp -d * (Win), ip neigh flush all (Linux).
  5. Điều tra máy attacker: malware, user nội bộ, thiết bị IoT bị compromize.
  6. Báo cáo, cập nhật rule DAI/DAI logging, đào tạo nhân viên.