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

Phát hiện xâm nhập (Intrusion Detection - IDS) trong bảo mật mạng

IDS (Intrusion Detection System) là gì?

Hệ thống phát hiện xâm nhập (IDS) là giải pháp bảo mật giám sát lưu lượng mạng và/hoặc hoạt động hệ thống để tìm kiếm dấu hiệu của hoạt động độc hại, vi phạm chính sách hoặc hành vi bất thường. IDS chỉ cảnh báo (alert), không tự động chặn (khác với IPS - Intrusion Prevention System).

Phân loại IDS theo triển khai

LoạiVị tríĐối tượng giám sátƯu điểmNhược điểm
NIDS (Network IDS)Điểm chiến lược mạng: Internet edge, DMZ, Data Center, VLAN boundary (SPAN/TAP)Traffic mạng (L2-L7)Không cần agent, thấy toàn bộ traffic, không ảnh hưởng hiệu năng hostKhông thấy traffic mã hóa (TLS) nếu không SSL decrypt, blind spot East-West nếu không tap đủ chỗ
HIDS (Host IDS)Cài agent trên Server, Workstation, ContainerSystem call, File integrity (FIM), Log (Event Log, Syslog, Auditd), Process, Network connection cục bộThấy được sau khi giải mã (TLS), context tiến trình/user, FIM chính xácCần cài agent, tiêu tốn resource host, quản trị fleet agent phức tạp
PIDS (Perimeter IDS)Biên giới mạng (DMZ, Internet Gateway)Traffic vào/ra InternetTập trung ranh giới, dễ triển khaiBỏ lỡ internal threat, lateral movement
VM-based IDS / Cloud IDSChạy trong VM/Container, mirror traffic VPC/VNet (AWS Traffic Mirroring, Azure Virtual Network TAP, GCP Packet Mirroring)Traffic cloud (North-South, East-West)Cloud-native, auto-scale, không hardwareChi phí mirror traffic, chỉ thấy cloud

Phân loại theo phương pháp phát hiện

  1. Signature-based (Dựa trên chữ ký / Misuse Detection): So khớp traffic với database chữ ký đã biết (Snort rules, Suricata rules, Emerging Threats, Proofpoint ET Pro). Ưu: Phát hiện chính xác tấn công biết, low false positive. Nhược: Bỏ lỡ zero-day, variant mới, polymorphic malware.
  2. Anomaly-based (Dựa trên bất thường / Behavior Detection): Học baseline bình thường (statistical, ML) → alert khi lệch (volume, frequency, protocol violation, rare destination, odd user agent). Ưu: Phát hiện zero-day, unknown. Nhược: False positive cao, cần tuning, baseline time.
  3. Hybrid (Kết hợp): Đa số IDS/IPS hiện đại dùng cả hai + Threat Intel + Reputation + Protocol Analysis (Zeek/Bro scripts).

IDS vs IPS vs Firewall

Đặc điểmFirewallIDSIPS
Chức năng chínhAllow/Deny theo policy (L3-L4, App-ID)Detect & Alert (Passive)Detect & Block (Inline, Active)
Vị tríChoke point (Perimeter, Segment)SPAN/TAP (Out-of-band)Inline (In-band)
Ảnh hưởng trafficCó (enforcement point)Không (passive)Có (latency, drop risk nếu fail-open/closed)
TLS InspectionCó (NGFW)Khó (cần SSL Decrypt trước)Có (NGFW/IPS inline)
Ví dụPalo Alto, FortiGate, Cisco Secure FirewallSuricata, Zeek, Snort, Security OnionPalo Alto (inline), FortiGate (IPS mode), Cisco Firepower, TippingPoint

Công cụ IDS mã nguồn mở phổ biến

  • Suricata: Multi-threaded, hỗ trợ Lua scripting, Eve JSON output, protocol detection mạnh, App Layer parsing (HTTP, TLS, DNS, SSH, SMB, MQTT).
  • Zeek (formerly Bro): Network Security Monitor – không chỉ IDS, mà framework phân tích traffic sâu (conn.log, http.log, ssl.log, dns.log, files.extract). Rất mạnh threat hunting, forensic.
  • Snort: Cổ điển, rule syntax phổ biến, single-threaded (legacy), vẫn dùng nhiều nơi do rule base khổng lồ.
  • Security Onion: Distro Linux tích hợp Suricata, Zeek, Elastic Stack (Kibana), Fleet (Osquery), Stellar Cyber, Playbook – sẵn sàng SOC-in-a-box.
  • Wazuh: HIDS + FIM + Log Analysis + Vulnerability Detection + MITRE ATT&CK mapping – agent-based, manager tập trung.

Chức năng cốt lõi của IDS

  1. Thu thập (Collection): Packet capture (libpcap/AF_PACKET/DPDK), NetFlow/sFlow, Log (Syslog, Windows Event, CloudTrail), API Cloud.
  2. Phân tích (Analysis): Rule matching, Anomaly scoring, Protocol parsing, File extraction, Threat Intel enrichment.
  3. Cảnh báo (Alerting): Tạo event/alert với severity, context (src/dst IP, user, host, MITRE ATT&CK technique, IOC, PCAP snippet).
  4. Tương tác (Response Support): Cung cấp context cho Analyst triage, SOAR playbook trigger, Threat Hunting pivot.

Ví dụ quy tắc Suricata (Signature-based)

alert http any any -> $HOME_NET any (
  msg:"ET EXPLOIT Possible Log4j JNDI Injection Attempt";
  flow:established,to_server;
  http.header; content:"${jndi:"; fast_pattern; nocase;
  http.uri; content:"${jndi:"; nocase;
  http.client_body; content:"${jndi:"; nocase;
  metadata:attack_target Application_Server, deployment Perimeter, tag Exploit, signature_severity Major;
  reference:url,logging.apache.org/log4j/2.x/security.html;
  reference:cve,2021-44228;
  classtype:attempted-admin;
  sid:2031762; rev:12;
)

Ví dụ phát hiện bất thường (Zeek Script)

# Detect SSH brute force: > 10 failed auth in 1 minute from same src
event ssh_auth_failed(c: connection, auth_method: string, user: string) {
  if (c$ssh?$auth_failed_count) c$ssh$auth_failed_count += 1;
  else c$ssh$auth_failed_count = 1;
  if (c$ssh$auth_failed_count > 10) {
    NOTICE([$note=SSH::Brute_Force, $src=c$id$orig_h, $dst=c$id$resp_h,
            $msg=fmt("SSH brute force from %s: %d failed attempts", c$id$orig_h, c$ssh$auth_failed_count)]);
  }
}

Triển khai IDS hiệu quả (Best Practices)

  1. Visibility trước: SPAN/TAP tại tất cả choke point (Internet, DC, OT, Cloud). Không thể phát hiện những gì không thấy.
  2. Tuning liên tục: Baseline false positive → suppress rule gây noise → tập trung high-fidelity alert.
  3. Threat Intel Integration: Tự động pull IOC (IP, Domain, Hash, URL) từ MISP, OTX, Commercial feed → block list / detection rule.
  4. MITRE ATT&CK Tagging: Mọi rule/alert gắn technique ID (T1059, T1003, T1566) → đo coverage, prioritize gap.
  5. PCAP Retention: Lưu full packet capture ≥ 7 ngày (hot), ≥ 90 ngày (cold) cho forensic.
  6. Integration: Syslog/CEF/JSON → SIEM (Splunk, Sentinel, Elastic) → Correlation → SOAR → Ticketing (Jira, ServiceNow).
  7. Purple Team Validation: Emulate technique (Atomic Red Team, Caldera) → verify detection → improve rule.

Kết luận

IDS là "cảm biến" (sensor) quan trọng trong chiến lược Defense in Depth. Xu hướng hiện nay: NIDS + HIDS + Cloud IDS hội tụ vào XDR/Open XDR (Cortex XDR, Microsoft Defender XDR, CrowdStrike Falcon, Elastic Security) – single pane of glass, correlated detection, automated response. Triển khai IDS thành công = Visibility + High-Fidelity Detection + Actionable Alert + Continuous Tuning.