Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Function Code
Cyber Security

Function Code

← Back to Glossary
By NHI Mgmt Group Updated November 26, 2026 Domain: Cyber Security

A function code is a field in an industrial protocol message, such as Modbus, that tells a device which operation to perform, for example reading or writing a value. Attackers send unauthorised write or diagnostic function codes to change process state. Defenders use protocol-aware inspection to permit only expected function codes and alert on writes from unapproved sources.

What a function code does in industrial protocols

A function code is the instruction byte or field that tells an industrial device what operation to perform, such as reading coils, writing registers, or requesting diagnostics. In protocols like Modbus, it is not just metadata, it is the command selector that determines whether a message is harmless, state-changing, or potentially disruptive if abused.

The security significance comes from that operational authority. A valid-looking packet with the wrong function code can cause a controller to alter outputs, change setpoints, or reveal information that should not be exposed. In OT environments, the difference between “read” and “write” is often the difference between normal supervision and process manipulation.

How function codes shape protocol trust

Industrial protocols are often designed around predictable command sets, so a function code becomes a compact trust decision for the receiver. The device, gateway, or inspection layer uses it to decide whether the request is allowed, whether it changes state, and whether the message should be forwarded, denied, or logged.

That makes function codes central to protocol-aware inspection. If defenders can distinguish expected read-only traffic from write or diagnostic operations, they can enforce allowlists and reduce the chance that a malicious or misrouted packet reaches a live control path. This is especially important where legacy systems assume that anything speaking the protocol is legitimate.

Attack and detection implications

Abuse usually starts with function codes that perform writes, diagnostics, or other privileged actions. An attacker who can reach the industrial protocol surface may send those requests to modify process state, disturb availability, or prepare follow-on manipulation. For that reason, defenders often pair protocol parsing with source validation so a write from an unapproved host stands out immediately.

Detection is strongest when the content of the message is interpreted in context, not just by port or session. The same transport can carry benign polling and dangerous writes, so monitoring needs to understand which function codes normally occur, which endpoints are allowed to issue them, and when a new command pattern suggests misuse. Modbus TCP and Modbus Security Guide and D3-APCA Application Protocol Command Analysis both focus on that protocol-command perspective.

Why allowlisting matters for industrial control

Function codes are most useful as a control point when they are treated as policy, not just parsing detail. In a well-managed OT environment, defenders define which devices may issue which operations, then filter out unexpected writes, diagnostics, or vendor-specific commands before they reach critical assets. That is the practical value of function-code inspection: it turns protocol structure into an enforcement boundary.

Because many industrial messages are short and repetitive, a single unexpected function code can be highly meaningful. A device that normally responds to reads may be forced into a changed state by an unexpected write, and a diagnostic command can expose timing or configuration information that helps an attacker plan the next step. The same logic also supports deeper register-level control, which is why D3-OVAR OT Variable Access Restriction is a useful companion concept.

What to watch for in practice

Function code abuse often shows up as a small set of anomalies rather than a noisy flood. Those include writes from engineering stations that should only read, diagnostics from unrecognised sources, and commands that target registers or objects outside the normal process cycle. In protocols such as Modbus, even a single unexpected write can be enough to alter equipment behaviour or conceal a larger compromise.

That is why segmentation, deep packet inspection, and source-aware rules matter together. If traffic is already confined to approved zones, and the protocol inspection layer understands which function codes belong to each role, defenders can catch misuse early and keep the control system’s command surface narrow. For a protocol-specific defensive reference, Modbus TCP and Modbus Security Guide covers function-code filtering, threat patterns, and monitoring approaches in more depth.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK addresses the attack and risk surface, while CIS Controls v8, NIST CSF 2.0 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
MITRE ATT&CKT0827 — Modify Controller TaskingIndustrial function-code abuse can change PLC or controller behavior.
T0834 — Native APIOT command abuse often drives direct device or system-function execution.
Recommendation — Map unexpected write commands to T0827 and alert on unauthorized controller tasking. Correlate protocol-command anomalies with T0834-style execution paths in OT detection.
CIS Controls v8CIS-13 — Network Monitoring and DefenseProtocol-aware inspection and allowlisting are network-defense controls for industrial traffic.
Recommendation — Use CIS-13 to inspect industrial protocol commands and block unexpected write operations.
NIST CSF 2.0PR.DS-01 — Data-at-Rest Is ProtectedProtocol command filtering protects process data and command integrity in transit.
Recommendation — Apply PR.DS-01 to preserve command integrity and prevent unauthorized process changes.
NIST SP 800-53 Rev 5SC-7 — Boundary ProtectionIndustrial command filtering depends on controlling protocol flows at trust boundaries.
Recommendation — Enforce SC-7 at OT boundaries to restrict unsafe function codes and unexpected sources.

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
Reviewed and updated by the NHIMG editorial team on November 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org