ภาพรวม TCP/IP Protocol Suite และความปลอดภัย
TCP/IP เป็นชุดโปรโตคอลหลักของอินเทอร์เน็ต ทำงานแบบ Stack (Layers) การเข้าใจโปรโตคอลหลัก 4 ตัวนี้ TCP, UDP, IP, ICMP เป็นพื้นฐานสำคัญของ Network Security เพราะ:
- เป็นภาษาที่อุปกรณ์ทุกตัวใช้สื่อสารกัน
- โจมตีส่วนใหญ่ exploite 行為ของโปรโตคอลเหล่านี้
- การป้องกัน ตรวจจับ ตอบสนอง ต้องเข้าใจพฤติกรรมปกติ/ผิดปกติของแต่ละโปรโตคอล
บทบาทและความสำคัญด้านความปลอดภัยของแต่ละโปรโตคอล
1. IP (Internet Protocol) - Layer 3 (Network Layer)
หน้าที่: Addressing (IPv4/IPv6) และ Routing ส่งแพ็กเก็ตจาก Source ไป Destination
ความสำคัญด้าน Security:
- IP Spoofing: ปลอม Source IP เพื่อหลบเลี่ยงการติดตาม หรือ DDoS Reflection/Amplification
- Ingress/Egress Filtering (BCP 38/84): บล็อกแพ็กเก็ตที่มี Source IP ไม่ถูกต้อง (Private IP บน Internet, Spoofed)
- IP Fragmentation Attacks: Teardrop, Ping of Death - แยก/ประกอบแพ็กเก็ตผิดปกติ
- IPv6 Security: Extension Headers, RA Guard, ND Inspection, SLAAC vs DHCPv6
- Anycast/Multicast/Broadcast: Amplification Vectors (DNS, NTP, Memcached)
2. ICMP (Internet Control Message Protocol) - Layer 3 (Control Plane)
หน้าที่: Error Reporting (Destination Unreachable, Time Exceeded, Parameter Problem) และ Operational Messages (Echo Request/Reply = Ping, Router Advertisement/Solicitation)
ความสำคัญด้าน Security:
- Reconnaissance: Ping Sweep, Traceroute (ICMP Time Exceeded) - แมปเครือข่าย
- DoS/DDoS: ICMP Flood (Ping Flood), Smurf Attack (Broadcast Ping + Spoof)
- Covert Channels: ICMP Tunneling (ส่งข้อมูลลับใน Payload) - ใช้ Data Exfiltration/C2
- Path MTU Discovery (PMTUD): ต้องการ ICMP "Packet Too Big" (Type 3 Code 4) - บล็อก ICMP ทั้งหมด = PMTUD Broken = Performance Issues
- Redirect Attacks: ICMP Redirect (Type 5) เปลี่ยน Routing ของ Victim
Best Practice:
- ไม่บล็อก ICMP ทั้งหมด - อนุญาต: Type 3 Code 4 (Fragmentation Needed), Type 0 (Echo Reply - ถ้าอนุญาต Ping), Type 11 (Time Exceeded - Traceroute)
- Rate-limit ICMP (เช่น 10-50 packets/sec)
- บล็อก: Redirect (Type 5), Router Advertisement (บน Host), Timestamp/Address Mask Requests
3. TCP (Transmission Control Protocol) - Layer 4 (Transport Layer)
หน้าที่: Reliable, Connection-oriented, Byte-stream, Flow Control, Congestion Control (3-way Handshake: SYN, SYN-ACK, ACK)
ความสำคัญด้าน Security:
- TCP Handshake Attacks: SYN Flood (DoS), SYN Cookies (Mitigation)
- Connection Hijacking: Sequence Number Prediction (เก่า), TCP Reset Attack (RST Packet), TCP Session Hijacking
- Port Scanning: SYN Scan (Half-open), Connect Scan, FIN/NULL/Xmas Scan - Reconnaissance
- TCP Options Abuse: MSS, Window Scale, SACK, Timestamps (Information Leakage: Uptime, OS Fingerprinting)
- Data Exfiltration over TCP: Tunneling (HTTP/HTTPS, DNS over TCP, Custom Ports)
- No Encryption/Authentication: TCP เองไม่มี - ต้องใช้ TLS/SSL/IPsec/MACsec
4. UDP (User Datagram Protocol) - Layer 4 (Transport Layer)
หน้าที่: Connectionless, Unreliable, Low Latency, No Handshake - ใช้สำหรับ DNS, DHCP, NTP, SNMP, VoIP, Video Streaming, Gaming, QUIC (HTTP/3)
ความสำคัญด้าน Security:
- Amplification/Reflection DDoS: UDP = No Handshake = ง่ายมากที่จะ Spoof Source IP
- DNS Amplification (50-100x)
- NTP Amplification (500x+)
- Memcached Amplification (50,000x+)
- SSDP, CLDAP, CharGEN, QOTD
- UDP Port Scanning: ช้ากว่า TCP (ไม่มี Response รับประกัน) แต่ใช้หา Service ที่เปิดอยู่
- UDP-based Tunneling/C2: DNS Tunneling (Port 53), QUIC (443/UDP), Custom UDP Protocols
- Stateless Nature: Firewall/IDS ต้อง Track State เอง (Session Table) - Resource Intensive
ความสัมพันธ์และการโต้ตอบระหว่างโปรโตคอล
| สถานการณ์ | โปรโตคอลที่เกี่ยวข้อง | Security Implication |
|---|---|---|
| Traceroute | ICMP Time Exceeded / UDP High Ports / TCP SYN | Network Mapping |
| DNS Query | UDP 53 (ปกติ) / TCP 53 (Large Response/Zone Transfer) | Amplification, Tunneling, Hijacking |
| Web Browsing (HTTPS) | TCP 443 + TLS 1.2/1.3 | Encrypted, ต้อง SSL Inspect เพื่อดูเนื้อหา |
| Ping | ICMP Echo Request/Reply | Recon, DoS, PMTUD |
| DHCP | UDP 67/68 | Rogue DHCP, Starvation, VLAN Hopping |
| BGP Routing | TCP 179 | BGP Hijacking, Route Leaks - ต้อง RPKI |
การประยุกต์ใช้ในเครื่องมือความปลอดภัย
- Firewall/ACL: Filter โดย IP (Src/Dst), Protocol (TCP/UDP/ICMP), Port (Src/Dst), Flags (SYN, ACK, RST), ICMP Type/Code
- IDS/IPS (Suricata/Snort): Rules เขียนบน TCP/UDP/ICMP Headers + Payload (Content, PCRE, Flow)
- DDoS Mitigation: UDP Reflection/Amplification Blocking, SYN Flood Protection (SYN Cookies), Rate Limiting per IP/Flow
- Network Forensics (Zeek/Wireshark): Analyze PCAP - TCP Streams, UDP Flows, ICMP Messages, Anomalies
- Threat Hunting: Beaconing (TCP/UDP Periodic), Long-lived Connections, Unusual Port/Protocol Combos, ICMP Tunneling
สรุป
TCP, UDP, IP, ICMP เป็นพื้นฐานของการสื่อสารเครือข่าย การเข้าใจพฤติกรรมปกติ ช่องโหว่ และรูปแบบการโจมตีของแต่ละโปรโตคอล จำเป็นสำหรับ:
- ออกแบบ Firewall/ACL Rules ที่แม่นยำ
- เขียน IDS/IPS Signatures และ Anomaly Detection
- ทำ Network Forensics และ Threat Hunting
- Mitigate DDoS (UDP Amplification, SYN Flood)
- ป้องกัน Data Exfiltration และ C2 Communications
- Troubleshoot Network Issues อย่างมีประสิทธิภาพ