Перейти к основному содержимому
IDS/IPS Architecture, Placement & Signature Logic
Урок 10 из 12

IDS/IPS Architecture, Placement & Signature Logic

Design effective network intrusion detection and prevention placements, understand how signature engines parse traffic, and write accurate Suricata rules for authorised labs.

Продвинутый 26 мин Сети
Этого урока пока нет на выбранном языке — показана версия на другом языке. Перевод готовится.
Только в разрешённой среде — Описанные здесь приёмы применяются только в учебных лабораториях и в системах, которые принадлежат вам или на которые есть письменное разрешение.

Цели обучения

  • Compare passive IDS and inline IPS architectures, including failure modes and visibility trade-offs
  • Explain how modern engines decode protocols, reassemble streams, and match fast-pattern pre-filters
  • Author and test Suricata signatures using sticky buffers and flow keywords against lab PCAPs
  • Identify common placement blind spots, evasion techniques, and rule-tuning pitfalls

Рекомендуется заранее: Wireshark Deep Packet Inspection & Stream ReassemblySuspicious Network Traffic: Beaconing, Tunneling & ExfilFirewall Configuration, Egress Filtering & Hardening

#Why this matters

State-inspecting firewalls verify IP addresses, ports, and connection state, yet most modern attacks travel inside permitted ports such as 80, 443, and 53. A firewall cannot tell whether an HTTP POST carries a normal form submission or a command-and-control (C2) check-in.

Intrusion Detection Systems (IDS) and Intrusion Prevention Systems (IPS) close that gap by inspecting packet headers, reassembled streams, and application-layer fields against signatures and protocol anomalies. Placing sensors poorly or writing sloppy rules, however, creates silent blind spots or overwhelms analysts with false positives.

#IDS vs. IPS and sensor placement

The core architectural choice is whether the sensor sits out-of-band (IDS) or inline (IPS).

Mode Traffic path Active blocking Failure impact Best fit
Passive NIDS Receives copies via TAP or switch SPAN Alerts only (or injects TCP RST) Zero forwarding outage if sensor crashes Core visibility, threat hunting, initial rule tuning
Inline NIPS Bump-in-the-wire between interfaces Drops or rejects malicious packets Network outage unless hardware bypass fails open Mature, high-confidence signatures at choke points
Host IDS/IPS Agent on endpoint OS Blocks processes or local sockets Local host impact only Encrypted workloads and host-level context

Passive sensors fed by a network TAP capture every frame reliably, whereas switch SPAN (port mirroring) can silently drop mirrored packets during traffic bursts. For inline IPS deployments, engineers must also choose between fail-open (traffic passes uninspected during a crash, preserving availability) and fail-closed (traffic halts, preserving strict policy).

Placement relative to Network Address Translation (NAT) and internal segments determines what you can actually attribute:

  1. InternetExternal traffic
  2. Perimeter Firewall & NATDrops unsolicited inbound ports
  3. DMZ Sensor (TAP)Sees public-facing services before internal routing
  4. Internal Core TAPSees real internal client IPs (pre-NAT) and east-west traffic

If a sensor sits only outside a NAT gateway, every outbound alert reports the single public NAT IP instead of the compromised workstation inside 10.10.10.0/24. Placing sensors inside the NAT boundary and on internal distribution switches exposes both real source addresses and lateral movement across VLANs.

#How signature engines process packets

Modern engines such as Suricata and Snort 3 do not run regular expressions blindly against every raw packet. They use a multi-stage pipeline so line-rate traffic stays fast:

  1. Packet acquisition and decoding: The engine reads frames (for example via AF_PACKET in passive mode or NFQUEUE in inline mode) and validates L2-L4 headers.
  2. Stream reassembly: TCP segments are reordered and reassembled into a continuous stream, defeating naive packet-splitting evasion.
  3. Application-layer parsing: Protocol parsers identify HTTP, DNS, TLS, and SMB regardless of port, extracting normalized fields such as URIs, host headers, and TLS Server Name Indication (SNI).
  4. Multi-pattern pre-filtering: An algorithm such as Hyperscan or Aho-Corasick scans traffic against one fast pattern chosen from each active rule.
  5. Full rule evaluation: Only rules whose fast pattern matched run expensive checks such as regular expressions (pcre), byte tests, or thresholds.

Because of step 4, a rule with a short or common fast pattern (such as GET or .php) forces step 5 to evaluate thousands of times per second, driving up CPU usage and kernel packet drops.

#Writing and testing Suricata rules

A Suricata rule has three parts: the action (alert, drop, pass, reject), the header (protocol, source/destination IP variables and ports, direction), and the options in parentheses.

text
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"Lab C2 Beacon Check-in"; flow:established,to_server; http.method; content:"POST"; http.uri; content:"/api/v1/checkin"; bsize:15; http.header; content:"X-Session-Tag:"; fast_pattern; classtype:trojan-activity; sid:1000101; rev:1;)

Key options make this rule accurate and cheap to run:

  • flow:established,to_server; restricts matching to completed TCP handshakes moving from client to server, eliminating spoofed one-packet noise.
  • Sticky buffers (http.method;, http.uri;, http.header;) apply all following content modifiers to that parsed field until another sticky buffer appears. Using http.uri; ensures Suricata inspects the normalized URI rather than raw packet bytes.
  • bsize:15; checks that the entire URI buffer is exactly 15 bytes long, blocking partial-path false positives.
  • fast_pattern; forces the pre-filter to index X-Session-Tag: (14 uncommon bytes) instead of POST.
  • sid and rev give every rule a unique local ID (above 1000000 for custom rules) and revision number.

You can validate custom rules against a captured PCAP offline before touching a live sensor:

Testing a custom Suricata rule against a lab PCAP
$ suricata -T -S local.rules -c /etc/suricata/suricata.yaml
Notice: suricata: Configuration provided was successfully validated.
$ suricata -r lab-beacon.pcap -S local.rules -l ./logs/
Notice: suricata: This is Suricata version 7.0.x RELEASE running in USER mode
$ cat ./logs/fast.log
11/18/2026-14:22:09.114021  [**] [1:1000101:1] Lab C2 Beacon Check-in [**] [Classification: A Network Trojan was detected] [Priority: 1] {TCP} 10.10.10.24:51422 -> 198.51.100.42:8080

Suricata also writes structured JSON records to ./logs/eve.json, capturing the HTTP URI, hostname, and alert metadata together for SIEM ingestion.

#Defending against evasion and common mistakes

Attackers try to slip past naive signatures, and defenders often weaken their own sensors through configuration mistakes:

  • Encrypted payload blindness: TLS hides http.uri and http.header from passive sensors. Instead of writing broken payload rules on port 443, match metadata fields (tls.sni, certificate subject/issuer, or JA3/JA4 fingerprints) or inspect decrypted traffic at an authorised TLS proxy.
  • Unanchored raw matches: Matching content without flow or protocol sticky buffers lets attackers bypass rules using URL encoding (%2f), extra whitespace, or TCP segmentation. Always inspect normalized buffers (http.uri, not http.uri.raw, unless deliberately hunting raw obfuscation).
  • Enabling IPS blocking prematurely: Switching thousands of community rules to drop without a baseline monitoring window breaks legitimate business traffic. Run new rules in alert mode first, measure hit rates, and promote only high-confidence signatures to drop.
  • Ignoring packet drops: Check stats.log or eve.json stats events for capture.kernel_drops. Dropped packets mean blind spots; fix them by tuning fast_pattern choices, pinning worker threads, or upgrading from SPAN to a hardware TAP.

#Summary

Passive NIDS provides risk-free visibility via TAPs or SPAN ports, while inline NIPS enforces blocking at the cost of latency and failure-mode risk. Placing sensors inside NAT boundaries and across internal segments ensures accurate host attribution and east-west coverage. Effective Suricata signatures rely on flow state, normalized sticky buffers, and selective fast_pattern strings, always tested offline against PCAPs and tuned in alert mode before blocking.

Проверка знаний

Войдите, чтобы проходить тест, завершать уроки и сохранять прогресс. Войти в систему

Практика: проверьте свои знания