IMDHMIControls LibraryShop main store

Explainer

Can a Modbus write change PLC outputs?

Industrial networks Published 7 min read

Short answer

Yes, but not by outrunning the scan. On a Modicon CPU the communication interface reaches data memory only between scans, so a write is applied whole and the next scan either consumes it or overwrites it. The real exposure is that Modbus TCP authenticates nothing: any host that can reach the CPU can write an unprotected holding register your logic unpacks into outputs, so pack status into read-only words, keep commands in a separate writable range, and enforce write protection with an IP access control list.

On this page
  1. A write cannot land mid-scan
  2. What the logic does with the word decides the harm
  3. Worked example: one scan of bad data or a lasting command
  4. 40001, 400001 and the %MW offset
  5. Restructure the map: status out, commands in
  6. Write protection and the access control list
  7. Zone the network around the CPU
  8. The decision, case by case
  9. Questions asked

Yes, and the write never has to outrun the scan to do it. On a Modicon CPU such as an M580, the communication interface can reach data memory only between two scans, so a Modbus write is applied whole at a scan boundary and the next scan either consumes it or overwrites it. If your program moves that word into the output tags, the written value becomes the output state. If the program only packs output tags into the word for SCADA to read, the write is gone within one scan and no output moves. The exposure is authorization, not speed: Modbus TCP authenticates nothing, so any host able to open a connection to the CPU can write any unprotected holding register with function code 06 or 16. The fix is a restructured register map, write protection on status words, and an access list naming who may connect.

A write cannot land mid-scan #

The scenario you feared — a device writing faster than the scan and catching the CPU mid-execution — is not how a Modicon CPU behaves. Its communication interface touches data memory only in the gap between two scans, so there is no mid-logic instant for a write to strike: the logic sees the old value or the new one, never a half-written word. The worst-case delay from an arriving write to the logic that reacts to it is one scan time, and that number belongs in the controller diagnostics on the target CPU, not in a datasheet.

The principle is wider than one vendor. Siemens documents each S7-1200 cycle as writing the outputs, reading the inputs, executing the user program, and only then handling communications and interrupts, so the program always works on a consistent image. On any of these controllers, write speed is not the attack surface. What matters is what the logic does with the word, and which hosts are allowed to write it.

What the logic does with the word decides the harm #

Read the program before touching any network setting. Find every rung that references the word — take %MW1 mapped to 40001/400001 as the example — and put it in one of four boxes:

Logic pattern One foreign write How long the effect lasts
Output tags packed into the word every scan, SCADA only reads Logic repacks the true tag states on the next scan; SCADA may catch one corrupted status read One scan
Word moved into the output tags by your move function Written bits become output states and field devices switch Until logic or another write changes them
Same word packed from tags and unpacked to outputs Last writer wins, decided by scan position and write timing Non-deterministic
Word used as a setpoint A new setpoint enters the control loop Until an operator or the logic changes it

The pattern in your description — the tags constitute the bits and a move function writes the word back into the device tags — is the third row: one register acting as both status word and command word. That is the row to eliminate.

Worked example: one scan of bad data or a lasting command #

Illustrative numbers; put your own measured values in. Assume the mast-task scan time read from the CPU diagnostics is 18 ms and the SCADA server polls the status word every 1000 ms.

Packed status word: a foreign write survives at most one scan, 18 ms, before the logic overwrites it with the true tag states. SCADA can only see the corrupted value if its poll lands inside that window, and 18 ms ÷ 1000 ms = 0.018, so 1.8% of polls. No output moves. Halving the poll to 500 ms doubles the figure to 18 ÷ 500 = 3.6%, and every additional 1 ms of scan time adds 1 ÷ 1000 = 0.1 percentage points at a 1 s poll.

Unpacked command word: one write of 0x0003 — bits 0 and 1 set — energizes two channels of the 16-channel card on the next scan, and they stay energized until the logic or another write releases them. There is no window and no probability; every such write commands the outputs.

The number to watch in the packed case is the measured scan time. In the unpacked case it is the count of hosts that can reach the CPU's Modbus service.

40001, 400001 and the %MW offset #

40001 and 400001 are five- and six-digit conventions for the same first holding register, not two different words. The %MW number behind them depends on the offset configured in the project, so confirm the mapping in the configuration instead of assuming %MW1. While you consolidate the map, keep each block contiguous and fully mapped: a client whose read steps into an unmapped hole is refused with exception 02, the behavior shown when a Modbus read crosses a gap in the register map.

Restructure the map: status out, commands in #

Your planned change is the right one: write the status of the device tags into a register and let SCADA read that register, instead of building the tags from a register SCADA can also write. Apply it as three blocks:

  • Status words: the logic packs output tags into them every scan, SCADA reads them and extracts bits with BITAND, and nothing on the network ever writes them.
  • Command words: a separate, deliberately writable range. SCADA writes only here, and only bits that mean operator intent.
  • Gating: permissives, interlocks and mode checks in the logic decide whether a command is honored. Outputs are driven by logic alone, never straight from a communications word, and command bits work best as rising edges so one write produces one action.

One limit is absolute: gating command bits in logic is operational control, not a safety function, and emergency stop or guard interlocks belong on a safety-rated path no network write can reach.

If you would rather not map process data into %MW words at all, one integration route is reading M580 I/O in Plant SCADA without mapped memory addresses.

Write protection and the access control list #

Two controller-side controls close most of the gap, both set in the controller or Ethernet module security configuration of the engineering software.

The access control list limits who connects: only listed addresses — the SCADA server, the historian, the engineering station — may open a connection, and a laptop or misconfigured gateway elsewhere on the plant network is refused before any function code is processed. A controller left with all security options disabled, or an older firmware generation without them, accepts every reachable host; that is the state to eliminate.

Holding-register write protection limits what a connection may do: writes to the protected range are refused even from permitted addresses. Protect every status word and any word overlaid on physical output bits, and leave writable only the command range. Protection applies to ranges of the data image, so status and commands sharing one word would force a choice between blocking SCADA commands and exposing the status words — the second reason to split them.

Verify both from an engineering station on the list: send one write to a word in the protected range and read it back unchanged. When a legitimate write does not take, the silence runs the other way too — a SCADA write to a PLC real address can fail silently when the data types do not line up.

Schneider Electric's cybersecurity support pages publish "How can I… Reduce Vulnerability to Cyber Attacks", which walks these measures for PLC and SCADA systems; use it as the checklist when hardening the M580.

Zone the network around the CPU #

Controls on the CPU fail open if every network can reach it. IEC 62443, in plain words, divides a plant into zones of comparable risk and requires every path between zones to be a defined conduit: identified, controlled, and carrying only what it must. For this controller that means the control network is its own zone, only the SCADA server and the engineering station hold a conduit to it, and that conduit carries Modbus on TCP port 502 and nothing else.

Control What it stops Where it is applied
Holding-register write protection Writes to protected registers from any source Controller configuration
IP access control list Connections from addresses not on the list Controller or Ethernet module
Segmentation and VLANs Plant and office traffic reaching the control network Switches and routers
Firewall at the zone boundary Unwanted access to the Modbus service and other controller services Zone edge

The decision, case by case #

  • Status word packed from output tags, SCADA reads only: keep the pattern, put the word inside the write-protected range, and accept at most one scan of corrupted status.
  • Word moved into output tags: do not commission it as built. Commands move to a separate writable range, every bit is gated in logic, and logic alone drives the outputs.
  • Same word packed and unpacked: split it into a status word and a command word before anything else, because non-deterministic control of outputs is the worst state on this list.
  • Setpoint word: writable only inside the command range, with the accepted span clamped in the logic.

Questions asked

Can a Modbus read harm the outputs?

No. Read function codes return data and change nothing; only the write codes 06 and 16 can alter a holding register. That still leaves a leak: an unauthenticated read exposes process values, setpoints and output status to anyone who can reach the service, so the access control list matters for reads as much as for writes.

Does the same exposure exist over Modbus RTU serial?

Yes. The register semantics are identical over Modbus RTU, so a word the logic unpacks into output tags is just as writable from the serial line. The difference is reach: on RTU only devices sharing the two-wire bus can write, while Modbus TCP is reachable from anything with a route to the CPU. Unit addresses on a serial network select a slave; they do not authenticate one.

How do I prove write protection is really refusing writes?

Pick a spare holding register inside the protected range that your logic never writes, note its value, send a single write to it from an engineering station the access list permits, then read it back. An unchanged value proves the protection refused the write. Do not test on a packed status word: the logic rewrites it every scan, which masks the result and makes the test tell you nothing.

Should safety functions ever run through these registers?

No. Emergency stop, guard-door and light-curtain functions belong on a safety-rated controller or relay whose outputs remove drive power directly. A Modbus command path is a non-safe influence by design, and gating its bits with ordinary logic does not change that. Keep the safety chain physically and electrically separate from anything a network write can reach.

Keep reading

  • Troubleshooting

    Reading Modbus TCP from a ControlLogix PLC without a gateway

    Yes — ControlLogix reads Modbus TCP without a gateway card through Rockwell's sample Modbus TCP driver, but only on controller firmware version 20 or later with socket-capable Ethernet hardware such as a 1756-EN2xx module at firmware 5.007 or later. If either side misses the gate, use a standalone EtherNet/IP to Modbus TCP converter. When the driver runs, prove one request against a known-good PC client and match unit ID, start address and count field by field.

    Industrial networks

  • Troubleshooting

    Modbus exception 02 when a read crosses a register map gap

    The exception is correct: a Modbus block read requests consecutive registers, so a span from 754 through 788 includes the undefined 764-767 gap and the meter rejects it with exception 02, illegal data address. Read the 754-763 setup block at startup and after configuration changes, keep continuous reads inside the 768+ measurement area, and publish the last fully accepted set to your calculation logic.

    Industrial networks

  • Troubleshooting

    Fixing a TwinCAT EtherNet/IP slave connection from an Omron PLC

    The CIP1 fault is a Forward Open mismatch: each Omron direction must carry the full serialized TwinCAT assembly, not the process variables alone. With 2 bytes in and 2 bytes out, the 4-byte ConnCtrl on outputs and ConnState on inputs make each direction 6 bytes, and the instances must follow producer and consumer roles. If a capture shows the request and a rejection, read the sizes and instances the originator actually serialized.

    Industrial networks