TExcelTAD
Home › Network Security: Discovery, Segmentation, Firewalls, VPN & IDS › IDS and IPS: Signatures, Anomalies and Placement

IDS and IPS: Signatures, Anomalies and Placement

Firewalls decide by addresses, ports and connection state. They don't look inside allowed traffic, and allowed traffic is exactly where most attacks travel: the exploit rides in an HTTPS request to the public web server, the stolen data leaves over an allowed DNS path, the worm spreads over SMB that file sharing needs. An intrusion detection system (IDS) inspects traffic (or host activity) for signs of attack and raises alerts; an intrusion prevention system (IPS) sits in the path and can also drop what it detects. This lesson covers the two ways of detecting, where sensors go, and what each placement can and can't see. The next lessons write rules, read Zeek logs and tune the result.

Two ways to detect

Signature-based (misuse) Anomaly-based (behavioural)
Idea match known patterns of attacks: bytes, protocol fields, sequences learn what is normal, alert on deviations
Examples a Suricata rule matching an exploit's request; a known-bad domain a host suddenly talking to 300 others; DNS queries ten times the usual length; traffic at 3 a.m.
Strength precise, explainable ("rule 2034567 matched these bytes"), few false positives when tuned can catch new attacks and misuse of legitimate tools
Weakness blind to what it has no signature for; evasion by small changes many false positives; "normal" includes bad habits; needs a baseline and tuning
Typical tools Suricata, Snort, ClamAV, YARA, threat-intel matching Zeek scripts and analytics on its logs, NetFlow analytics, NDR products, SIEM correlation

Real deployments combine both. The program shows the difference on one synthetic hour of connection counts per internal host: a signature view would only fire on a known bad destination, an anomaly view compares each host with its own baseline.

python · try it yourself
import statistics as st

baseline = {   # connections per hour over the last 7 days (synthetic)
    "ws05":   [110, 95, 130, 102, 120, 99, 115],
    "ws07":   [80, 92, 85, 77, 90, 88, 84],
    "www":    [2400, 2550, 2300, 2610, 2480, 2390, 2520],
    "db":     [300, 310, 295, 305, 290, 315, 300],
}
this_hour = {"ws05": 118, "ws07": 1430, "www": 2700, "db": 298}
known_bad = {"203.0.113.66"}                       # a threat-intel list
destinations = {"ws05": {"10.10.2.25", "198.51.100.30"}, "ws07": {f"10.10.3.{i}" for i in range(1, 250)},
                "www": {"10.10.2.30"}, "db": {"10.10.2.53"}}

print(f"{'host':5} {'now':>5} {'mean':>7} {'sd':>6} {'z':>6}  anomaly  signature")
for h, hist in baseline.items():
    m, sd = st.mean(hist), st.stdev(hist)
    z = (this_hour[h] - m) / sd
    anomaly = "ALERT" if abs(z) > 4 else "-"
    sig = "ALERT" if destinations[h] & known_bad else "-"
    print(f"{h:5} {this_hour[h]:5} {m:7.1f} {sd:6.1f} {z:6.1f}  {anomaly:7}  {sig}")
print("ws07 distinct internal destinations this hour:", len(destinations["ws07"]))
host    now    mean     sd      z  anomaly  signature
ws05    118   110.1   12.5    0.6  -        -
ws07   1430    85.1    5.4  250.6  ALERT    -
www    2700  2464.3  106.9    2.2  -        -
db      298   302.1    8.6   -0.5  -        -
ws07 distinct internal destinations this hour: 249

ws07 makes over a thousand connections to 249 internal addresses in an hour, about 250 standard deviations above its own normal: classic worm or scanning behaviour, invisible to the signature view because no destination is on a blocklist. The web server's 2,700 is also above its mean, but a z-score of 2.2 for a busy server is ordinary variation; the threshold decides, which is what tuning is about (Tuning Alerts and False Positives).

Network and host sensors

  • NIDS (network IDS) watches packets on a link: Suricata, Snort, Zeek. One sensor sees many hosts, including unmanaged ones, but not the content of encrypted traffic.
  • HIDS (host IDS) watches one system: file integrity, logs, processes (OSSEC/Wazuh, auditd rules, EDR). It sees decrypted activity and local actions, but only where an agent runs.

Encryption moves detection to the hosts and to metadata: with TLS 1.3 everywhere, a NIDS still sees addresses, ports, timing, sizes, the SNI and the certificate chain (where not encrypted), JA3/JA4 client fingerprints, and DNS (unless encrypted too). TLS interception at a proxy restores content inspection for outbound web traffic, at a cost in privacy, complexity and risk.

Where the sensor sits

firewall TAP switch IDS (passive) IDS via SPAN(copy of ports) firewall IPS (inline) servers passive: sees copies, can only alert inline: every packet passes through it, it can drop
Placement How Pros Cons
Network tap a passive device on the cable copies both directions to the sensor sees every packet, including errors; can't be misconfigured into the path; fails safe (traffic continues) hardware per link; full-duplex links need two monitor ports or an aggregating tap
SPAN / mirror port the switch copies selected ports or VLANs to a monitor port no extra hardware, flexible the switch may drop copies under load; oversubscription (many ports into one); configuration can silently change
Inline IPS the sensor forwards traffic and can drop prevention, not just detection adds latency and a failure point: decide fail-open (traffic passes when the IPS fails: availability) or fail-closed (traffic stops: security); false positives block real users
Host / cloud agents, VPC traffic mirroring, cloud-native IDS sees east-west traffic and decrypted activity per-host cost; coverage gaps where no agent runs

Placement follows the zones (Zones, DMZs and Trust Boundaries): behind the Internet firewall (what got past it), at the DMZ–internal boundary (a compromised DMZ host talking inward), on the server zone's uplink (east-west traffic), and at the egress point (beacons, exfiltration). A sensor in front of the firewall sees all the Internet's noise and mostly measures background scanning.

Prevention modes

An IPS drops packets that match rules marked drop (Suricata in inline mode with NFQUEUE or AF_PACKET) or resets connections. Common practice: run new rules in alert mode first, measure their false positives on real traffic, then switch the reliable ones to drop. High-confidence rules (known exploit payloads against your exposed services) are good prevention candidates; broad policy rules are better as alerts.

Pitfalls

  • A sensor that receives traffic but nobody reads its alerts.
  • SPAN sessions silently dropping packets under load; check the sensor's capture-loss statistics.
  • Asymmetric visibility: the sensor sees only one direction of a flow, so stream reassembly and many rules fail.
  • Inline IPS with all rules in drop mode on day one.
  • Forgetting encrypted traffic: plan metadata-based detection and host sensors.

Practice

1. In the program, which hosts alert at a threshold of |z| > 2 instead of 4, and what does that show?

ws07 and www (z = 2.2): a lower threshold catches the web server's normal busy hour as a false positive. Thresholds trade missed attacks against false alarms.

2. You can afford one sensor for the lab company. Where do you put it?

On the firewall's internal side covering the DMZ–server boundary and the egress path (for example on a tap or SPAN of the firewall's internal interfaces), so it sees inbound attacks that passed the firewall, DMZ-to-internal traffic and outbound beacons. Add host agents on the servers for east-west and encrypted activity.

3. An inline IPS in front of the payment API fails. Should it fail open or closed?

It depends on the business decision recorded in the design. Payment availability usually argues for fail-open with an immediate alert, plus compensating controls (the API's own input validation, a WAF, host monitoring); a system where a missed attack is worse than an outage may fail closed.

Test yourself

Which detection approach can catch a new attack with no known pattern?

  1. Signature-based
  2. Anomaly-based
  3. Neither
  4. Port-based filtering

Why did the signature view miss ws07?

  1. Its traffic was encrypted
  2. None of its destinations were on the known-bad list, although its behaviour was abnormal
  3. It was offline
  4. Signatures only work on servers

What is a key advantage of a network tap over a SPAN port?

  1. It can drop packets
  2. It passively copies every packet and isn't subject to switch load or configuration changes
  3. It decrypts TLS
  4. It is free

What does fail-open mean for an inline IPS?

  1. It blocks all traffic on failure
  2. Traffic keeps flowing (uninspected) when the IPS fails
  3. It opens all ports
  4. It logs more