Skip to content

v0.9.2

Choose a tag to compare

@JeremyTheocharis JeremyTheocharis released this 23 Nov 08:15
· 7 commits to main since this release
b76fd80

Thank you to the contributors in this release: @Chiaf1, @frangelbarrera, @dkb5191, @LaiArturs, @stefan-kolb, @sankalpsthakur, @janbiehl, @barisvelioglu-maestrohub, @dgunther, @abdel084cb, @cpruijsen, @mliebcyb, @istyf, and @skartikey for the reviews.

go get github.com/gopcua/opcua@v0.9.2

gopcua ships both a client and a server. Each item is tagged (client) or (server) for which side it affects, and items that only matter to developers building against the library API carry API. If you consume gopcua through Telegraf or benthos-umh, the plain (client) items are the runtime behavior you get automatically; (server) items only matter if you build a server on gopcua.

No API breaks, and no change to the minimum Go version or to dependencies. Two vulnerabilities are fixed, and one behaviour change affects peers that break the protocol; all three are under Action required. Two more behaviours change in ways your error handling may notice: a single rejected request no longer looks like a lost connection (#904), and out-of-range DateTimes decode to fixed limits (#906, #955); see Fixes.

Action required

  • Fixed a vulnerability that let a malicious peer hang a decoding goroutine forever with a 21-byte Variant whose ArrayDimensions overflow when multiplied (CWE-835, CWE-190). The goroutine spins at full CPU and grows memory until the process is killed. Reachable by a server decoding a client request and by a client decoding a server response. With Sign or SignAndEncrypt only the peer at the other end of the channel can send it; with SecurityMode None, anyone on the network path who can modify the traffic. No session or credentials are needed. High, CVSS 7.5. Affects versions before v0.9.2. Update now. (#953, #954, GHSA-h3g2-2pf7-h77p) (client + server)
  • Fixed a vulnerability that let a malicious peer crash the process with a Variant declaring an array length below -1, which panicked in reflect.MakeSlice with nothing to recover it, or make it allocate gigabytes with a Variant declaring more ArrayDimensions than the message holds (a 10-byte value allocated 8 GB) (CWE-1284, CWE-789). Same reach as above. High, CVSS 7.5. Affects versions before v0.9.2 (the crash since v0.6.1). Update now. Reported and fixed by @abdel084cb (Safetybits); first described publicly by @freedom-winds in #892 and #893. (#936, GHSA-798p-q82c-7h3m) (client + server)
  • The secure channel now rejects a chunk whose SequenceNumber repeats or skips, as OPC 10000-6 §6.7.2.4 requires, and closes the channel with an error that wraps Bad_SecurityChecksFailed and names the received and the expected number. Previously such a chunk was accepted, so a replayed chunk went through. UA-.NETStandard and open62541 enforce the same rule, so conforming servers are unaffected. A server that breaks it, for example one built on gopcua v0.9.1 or older, which could reuse a number around a token renewal, now loses the channel and the client reconnects, on every violation. There is no option to turn the check off. Before upgrading in production, run against your servers and watch for this error; if it repeats against one server, that server breaks the rule, and please open an issue naming it and its firmware. The release candidate ran for 24 hours over SignAndEncrypt against a Siemens S7-1200, a Wago PLC and Kepware with no rejected chunk. (#952, #961) (client + server)

New

  • API opcua.ForceNonEmptyNonce() makes the client send a random 32-byte ClientNonce in OpenSecureChannel under SecurityPolicy None. Some embedded servers close the connection on the null nonce the spec recommends there (#894). The default does not change. (#902) (client)

Improvements

  • API A Variant whose ArrayDimensions do not match its ArrayLength now fails to decode with ua.StatusBadDecodingError, which you can match with errors.Is. It used to return an unexported error. (#954) (client + server)
  • API Prefixed debug loggers, such as the client's client: monitor: output, now write wherever debug.Logger points, so debug.Logger.SetOutput(w) captures all debug output. A nil debug.Logger falls back to stderr. (#900) (client + server)

Fixes

  • Username login works against servers that list several USERNAME token policies with a legacy one first, such as the Siemens S7-1200 G2 and S7-1500. The client took the first policy, Basic128Rsa15, and failed to encrypt the password for server certificates larger than 2048 bits. It now takes the policy that matches the endpoint's security policy, or one that names none, so the password is no longer encrypted under Basic128Rsa15 there. Servers that list one username policy, or the matching one first, see no change. Fixes #912. (#914) (client)
  • A server answering one request with a Bad status, such as Bad_TooManyOperations, Bad_ServiceUnsupported or Bad_UserAccessDenied, no longer makes the client close and reopen the secure channel. The caller gets the status the server sent, where it sometimes got io.EOF, and subscriptions keep running. If your code treated io.EOF from a request as a lost connection, it now sees the status instead. Only a status that says the channel or session is gone triggers a reconnect. (#904) (client)
  • Connecting to a server whose clock is behind the client's, such as a PLC with no battery-backed clock or NTP, no longer times out with unable to find instance for SecureChannelID. (#911) (client)
  • Subscriptions no longer stop delivering data, with the client still Connected and no error, after cancelling the last subscription and subscribing again right away, or when a reconnect finishes while a failed Publish is still in flight. (#947, #957) (client)
  • After a short connection loss in which the server kept the session, the client republishes its subscriptions and recovers the notifications it missed. It used to report Connected with no data flowing and never retry. Fixes #879. (#907) (client)
  • A host name that resolves to several addresses is now tried address by address, so opc.tcp://localhost:4840 reaches a server that listens on IPv4 only when localhost resolves to ::1 first. (#927) (client)
  • Client.Close no longer leaves the reconnect goroutine and its socket behind when a server accepts the TCP connection but never answers Hello. (#919) (client)
  • Aes256_Sha256_RsaPss now connects to the OPC Foundation .NET stack, for example opc-plc, which rejected the OpenSecureChannel with "Could not validate signature" because the asymmetric encryption used the wrong block size. (#915) (client + server)
  • A data race between Client.Close and an auto-reconnect dial is fixed. Without the race detector it could close a stale connection or hit a nil pointer in Close. (#897) (client)
  • A DateTime outside 1601–9999 no longer decodes to an unrelated date: a wire value of -1 decoded as 2185-07-21. Values past either end now decode to time.Time{} or 9999-12-31T23:59:59Z, and encoding clamps the same way, as OPC 10000-6 §5.2.2.5 specifies; 9999-12-31T23:59:59Z itself now encodes as the Int64 maximum. If you store source or server timestamps, a zero time.Time now also means the server sent a value before 1601. (#906, #955) (client + server)
  • Encoding a struct with a nil NodeId, LocalizedText, DataValue, Guid, Variant, DiagnosticInfo, ExpandedNodeId or QualifiedName field writes that type's null value. A nil NodeId used to crash the process, a nil ExpandedNodeId failed the whole message, and a nil QualifiedName wrote no bytes and misframed every field after it. A server hits this with a ReferenceDescription field the Browse ResultMask leaves out. (#901, #956) (client + server)
  • Reading a node's DataType attribute returns a NodeId, as the spec requires, also when the node stores it as an ExpandedNodeId. Fixes #849. (#873) (server)

Security updates

  • An expired security token is now removed from the channel it belongs to. When the server gave the channel and its token different ids, an expired token stayed valid for the rest of the connection (CWE-324). Using it needs that token's keys, which is why it is not under Action required. (#951) (client + server)

To report a vulnerability, use GitHub's private reporting; see SECURITY.md.

Full Changelog: v0.9.1...v0.9.2