Join our Newsletter — 33% off our NHI Course
Home› Guides› Modbus TCP and Modbus Security Guide: Protecting an…
Guide OT & IoT Security

Modbus TCP and Modbus Security Guide: Protecting an unauthenticated protocol in practice

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 13 min read
On this page

Modbus accepts a write to a holding register from any host that can reach the device, with no authentication and no integrity check, and that is how it is still deployed in most plants, buildings and utilities. The protocol dates from serial networks where physical access was the only control, and its TCP form simply carried that trust onto Ethernet. A secure variant, Modbus/TCP Security on port 802, exists but needs support at both ends. This guide explains how Modbus works from a defender's point of view, what attackers can do with it, how to choose between protecting legacy Modbus and moving to the secure variant, and how to segment, filter and monitor it. It is written for OT engineers, network and detection teams, and integrators who specify Modbus devices.

Key takeaways

  • Reachability equals control. Any device that can open TCP 502 to a Modbus server can read and write its data model; the network path is the only access control legacy Modbus has.
  • Function codes are the policy language. Reads (codes 1 to 4) and writes (5, 6, 15, 16, 22, 23), plus diagnostics and vendor programming codes, can be allowed or blocked per source with protocol-aware firewalls and IDS rules.
  • Modbus/TCP Security is worth it for new builds. TLS with mutual certificate authentication on TCP 802 fixes spoofing and tampering, but only when both client and server support it and certificates are managed.
  • Never expose Modbus to the internet. The FrostyGoop incident disrupted district heating in Ukraine using legitimate Modbus commands against controllers reachable on port 502.
  • Baseline writes and alert on deviation. Most Modbus networks have a small, stable set of masters and write patterns; anything new is worth investigating.

How Modbus works, from a defender's view

Modbus is a request and response protocol between a client (historically the master, typically a SCADA server, HMI or PLC) and a server (historically the slave, typically a PLC, RTU, meter, drive or gateway). It exists in three main forms.

  • Modbus RTU: binary framing over serial links such as RS-485, with a device address (1 to 247, 0 is broadcast) and a CRC. Physical access to the bus means full access.
  • Modbus ASCII: the same model with text framing, rare in new installations.
  • Modbus TCP: the Modbus PDU wrapped in an MBAP header (transaction identifier, protocol identifier, length and unit identifier) over TCP. IANA registers the service mbap on port 502 and mbap-s, the secure variant, on port 802.

The data model has four tables: coils (read and write bits), discrete inputs (read-only bits), input registers (read-only 16-bit words) and holding registers (read and write 16-bit words). What a register means (a setpoint, a valve position, a speed limit) is defined only by the device vendor's register map. That is why reconnaissance matters to an attacker and why register maps should be treated as sensitive engineering documents.

The unit identifier routes requests through Modbus TCP to RTU gateways: the IP address is the gateway, and the unit ID selects the serial device behind it. One exposed gateway can therefore expose an entire serial bus.

Function codes and what they allow

The function code tells the server what to do. Defenders should know which codes their process actually uses, because allowlisting them is the most effective control available for legacy Modbus. Names below follow the Zeek Modbus analyzer constants.

Code (decimal / hex)NameEffectTypical policy
1 / 0x01Read CoilsRead output bitsAllow from SCADA, HMI and historian
2 / 0x02Read Discrete InputsRead input bitsAllow from SCADA, HMI and historian
3 / 0x03Read Holding RegistersRead read/write registersAllow from SCADA, HMI and historian
4 / 0x04Read Input RegistersRead measured valuesAllow from SCADA, HMI and historian
5 / 0x05Write Single CoilSwitch an output on or offOnly from named control masters
6 / 0x06Write Single RegisterChange a setpoint or parameterOnly from named control masters, ideally to defined address ranges
15 / 0x0FWrite Multiple CoilsSwitch several outputsOnly from named control masters
16 / 0x10Write Multiple RegistersChange several parameters at onceOnly from named control masters; alert on new address ranges
22 / 0x16 and 23 / 0x17Mask Write Register; Read/Write Multiple RegistersModify register bits; combined read and writeTreat as writes
8 / 0x08DiagnosticsIncludes sub-functions that restart communications or force listen-only modeBlock except from maintenance hosts
17 / 0x11 and 43 / 0x2BReport Server ID; Encapsulated Interface Transport (device identification)Reveal device type and firmware detailsAllow from asset inventory tools only; alert otherwise
20 / 0x14 and 21 / 0x15Read File Record; Write File RecordAccess file-structured memoryBlock unless the process needs it
90 / 0x5A, 125 / 0x7D and other vendor codesVendor programming (for example Schneider Unity), firmware replacementProgram download, firmware change, run/stopOnly from engineering workstations, ideally only during change windows

A server answering with an exception (the function code with the high bit set plus an exception code such as Illegal Function or Illegal Data Address) is useful evidence: bursts of exceptions often mean someone is scanning the register map.

Threats and how attacks use Modbus

ThreatWhat it looks like on the wireATT&CK for ICSControl
Unauthorised parameter changeWrites (6, 16) from a host that does not normally writeT0836 Modify Parameter, T1692 Unauthorized MessageWrite allowlist per source, protocol-aware firewall, alerting
Process reconnaissanceSequential reads across address ranges, device identification requests, exception burstsT0861 Point & Tag Identification, T0888 Remote System Information DiscoveryBlock identification codes from non-inventory hosts, alert on scans
Loss of view and false readingsChanged scaling or calibration registers, firmware downgradeT0829 Loss of View, T0832 Manipulation of View, T1693.001 System FirmwareRestrict programming codes, monitor firmware versions
Denial of serviceFloods of requests, Diagnostics sub-functions that force listen-only mode, malformed framesT0814 Denial of ServiceRate limits, block code 8 from non-maintenance hosts, connection limits
Spoofing and man in the middleInjected or modified responses on a flat networkT0830 Adversary-in-the-MiddleSegmentation, port security, Modbus/TCP Security where supported
Internet exposureInbound TCP 502 from the internetT0883 Internet Accessible DeviceRemove exposure, external scanning, secure remote access

FrostyGoop: MITRE ATT&CK records the FrostyGoop Incident (C0041) as taking place in January 2024 against a municipal district heating company in Ukraine, where the FrostyGoop malware (S1165) was used to manipulate ENCO controllers through legitimate Modbus commands. The software reads and writes holding registers over TCP 502. ATT&CK records modified parameters that made controllers report incorrect measurements and a firmware downgrade to a version lacking monitoring. Dragos, which found the binaries in April 2024, reported a two-day loss of heating, assessed with moderate confidence that the controllers had port 502 exposed to the internet, and noted that the router, management servers and controllers were not adequately segmented. Nothing in that attack required a vulnerability in Modbus itself: the protocol did exactly what it was told. See the FrostyGoop Modbus Malware Guide.

Legacy Modbus or Modbus/TCP Security: the decision

Modbus/TCP Security, published by the Modbus Organization, wraps Modbus in TLS on TCP port 802 with mutual authentication using X.509v3 certificates, and allows the server to authorise requests based on a role carried in the client certificate. Wireshark and other tools dissect it as Modbus over TLS on port 802. The decision is about where the protection gets you most risk reduction for the effort.

FactorProtect legacy Modbus TCP (502)Adopt Modbus/TCP Security (802)
Device supportWorks with any deviceNeeds firmware support on every client and server in the path
ProtectionNetwork controls only: anyone on the permitted path can still writeAuthenticates both ends, protects integrity and confidentiality, supports role-based authorisation
OperationsNo certificates to manageCertificate issuance, renewal and revocation for every device; expiry can stop communications
MonitoringFull visibility of function codes to IDS and protocol-aware firewallsPayload is encrypted; visibility needs endpoint logging or inspection at a trusted proxy
PerformanceMinimal overheadTLS handshake and processing on small devices; keep sessions long-lived
Best fitBrownfield sites, serial gateways, devices with long remaining lifeGreenfield projects, links crossing untrusted networks, remote sites, high-consequence writes

For most organisations the answer is both: specify Modbus/TCP Security in procurement for new devices and links that leave a protected zone, and protect the installed base with segmentation and function code filtering. Where devices cannot be upgraded, a secure tunnel (IPsec or TLS between gateways) protects Modbus across an untrusted network, but it does not authenticate which host inside the zone sent a command. Treat device certificates as machine identities with owners, expiry tracking and a renewal process. See the Device and IoT Identity Guide and the OT Product Procurement Guide.

Segmentation and filtering

  • Zone the servers: place Modbus devices in zones with conduits that admit TCP 502 only from named clients. See the OT Network Segmentation, Purdue Model and IEC 62443 Zones and Conduits Guide.
  • Use protocol-aware enforcement at high-consequence conduits: industrial firewalls and deep packet inspection modules can allow reads from the historian, writes from the SCADA server only, and block programming and diagnostics codes except from engineering hosts.
  • Restrict by address range: where the enforcement point supports it, permit writes only to the register ranges the process uses.
  • Protect gateways: Modbus TCP to RTU gateways expose whole serial buses; restrict which unit IDs each client may address and keep gateway management interfaces on a separate network.
  • Remote access through a broker: no port forwarding of 502 or 802; vendors and engineers connect through a recorded, MFA-protected broker. See the OT Remote Access Guide.
  • Device-side settings: many PLCs and gateways offer an IP allowlist for Modbus clients, a read-only Modbus mode, or the option to disable the Modbus server entirely when unused; use them as a second layer.

Monitoring and detection

Modbus is easy to monitor because it is unencrypted and regular. Use passive sensors on SPAN ports or taps and build a baseline before alerting.

  • Zeek: the Modbus analyzer is registered on 502/tcp and writes modbus.log with ts, uid, connection id, transaction id (tid), unit, func, pdu_type and exception fields. That is enough to baseline who talks to whom, with which function codes. See the Zeek Network Monitoring Guide.
  • Suricata: the modbus rule keyword matches on function (including categories such as public, user and reserved, and negation), on access (read or write, by table such as coils or holding, with address and value conditions) and on unit identifier. Rules can, for example, alert on any write to holding register ranges from a host other than the SCADA server, or on any reserved function code. Suricata documentation notes that Modbus addresses in rules start at 1. See the Suricata IDS Guide.
  • Commercial OT monitoring: protocol-aware platforms add asset identification from Modbus device identification responses and process-variable baselines.
DetectionLogicPriority
New Modbus clientSource IP not in baseline opens TCP 502 or 802High
Write from a read-only clientFunction 5, 6, 15, 16, 22 or 23 from historian, HMI view station or unknown hostHigh
Programming or firmware codeVendor programming or firmware replacement codes outside a change windowHigh
Diagnostics useFunction 8 from any non-maintenance hostMedium
Register map scanningBurst of exceptions or sequential reads across wide address rangesMedium
Inbound internet trafficExternal source to TCP 502 or 802 at any boundaryCritical

How to implement

  1. Inventory: passively capture Modbus traffic for at least one full operating cycle (including shift changes and batch changeovers) and list clients, servers, unit IDs and function codes in use.
  2. Close external exposure: check for TCP 502 and 802 reachable from the internet or from corporate IT, and remove it first, as the five CISA primary OT mitigations recommend for all OT devices.
  3. Segment: move Modbus servers into zones and restrict conduits to the inventoried clients. Apply rules in log-only mode first, compare against the baseline, then enforce during a planned outage with the previous rule set kept for rollback.
  4. Filter function codes: at high-consequence conduits, allow reads broadly and writes only from control masters; block diagnostics, file record and programming codes except from engineering hosts.
  5. Monitor: deploy Zeek or Suricata rules for the six detections above, routed to someone who can contact operations.
  6. Upgrade selectively: require Modbus/TCP Security in new procurement and on links crossing untrusted networks; pilot on one link with certificate renewal tested before expiry becomes a production risk.

Small sites with a handful of devices can often achieve most of the value with an IP allowlist on the device, a single industrial firewall and Zeek on a low-cost sensor. Large estates should standardise a register-range and function code policy per device type and push it through central firewall management.

Framework mapping

Control areaNIST SP 800-53 Rev. 5NIST CSF 2.0MITRE D3FEND
Segmentation and conduitsSC-7 Boundary ProtectionPR.IRD3-NTF Network Traffic Filtering
Function code and address allowlistingAC-3 Access Enforcement, CM-7 Least FunctionalityPR.PSD3-NTF Network Traffic Filtering
Modbus/TCP Security and device certificatesIA-3 Device Identification and Authentication, SC-8, SC-23, SC-12PR.AA, PR.DSNone mapped
Traffic monitoring and baselinesSI-4 System MonitoringDE.CMD3-NTA Network Traffic Analysis
Denial of service resilienceSC-5 Denial-of-service ProtectionPR.IRNone mapped

Common failure patterns

  • Port forwarding for convenience: TCP 502 forwarded through a router for remote monitoring, the exposure pattern behind FrostyGoop.
  • Allowing everything inside the zone: segmentation stops at the zone boundary, so any compromised HMI can write to every PLC.
  • Read-only assumptions: historians and dashboards given full Modbus access because "they only read", leaving a write path from a less protected system.
  • Forgotten gateways: serial gateways with default management passwords and no restriction on unit IDs.
  • Secure variant without certificate operations: Modbus/TCP Security enabled with long-lived self-signed certificates and no renewal plan, then disabled after an expiry outage.
  • Monitoring without a baseline: IDS rules that alert on every write, so alerts are ignored within a week.

Practitioner checklist

  • Confirm no Modbus port (502 or 802) is reachable from the internet or the corporate network.
  • Inventory every Modbus client, server, gateway, unit ID and function code from passive capture.
  • Restrict TCP 502 at zone conduits to named clients and keep a rollback rule set.
  • Allow writes only from control masters; block diagnostics, file record and programming codes elsewhere.
  • Use device-side IP allowlists, read-only modes or disable unused Modbus servers.
  • Protect and restrict serial gateways by unit ID and management access.
  • Deploy Zeek or Suricata detections for new clients, unexpected writes and programming codes.
  • Treat register maps as sensitive engineering documents.
  • Specify Modbus/TCP Security for new devices and untrusted links, with certificate renewal tested.

Standards and references

Related NHI Mgmt Group resources: OT Security Guide · FrostyGoop Modbus Malware Guide · PLC Security Guide · OT Network Security Monitoring Guide · DNP3 Secure Authentication Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.