Modbus TCP Security: Risk Calculator & Firewall Diagram

Share:
Cybersecurity
Modbus TCP Security: Why Port 502 Has No Protection and How to Secure It with Zones, Whitelists and TLS

Any device that can reach port 502 can read or write a Modbus controller, because the protocol never asks who is talking. Protection comes from the network: zones, function code filters, monitoring and, on newer devices, TLS on port 802.

Port 502 and 802 Function code whitelist IEC 62443 zones Risk score calculator Troubleshooting table

Modbus TCP was built for trusted plant networks, so it carries no password and no encryption. Attackers can abuse that, and the fixes that work are segmentation, Modbus aware firewalls, read only gateways and TLS.

Hello everyone, today we are going to learn modbus tcp security, from why port 502 is open by design to the firewall rules, zones and TLS that protect it.
modbus tcp security
Quick Answer

What is Modbus TCP security and why does port 502 need protection?

Modbus TCP security is the set of controls that protect Modbus traffic on TCP port 502, which has no authentication, no encryption and no integrity check. Any host that reaches a PLC can send function code 6 or 16 and change a setpoint. For example, a laptop on the same switch can rewrite holding register 40001 in one packet, so you add zones, a function code whitelist, monitoring and TLS on port 802.

What Is Modbus TCP Security?

Modbus TCP security means protecting Modbus messages on TCP port 502, a protocol that trusts every client and sends every value in clear text. Because the protocol itself has no login, protection comes from the network around it and, where devices support it, from the newer secure Modbus protocol on port 802.

502Plain Modbus TCP port, no login
802Modbus Security port with TLS
5, 6, 15, 16Write codes to filter
1979Year Modicon released Modbus
Do You Know?

Modbus TCP adds only a 7 byte MBAP header in front of the old serial PDU: transaction ID, protocol ID, length and unit ID. None of these fields identifies a user or carries a signature.

Advertisement

Is Modbus TCP Secure by Default?

No, plain Modbus TCP is not secure by default, because the server answers any well formed request from any IP address. The SANS Institute describes Modbus as insecure by design, since confidentiality and integrity were not part of the original requirements.

Security propertyPlain Modbus TCP (502)Modbus Security (802)
AuthenticationNone, any client acceptedMutual X.509v3 certificates
EncryptionNone, values in clear textTLS 1.2 or newer
Integrity checkNone at Modbus levelTLS record protection
AuthorisationNoneRole carried in certificate
Replay protectionNoneProvided by TLS session
Device supportAlmost every deviceNewer PLCs and gateways only

On older devices, every protection in the right column has to come from outside the device, and that is the core gap in modbus tcp security. That is why the function code list matters as much as the IP address when you write firewall rules.

Quick Tip

Run a quick Wireshark capture on a mirror port and filter on tcp.port == 502. If you can read register values in the packet details, so can anyone else on that segment.

What Attacks Target Modbus TCP?

The main attacks are unauthorised writes, reconnaissance scans, replay and man in the middle changes, and simple flooding that stalls a controller. Each one works because the protocol accepts a request without asking who sent it.

Unauthorised write

Codes 5, 6, 15 and 16 force coils or change registers, so a pump can start.

Best for: Testing write whitelists
Write
Reconnaissance

Scanners sweep port 502 and read code 43 device identification to map the plant.

Best for: Testing IDS alerts
Recon
Replay and MITM

A captured write is resent later, or ARP spoofing changes values in transit.

Best for: Testing switch hardening
MITM
Denial of service

Request floods fill the small PLC TCP stack so real polls time out.

Best for: Testing rate limits
DoS

Dragos reported that the FrostyGoop malware used Modbus TCP on port 502 in January 2024 against a district heating company in Ukraine. More than 600 apartment buildings lost central heating for about two days, and the malware supports codes 3, 6 and 16.

Myth: Modbus devices are safe because attackers do not understand industrial protocols.
Fact: Free tools and public scripts can read and write Modbus registers, and FrostyGoop showed this in a real utility.
Myth: A VLAN alone makes Modbus traffic private.
Fact: A VLAN separates broadcast domains, but any host inside it still reaches port 502 unless a firewall filters it.
Myth: Encryption is the first fix to apply.
Fact: Most field devices cannot run TLS, so segmentation and function code filtering usually come first.

How Does Modbus TCP Security Work in a Plant Network?

Modbus TCP security works in layers: zones keep untrusted hosts away from port 502, conduits carry only the traffic you approve, and a Modbus aware firewall checks each function code. TLS on port 802 and monitoring sit on top where the devices support them.

The diagram below follows the Purdue model levels and the IEC 62443 zones and conduits approach, with one firewall at each boundary.

modbus tcp security zones and conduits diagram with Modbus aware firewall
Diagram by Instrumentation Blog showing enterprise, DMZ, control and field zones with firewall conduits and a Modbus aware firewall in front of the PLC, RTU and meter.

Good OT network segmentation is the base layer, and it should include managed industrial network switches with port security. On top of that, a deep packet inspection firewall reads the Modbus header and can block a write even when the IP address is allowed.

Where business users only need data, a data diode or a read only protocol gateway removes the write path altogether.

Do You Know?

IEC 62443 3 3 defines security levels SL 1 to SL 4 for zones. A zone holding Modbus controllers that drive pumps or burners usually needs a higher target level than an office network.

Advertisement

What Port Does Modbus TCP Use, and What Is Port 802?

Plain Modbus TCP uses TCP port 502, while Modbus/TCP Security uses TCP port 802, which IANA assigned to the secure version. The secure version keeps the same Modbus frame and wraps it in TLS.

The Modbus Organization specification requires TLS 1.2 or better with no fallback to older versions, plus mutual client and server authentication with X.509v3 certificates.

Authorisation rides inside the certificate as a role, using the Modbus.org OID 1.3.6.1.4.1.50316.802.1. The server maps that role to allowed function codes, so an operator role can read while only an engineer role may write.

PDF
Modbus/TCP Security Protocol Specification
Modbus Organization, version 36, July 2021, covering TLS, port 802, certificates and roles

How to Secure Modbus TCP Step by Step

To secure Modbus TCP, list every device, cut the network into zones, allow only known masters, whitelist function codes, monitor writes and move to TLS where the hardware supports it. The steps below follow that order because each one makes the next easier.

1
Build an asset list
Record each Modbus server, its IP, unit ID and masters.
2
Define zones
Group devices by risk, then draw the conduits.
3
Lock the conduits
Allow port 502 only from named masters.
4
Whitelist codes
Allow read codes 1 to 4 for HMIs and permit 5, 6, 15 and 16 only from the engineering workstation.
5
Limit register ranges
Allow writes only to expected setpoint registers.
6
Monitor and alert
Alert the control room on new writers or codes.

An OT asset inventory is the first step, because you cannot write a whitelist for devices you do not know. Next, plan your IP addressing and subnets so each zone sits on its own range.

An OT intrusion detection system then watches for writes that slip past the rules, and PLC remote access security covers vendor sessions.

Benefits of a function code whitelist
  • Blocks writes from read only clients
  • Works with old PLCs that cannot run TLS
  • Logs every denied request for audits
  • Needs no change inside the controller
Limits to keep in mind
  • Cannot stop a hijacked engineering workstation
  • Gives no encryption, so values remain readable
  • Needs updates when the process changes
  • Adds a device that must itself be patched

Modbus TCP Risk Score Calculator

This calculator gives a quick screening score for one Modbus link by multiplying likelihood by impact on a 5 by 5 scale. It is a teaching tool, not a full IEC 62443 risk assessment.

Exposure runs from 1 (isolated cell) to 5 (reachable from the office network). W is the number of write codes (5, 6, 15, 16) reachable from untrusted hosts, and controls counts segmentation, IDS monitoring, TLS on port 802 and a read only gateway.

Modbus TCP Risk Score Calculator
Screening risk score
Likelihood 5 x Impact 4 = Risk 20 of 25 (High)
Solved example
Before: Exposure 4, W 4, Controls 1, Impact 4
L = 4 + round up (4 ÷ 2) minus 1 = 5
Risk = 5 × 4 = 20 of 25, High
After whitelist and IDS: W 0, Controls 2
L = 4 + 0 minus 2 = 2, Risk = 2 × 4 = 8, Medium

Taking all four write codes away from untrusted hosts and adding IDS as a second control drops the score from 20 to 8.

modbus risk score formula with before and after hardening example
Diagram by Instrumentation Blog showing the Modbus risk score formula and the solved example falling from 20 High to 8 Medium after hardening.
Quick Tip

Keep the exposure value honest. If a contractor laptop can plug into the control zone switch, treat that zone as exposure 4 even when it has no internet route.

Advertisement

Modbus TCP Security Troubleshooting

Most problems after hardening come from rules that are too tight, wrong unit IDs through gateways, or TLS certificate errors on port 802. These are the symptoms we usually see during commissioning, with what to check first.

SymptomLikely causeWhat to check
HMI shows bad quality after firewall installRead code or register range not allowedFirewall deny log for code 3 or 4
Setpoint write fails, reads workWrite code allowed only from EWSSource IP of the write
Gateway devices time outUnit ID not in ruleUnit ID per serial slave
TLS session on 802 failsExpired or untrusted certificateCertificate dates and CA chain
Write allowed but rejected by PLCRole lacks write rightsRole mapping in the server

When the HMI goes bad quality, check the firewall log before you touch the PLC, because the PLC is usually fine. Our Modbus RTU troubleshooting guide helps when the problem sits on the serial side of a gateway.

Modbus aware firewall decision flowchart for port, client IP and write codes
Diagram by Instrumentation Blog showing the decision path a Modbus aware firewall follows for port, client IP, function code and write permission before it allows or drops a packet.
  • Every Modbus server listed with IP, unit ID, firmware and owner
  • No route from the office network to TCP port 502
  • Read codes allowed only from named HMIs and historians
  • Write codes 5, 6, 15 and 16 allowed only from the engineering workstation
  • TLS on port 802 planned for new PLCs and gateways

For a full audit, work through our SCADA security checklist and record each gap with an owner.

Which Modbus Security Controls Should You Choose?

Choose controls by what your devices can do: old PLCs get segmentation and a Modbus aware firewall, new PLCs get TLS on port 802, and data users get a read only path. Most plants end up with a mix of all three.

ControlProtects againstWorks on old devicesEffort
Zones and conduitsRandom hosts reaching 502YesMedium
Function code whitelistUnauthorised writesYesMedium
Read only gateway or diodeAny write from IT sideYesLow to medium
Modbus Security on 802Sniffing, spoofing, replayNo, needs supportHigh
IDS monitoringUnnoticed new writersYesMedium

If you are building a new system, ask vendors whether the PLC supports Modbus Security on port 802 and certificate roles. The S4x18 talk below gives the background on how the Modbus Organization designed it.

Also read how zero trust for OT networks and PLC cybersecurity standards extend these ideas across the whole plant. An ICS incident response plan then tells your team what to do if a bad write gets through.

Modbus TCP Security FAQ

Is Modbus TCP secure enough to use on a plant network today?

Plain Modbus TCP is safe enough only inside a well segmented zone with a Modbus aware firewall and monitoring. On its own it has no login, no encryption and no integrity check.

So treat port 502 as trusted only for the named masters that need it.

What is the difference between Modbus TCP and Modbus TCP Security?

Modbus TCP runs on port 502 with no protection, while Modbus/TCP Security runs on port 802 inside TLS 1.2 or newer. The secure version adds mutual X.509v3 certificate checks and roles.

The Modbus frame itself stays the same in both versions.

Which Modbus function codes should a firewall block by default?

Block write codes 5, 6, 15 and 16 from every host except the engineering workstation. Also block code 8 diagnostics and code 43 device identification unless a tool really needs them.

Allow read codes 1 to 4 only from named HMIs and historians.

How do I calculate a simple Modbus link risk score step by step?

Add exposure and half the open write codes rounded up, subtract controls, and keep the result from 1 to 5. Multiply that likelihood by impact.

With exposure 4, four write codes, one control and impact 4, you get 5 times 4, which is 20 out of 25.

Can a VLAN alone protect Modbus TCP devices from attacks?

No, a VLAN only separates broadcast traffic, and every host inside it can still reach port 502. You need a firewall between VLANs that filters by IP and function code.

Add port security on switches so a stray laptop cannot join the control VLAN.

What is the most common mistake when securing Modbus TCP networks?

The most common mistake is switching a new firewall to blocking mode without learning normal traffic first. Weekly recipe writes or rare maintenance reads then get blocked and stop the process.

Run alert mode for one full production cycle before you enforce.

Which Modbus security method is best for old PLCs without TLS?

For old PLCs the best mix is a separate zone, a Modbus aware firewall with a code whitelist, and IDS monitoring. A read only gateway serves business users without any write path.

Plan TLS on port 802 at the next hardware upgrade.

Advertisement

Related Articles

External References

What We Learn Today

  • Plain Modbus on port 502 trusts every client, so any host that reaches a PLC can write coils and registers with one request.
  • Good modbus tcp security starts with an asset list, IEC 62443 zones and conduits, and a firewall that whitelists function codes per master.
  • Modbus/TCP Security on port 802 adds TLS 1.2 or newer, mutual X.509v3 certificates and roles, but it needs support inside the PLC or gateway.
I hope you like above blog. There is no cost associated in sharing the article in your social media. Thanks for reading!! Happy Learning!!
Sunayana Gadepatil, author at Instrumentation Blog
Author · instrumentationblog.in
Ms. Sunayana Gadepatil is an instrumentation professional, technical writer, and the author behind Instrumentation Blog. With a strong interest in industrial instrumentation, process measurement, and automation, she specializes in simplifying complex technical concepts into clear, practical, and easy to understand insights. Through her articles, Ms. Sunayana shares valuable knowledge on flow, pressure, level, temperature, control systems, and industrial automation for engineers, students, technicians, and industry professionals.
Technically reviewed on

Leave a Reply

Your email address will not be published. Required fields are marked *

Support free learning

Help keep every guide, calculator and tool 100% free

Hosting, software and hours of research go into every article. Even a small contribution helps us publish more in-depth guides for students, technicians and engineers.

  • No paywalls
  • No sign up
  • Free for everyone