Intrusion Detection System (IDS) คืออะไร?
Intrusion Detection System (IDS) คือระบบที่เฝ้าระวัง (Monitor) เครือข่ายหรือระบบ เพื่อตรวจจับกิจกรรมที่น่าสงสัย นโยบายที่ถูกละเมิด หรือการโจมตีที่ทราบจัก (Known Attacks) และส่งเตือน (Alert) ให้ทีมความปลอดภัย ไม่ได้ Block เอง (นั่นคือ IPS)
IDS vs IPS vs Firewall
| Feature | Firewall | IDS | IPS |
|---|---|---|---|
| Primary Function | Allow/Deny Traffic (Policy) | Detect & Alert | Detect & Block (Inline) |
| Deployment | Inline (In Path) | Out-of-band (Tap/SPAN) | Inline (In Path) |
| Latency Impact | Yes | No (Passive) | Yes (Minimal) |
| False Positive Risk | Low (Policy-based) | Medium (Alert Only) | High (Can Block Legit) |
| Use Case | Perimeter Control | Visibility, Forensics, Compliance | Active Prevention |
ประเภทของ IDS
1. ตามตำแหน่งการติดตั้ง (Deployment)
- NIDS (Network-based IDS): ติดตั้งบน Network Tap/SPAN Port เฝ้าระวัง Traffic ทั้ง Segment
- ตัวอย่าง: Snort, Suricata, Zeek (Bro), Cisco FirePOWER, Corelight
- จุดแข็ง: มองเห็นทั้ง Network, ไม่ต้อง Agent บน Host
- จุดอ่อน: ไม่เห็น Encrypted Traffic (TLS), ไม่เห็น Host-level Activity
- HIDS (Host-based IDS): ติดตั้ง Agent บน Server/Endpoint
- ตัวอย่าง: OSSEC/Wazuh, Sysmon, Auditd, CrowdStrike, SentinelOne
- จุดแข็ง: มองเห็น File Integrity, Registry, Process Tree, Logs, Encrypted Traffic (บน Host)
- จุดอ่อน: ใช้ Resource ของ Host, ต้อง Deploy ทุกเครื่อง
- Hybrid/Cloud IDS: Cloud-native (AWS GuardDuty, Azure Defender, GCP Security Command Center)
2. ตามวิธีการตรวจจับ (Detection Method)
- Signature-based (Misuse Detection): จับรูปแบบที่รู้จัก (Rules, Signatures, IOCs) - เร็ว แม่นยำสำหรับ Known Threats แต่ไม่จับ Zero-day
- Anomaly-based (Behavioral/ML): เรียนรู้ Baseline ปกติ → จับ Deviation - จับ Zero-day/Unknown ได้ แต่ False Positive สูง
- Hybrid: รวมทั้งสอง (Modern NIDS/NDR ทำได้)
IDS ที่นิยมใช้งาน (Top Tools)
| Tool | Type | License | Strengths |
|---|---|---|---|
| Snort | NIDS/NIPS | Open Source (GPL) | Mature, Huge Rule Set, Cisco-backed |
| Suricata | NIDS/NIPS | Open Source (GPL) | Multi-threaded, Rust-based, Lua Scripting, File Extract |
| Zeek (Bro) | NIDS (NSM) | BSD License | High-level Logs, Protocol Analysis, Scripting, Long-term Storage |
| Wazuh (OSSEC Fork) | HIDS + SIEM | Open Source (GPL) | FIM, Log Analysis, Rootkit Detection, MITRE Mapping, Cloud |
| Security Onion | Distro (NIDS+HIDS+SIEM) | Open Source | All-in-one: Zeek, Suricata, Wazuh, Elastic, Kibana, Stenographer |
| Cisco Secure IDS/IPS | NIDS/NIPS | Commercial | Talos Intelligence, Integrated with Cisco Ecosystem |
| Palo Alto / FortiGate IPS | NIPS (Inline) | Commercial | App-ID, SSL Decrypt, Threat Prevention Subscription |
การทำงานของ IDS (Workflow)
- Packet Capture: รับ Traffic จาก Tap/SPAN/Port Mirror/Agent
- Preprocessing: Reassembly (TCP Stream), Normalization, Decoding
- Detection Engine:
- Signature Matching (Pattern Matching: Aho-Corasick, Hyperscan)
- Anomaly Detection (Statistical, ML, Behavioral)
- Protocol Analysis (RFC Compliance)
- Alert Generation: สร้าง Event/Alert พร้อม Context (Src/Dst IP, Port, Payload, Rule ID, Severity)
- Logging/Output: Syslog, JSON, PCAP, Database, SIEM Forward
- Response (ถ้าเป็น IPS): Drop Packet, Reset Connection (TCP RST), Block IP, Rate Limit
IDS Rules (Snort/Suricata Rule Syntax)
alert tcp any any -> $HOME_NET 80 (msg:"WEB-APP SQL Injection Attempt"; flow:to_server,established; content:"UNION SELECT"; nocase; sid:1000001; rev:1;)
Action: alert/log/pass/drop/reject/sdrop | Protocol | Source IP/Port | Direction | Destination IP/Port | (Options: msg, content, pcre, flow, threshold, metadata, sid, rev)
Deployment Architecture
- Strategic Placement: Internet Edge (Inbound/Outbound), Data Center East-West, DMZ, Critical Segments (OT, PCI, Crown Jewels)
- Tap vs SPAN: Tap (Hardware, No Packet Loss, Fail-open) > SPAN (Switch Port, May Drop at High Util)
- Encrypted Traffic: ต้องมี TLS Decryption (Out-of-band Decrypt หรือ Inline Decrypt) เพื่อ Inspect HTTPS
IPS (Intrusion Prevention System) - Inline Prevention
- ทำงาน Inline (In-path) → สามารถ Drop/Block ได้จริง
- Modes: Inline (Prevention), Tap (Detection Only), Simulate (Log Only)
- Critical: False Positive = Business Impact ต้อง Tuning อย่างต่อเนื่อง
- High Availability: Active/Standby, Active/Active (Bypass Network Interface)
Best Practices
- Enable เฉพาะ Rules ที่เกี่ยวข้อง (Disable Noisy Rules)
- Tuning Thresholds: Suppression, Rate Limiting, Event Filtering
- Integrate กับ SIEM (Correlation, Enrichment)
- Regular Rule Updates (Talos, Emerging Threats, Custom)
- PCAP Retention สำหรับ Forensics (Storage Sizing)
- Test Rules ใน Lab/Simulate Mode ก่อน Deploy Production
- Red Team / Purple Team Exercises เพื่อ Validate Detection
สรุป
IDS เป็น "ตา" ของ Security Operations ให้ Visibility ลงลึก ส่วน IPS เป็น "มือ" ที่ Block ได้จริง ทั้งคู่ต้องทำงานร่วมกับ Firewall, SIEM, EDR, Threat Intel ในกรอบ Defense in Depth ไม่ควรพึ่งพาเพียงตัวเดียว