Skip to content

Security: otfabric/go-profinet

Security

SECURITY.md

Security Policy

Reporting a Vulnerability

Please report vulnerabilities privately: email security@otfabric.io, or open a private advisory on GitHub (the Security tab → Advisories → Report a vulnerability), with a description, steps to reproduce, the affected version and the impact you identified. Do not open a public issue.

We acknowledge reports within 48 hours and aim to fix or mitigate critical issues within 7 days.

Supported Versions

Version Supported
Latest release Yes
Older releases No

Security considerations

PROFINET has no security of its own

PROFINET IO without the security classes 2 and 3 (which go-profinet does not implement) has no authentication, integrity protection or encryption. Anyone with Layer 2 access to a device can rename it, readdress it, reset it, write its records and take control of its outputs; anyone on the path can read and alter the cyclic data. go-profinet does not change that.

  • Run PROFINET on isolated networks; separate them from office networks and the Internet with the zones and conduits of IEC 62443.
  • Treat every host that runs go-profinet with raw Ethernet access as part of the control network.

PROFINET security classes

PI defines three security classes (PI white paper "PROFINET Protocol Security", V1.05, 2019): class 1 "robustness" (SNMP default communities can be changed, DCP can be set to read-only, GSD files are signed), class 2 integrity and authenticity of the communication with cryptography, class 3 confidentiality as well. Their normative definitions (PI's Security Class 1 guideline, PI order 7.312; the PROFINET security specifications; the GSDX container specification, PI order 2.752) are for PI members and were not read.

go-profinet does not implement Security Class 1, nor any other security class, and claims none. Since v0.28.0 it implements two Security Class 1 capabilities, from public, independent evidence (Wireshark's PNIO dissector and the p-net stack), each opt-in or requested by the controller. The third part of class 1, signed GSD files, is not implemented, so no device built with go-profinet is a Security Class 1 device because of them:

Security Class 1 capability go-profinet Not covered
DCP Set refused while an AR runs: RejectDCPsetRequests, bit 27 of ARProperties (pnio.ARPropRejectDCPSet) the device refuses every DCP Set block but Signal while an AR whose Connect set the bit exists (dcp.SetGuard, device.ARInfo.RejectDCPSet, audited as dcp.AuditRejectedByAR); the controller sets the bit with controller.DeviceConfig.RejectDCPSet whatever PI's guideline adds beyond p-net's behaviour; the bit is a claim of whoever sends the Connect
SNMP access set by the controller: the records CIMSNMPAdjust (0x8200) and CIMSNMPReal (0x8201) device.SNMPConfig.Adjustable: a controller disables the agent or replaces its communities, kept in Config.Store, reset by ResetToFactory; pnio.CIMSNMPAdjust, pnio.CIMSNMPReal SNMP writes (the agent stays read-only), SNMPv3; a community still travels in clear text
Signed GSD files (GSDX) not implemented the GSDX container specification and PI's signing service are members-only: gsdml/gsdx reads the public OPC layer and signature metadata and verifies nothing
SNMP disabled by default, or any other default class 1 asks for not implemented the defaults are the application's (device.Config.SNMP is nil unless set)

Interoperability interpretations, pending PI's normative text. Two behaviours of these capabilities follow p-net 67301c5fc7, the only implementation found, and not PI's guideline; they are provisional and may change when the normative text is available:

  • An empty community name in a CIMSNMPAdjust write keeps the name in force (p-net src/device/pf_cim.c: "Zero length is allowed (means keep existing name)"). This applies to the two community names of CIMSNMPAdjust only. It is not a rule of go-profinet for other names: a DCP Set of an empty NameOfStation still sets an empty name, and ResetToFactory still returns the SNMP access to SNMPConfig.Community.
  • The DCP transaction brackets, Control/Start and Control/Stop, are refused while RejectDCPsetRequests is in force (p-net src/common/pf_dcp.c: every Set block but Signal). This is about DCP Set transaction control only: Start and Stop open and close a DCP Set transaction of one tool, and refusing them changes nothing else. They have nothing to do with the controller's lifecycle, the AR, the application's run state or any safety stop, none of which DCP controls. A refused bracket has no effect: it neither holds the device against other tools nor ends another tool's transaction (since v0.28.1; v0.28.0 still opened a transaction on a refused Start, for 3 s).

Confirmed behaviour. The SNMP agent is read-only and stays so (snmp.Agent refuses every SetRequest). With the access a controller sets to read-write (pnio.SNMPReadWrite), the agent accepts both the read-only and the read-write community, and both for reads only; an access with a read-write community never makes the agent writable.

Neither capability authenticates anybody: a Connect that sets RejectDCPsetRequests and a write of CIMSNMPAdjust come from whoever can reach the device. They reduce what an accident or a careless tool can change while a controller runs; they are not protection against an attacker on the network. Classes 2 and 3 need specifications go-profinet does not have (see docs/PI-MEMBERSHIP.md).

Privileges

Raw Ethernet needs CAP_NET_RAW (Linux), access to /dev/bpf* (macOS) or Npcap (Windows). Grant the capability to the program, not root to the user; do not grant it on shared hosts. The virtual network (vnet) needs none.

Hardening of the implementation

  • Every decoder of network input bounds counts and lengths before it allocates, rejects trailing or inconsistent data and is fuzzed (make fuzz); malformed input is dropped and counted, never a panic.
  • Resources are bounded: RPC messages (64 KiB, 256 fragments), RPC activities and handler workers, ARs per device, subscription queues, alarm windows, GSDML documents (64 MiB and 1 048 576 elements; encoding/xml fetches no DTD and expands no entity beyond the predefined five, and gsdml.Parse refuses an internal DTD subset, whose declarations it cannot apply) and the parameter records a model gets from one (16 MiB, gsdml.MaxModelRecordOctets). A Connect for an ARUUID whose Connect still runs is refused; the RPC client takes an answer only from the host it called.
  • Fixed bounds on what files and the network can make the library keep or compute (each is a constant in the package named; none is configurable unless said):
    • gsdml: a document has at most 1 048 576 elements (start tags, counted before decoding; profinet.ErrResourceExhausted beyond). A parsed document of that size occupies up to about 300 MiB. Check lists at most 16 384 issues per severity plus one that counts the rest (rule limit); its work follows the size of the document, not the ranges in its slot and reduction ratio lists. ToModel charges MaxModelRecordOctets for the module types and again for the modules as plugged, once per slot, and refuses a module or device access point with more than 1440 submodules.
    • model: Validate refuses more than 1440 plugged submodules and more than 16 MiB of parameter records in them (profinet.ErrInvalidConfig), before any work per submodule, so device.New and Controller.AddDevice never clone or write more.
    • gsdml/gsdx: Open decodes at most 65 536 XML elements into the package model (16 per ZIP entry where MaxParts allows more entries than the default), lists at most 16 384 issues plus a count, and parses a certificate part once.
    • dcp: an Identify without IdentifyOptions.Max collects at most 4096 stations and ends with profinet.ErrResourceExhausted when one more answers; Max replaces the bound.
    • netstack: the ARP table holds at most 1024 addresses; a full table learns a new address only from traffic for the stack itself, in place of the entry used longest ago.
    • pnio: the MultipleBlockHeaders of a PDRealData record nest at most four deep; deeper records are refused as malformed.
    • snmp: a request reads the LLDP neighbors once, whatever its kind and number of variable bindings.
  • Concurrency is race-tested (go test -race) and chaos-tested with seeded loss, duplication, corruption, reordering and delay.
  • The DCP responder answers every requester. While one requester holds an open Set transaction (Control/Start Transaction without End Transaction, at most 3 s after its last Set), the Sets of other requesters are answered with BlockError "resource error" and change nothing. It validates station names.
  • Opt-in DCP restrictions (dcp.Policy, device.Config.DCPPolicy): a read-only mode that refuses every Set that changes the device, rate limits per source MAC address for Identify responses and Set requests in a fixed-size table, and audit events (source, block, outcome) for every Set, ResetToFactory and refused request. They limit accidents and floods; they authenticate nobody (a source address can be forged) and are not a PROFINET security class.

Decision points of the application

An IO-Device lets the application refuse what a peer asks before the device carries it out, beside the protocol's own checks (policy 1.7, SEC-R02). Both decision points are supplemental: they run after the checks the device makes itself (a malformed request, a slot the device does not have, a submodule another controller owns, the read-only mode, a rate limit) and can only refuse what those allow. Neither authenticates anybody; see the identities below.

device.Config.Authorize dcp.Policy.Authorize (device.Config.DCPPolicy)
Classes Connect (IOCAR and IOSAR), Read and ReadImplicit, Write (each item of a WriteMultiple), Control PrmBegin, PrmEnd and PrmEnd plug each Set block: name, IP suite, DHCP options, Signal, ResetToFactory, FactoryReset, unknown blocks
Every path every record the device would serve, I&M, PDev, MRP, diagnosis and model records included: the device asks before it reads or writes its own state, and before Handler.ReadRecord and Handler.WriteRecord every block that passed the read-only mode, before the station (or Config.ApplyIP, Config.SetDHCP, Handler) sees it
Not asked Release (it ends what the Connect granted); a request the device refuses itself Identify, Get and Hello (answered to whoever asks, as DCP defines); the transaction brackets Control/Start and Control/Stop, which change nothing
Goroutine the RPC worker of the request; up to 8 run at once (rpc.ServerOptions.Workers) the responder's goroutine: no other DCP request is answered while it runs
Held while it runs the worker; a Connect holds no reservation, no frame ID and nothing of an AR it would replace the responder
Context the RPC call's: 30 s (rpc.ServerOptions.HandlerTimeout) and ended by Device.Close; a Connect's also by its CM activity timeout (ActivityTimeoutFactor × 100 ms) the responder's: ended by Close, no deadline
A late allow after the context ended, or after the AR of a Read, Write or Control closed: refused with device.ErrLateDecision after the responder closed: refused
Refusal a *pnio.StatusError selects the status; otherwise a Read or Write is answered "access denied" (PNIORW 0xB6) and a Connect or Control CMRPC "state conflict", the status the device already answers a Connect it cannot take now a *dcp.RefusalError selects the BlockError; otherwise "SET not possible by local reasons"
Panics or runtime.Goexit refuses (device.ErrDecisionFailed); the worker goes on refuses; the responder goes on
Input device.Request, a description: Data is a copy dcp.SetRequest, a description: Data is a copy
Reported device.Config.Events, EventDecided dcp.Policy.Audit, AuditDenied

What a decision grants. A Connect grants a lasting relationship, the AR: its cyclic data for the submodules it owns, and its alarms. Each Read, Write and Control of the AR is asked again. The grant ends with a Release, an abort by either side, a rerun, a DCP Set that changes the name or a ResetToFactory, Device.Close, or Device.AbortAR, which is how the application ends a grant it gave. The device asks nothing per cyclic frame: a callback per frame would cost time on the cyclic goroutines and could miss the watchdog. A DCP decision grants one block.

A Connect that replaces an AR. A Connect for an AR UUID the device holds, or a new IOCAR from the same controller, replaces the old AR (rerun). Request.Replaces names it; the decision runs before anything of it is touched, and a refused rerun leaves it as it was. If the AR to replace changed while the decision ran, the Connect is refused.

Close while a decision runs. Device.Close waits for the RPC workers, so it returns only after a blocking decision has returned; the decision's context ends at once, and an allow after that refuses. A decision may call Device.AbortAR and the methods that read the device's state; it must not call Close.

Identities. PROFINET without security class 2 or 3 authenticates nobody. Request.Source is a network address as the IP stack reports it; the AR UUID, session key, initiator MAC address, initiator object and station name of a Connect, and the source MAC address of a DCP request, are claimed by the peer. A decision on them is a decision on a claim. An application that wants a Read or Write only from the controller that made the Connect compares Request.Source with Request.AR.ControllerAddr (examples/observability does).

Application callbacks. Every method of a configured Handler, Metrics, Config.Events, Config.ApplyIP and Config.SetDHCP on the device, the Set methods of a dcp.Station and Policy.Audit on the responder, and OnState, OnAlarm and Metrics on the controller run on a goroutine of their own while the library's goroutine waits for them: one that panics or calls runtime.Goexit is logged, the library goroutine goes on, and a callback that decides refuses. The same guard runs the Refused callbacks of the allow-lists below, and every rpc.Handler of an rpc.Server: a handler of an application's own interface that panics or calls runtime.Goexit is answered with a FAULT (StatusFaultUnspec), which grants nothing, whatever it had built; the failure is logged and counted (ServerStats.HandlerFailures), the activity is answered and free for its next call, and the worker goes on. What the handler changed before it failed stays changed.

What a controller may send

The requester side has an allow-list of the application's: a local, opt-in restriction of what the library sends, checked before anything is sent (policy 1.7, SEC-R02). It is not a decision about a peer and authenticates nobody; it keeps a component (a monitoring controller, an engineering tool) from sending what it should not, whatever its own code or its user asks.

controller.Allowlist (controller.Config.Allowed, controller.RecordClientOptions.Allowed) dcp.SetAllowlist (dcp.ClientOptions.Allowed)
Classes OpConnect (IOCAR, device access AR), OpRead, OpReadImplicit, OpWrite (each item of a WriteMultiple), OpPrmBegin, OpPrmEnd (and PrmEnd plug), OpOtherControl; on the controller also OpDCPSet each Set block
Narrowed by ReadIndexes and WriteIndexes (record index ranges); DCPBlocks Blocks
Not covered Release (it ends a grant; refusing it would only keep the device's resources until its timeout); DCP Identify and Get; alarm acknowledgements, the answer to ApplicationReady and the cyclic outputs, which belong to an AR the Connect established; calls made directly on Controller.RPC() Identify and Get, which read; the transaction brackets Control/Start and Control/Stop
Refusal *controller.NotAllowedError (profinet.ErrNotAllowed); nothing is sent, no Metrics.OnRecord *dcp.NotAllowedError (profinet.ErrNotAllowed); one block outside it refuses the whole Set
Reported Allowlist.Refused (controller.Refusal) and the entry controller: not allowed SetAllowlist.Refused (dcp.SetRefusal) and the entry dcp: set not allowed
Default nil: everything is sent, as before nil: every Set

The controller checks the startup of a device in AddDevice (Connect, the parameter writes, PrmEnd, and the DCP Set of the IP suite with AssignIP) and every step of Reparameterize before it sends the first: a device it may not start is not added (ErrInvalidConfig and ErrNotAllowed), so its lifecycle never retries what it may not send, and a re-parameterization is never left after PrmBegin. Both allow-lists are copied when the controller, record client or requester is made.

Changing devices

dcp.Client.Set, SetName, SetIP, ResetToFactory, RecordClient.Write and the outputs of a controller change real equipment; their documentation says so. Only call them on an explicit request of the user.

Not certified

go-profinet is not certified by PROFIBUS & PROFINET International and is not a safety component.

Reference implementations

The interop suite runs GPL-licensed reference implementations in containers. The p-net tree used is older than its v1.0.2 security fixes: run the interop suite only on isolated Docker networks.

Learn more about advisories related to otfabric/go-profinet in the GitHub Advisory Database