ntopng/scripts/lua/modules/alert_definitions
Ivan Nardi e0a2f4aa5e
Fix the direction of DHCP flows and the Unexpected DHCP server check (#11139)
DHCP flows whose first packet is a reply sent by the server (e.g. a unicast
ACK or OFFER, a reply to a relay agent) were recorded with the server as
client, as the direction of UDP flows is never swapped by the ports. The
Unexpected DHCP server check, the DHCP service and the DHCP Server tag relied
on that reversed direction (server = client of the flow using port 67), so
also relay agents got the DHCP service/tag, rogue servers were missed when
the flow started with a request, the alert blamed the client of the flow and
its description named the DHCP client.

Direction (Flow::checkL7Direction()):
* DHCP (v4) flows are decided by the first packet, BOOTREQUEST or BOOTREPLY
  (op), as already done for DNS, NTP and ICMP.
* A flow is never swapped when its client would become a non-unicast address
  (e.g. a reply sent to broadcast), as in check_swap(): this applies to all
  the protocols checked there.

DHCP server of a flow (new Flow::isDHCPServerClient()): the server of the
flow, or its client for the replies sent to broadcast; by the ports only when
the direction has not been decided (e.g. collected flows). Used by
get_dhcp_srv_ip_addr(), by the DHCP service (relay agents talking to a DHCP
server no longer get it) and by the check. The DHCP fingerprint is taken only
from the DHCP client (port 68), not from relay agents.

Unexpected DHCP server check:
* Checks the flows whose DHCP server is a unicast address, on either side.
* Requires a reply from the server: the flows are checked when the protocol
  is detected, if the server has already replied, and again when they end
  (new has_flow_end parameter of UnexpectedServer), for the replies following
  a request. A flow alerted twice keeps the first alert only. A request with
  no reply (e.g. a renew to a server that no longer answers) raises no alert.
* The DHCP server is the attacker. UnexpectedServer now gives most of the
  score to the attacker set by buildAlert() (unchanged for the DNS, NTP and
  SMTP checks, which blame the client).
* The description names the DHCP server (server_ip of the alert), also when
  it is the client of the flow.
* Relay agents forwarding to a configured DHCP server are still allowed.

Documentation of the check updated.

DHCPv6 is not changed.
2026-10-28 11:24:28 +01:00
..
flow Fix the direction of DHCP flows and the Unexpected DHCP server check (#11139) 2026-10-28 11:24:28 +01:00
host Implemented VPN detection alert (#10344) 2026-05-12 12:47:02 +02:00
other Added utm source to ntop links (#11108) 2026-10-21 17:23:50 +02:00