detecting-modbus-command-injection-attacks

Detect unauthorized Modbus TCP write operations and anomalous function codes in ICS networks.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill detecting-modbus-command-injection-attacks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: detecting-modbus-command-injection-attacks
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/ot-ics-security/detecting-modbus-command-injection-attacks
Command: npx skills add https://github.com/xalgord/xalgorix --skill detecting-modbus-command-injection-attacks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires scapy.

What problem does it solve?

Modbus TCP lacks authentication, so attackers can inject write commands to manipulate PLC registers and coils without detection. This Skill helps OT security teams identify unauthorized masters, anomalous function codes, broadcast writes, and out-of-range register access before they cause operational impact like the FrostyGoop attack.

Core Features & Use Cases

  • Baseline-Based Anomaly Detection: Compare live Modbus traffic against authorized master/slave pairs, allowed function codes, register ranges, and polling intervals.
  • Six Detection Rules: Flag unauthorized masters, unauthorized writes, write floods, broadcast writes (unit ID 0), out-of-range register access, and diagnostic commands, each mapped to MITRE ATT&CK for ICS techniques.
  • Suricata Rule Deployment: Ready-to-adapt IDS rules for Modbus write operations, broadcast commands, and FrostyGoop-pattern register writes.
  • Use Case: An OT SOC analyst monitoring a building automation segment notices write commands from an unknown IP to heating control PLCs; the detector flags it as a CRITICAL unauthorized write with MITRE technique T0855 for investigation.

Quick Start

Analyze a captured Modbus traffic file against my baseline configuration and report any unauthorized write operations or anomalous function codes.

Frequently Asked Questions about detecting-modbus-command-injection-attacks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect unauthorized Modbus write commands on my network?

Monitor TCP port 502 traffic and compare write function codes (FC5, FC6, FC15, FC16) against a baseline of authorized master IPs and register ranges. The included Python detector uses Scapy to parse MBAP headers and flags writes from non-authorized sources as CRITICAL alerts.

What Suricata rules detect Modbus command injection attacks?

Use Suricata rules matching modbus_func keywords like write_single_coil and write_multiple_registers from non-authorized sources, plus rules for unit ID 0 broadcast writes and excessive write rates. The Skill provides six ready rules with classtype and threshold configurations.

Can Modbus detection work with offline pcap files?

Yes, the detector accepts pcap or pcapng files for offline analysis using Scapy's rdpcap function, in addition to live interface monitoring. This lets you validate detection rules against labeled captures without touching live PLC traffic.

Why does IP-based Modbus allowlisting produce false negatives?

Modbus TCP has no authentication, so attackers can spoof a legitimate master IP to make malicious writes appear authorized. Combine IP allowlisting with ARP inspection, static MAC bindings, register value bounds, and write-rate limits to close this gap.

What are the limitations of Modbus function code monitoring?

Function code matching alone misses attacks that reuse permitted codes and registers, as FrostyGoop did. It also cannot see Modbus RTU serial traffic behind gateways if the SPAN only watches TCP/502, and legitimate SCADA writes use the same codes, requiring change-log correlation.