feat(cluster): #1003 Akka remoting hardening — untrusted-mode on by default, mutual TLS opt-in
Follow-up of #973 (review 2026-12-02 A-1). New Cluster:Remoting section (AkkaRemotingOptions): - UntrustedMode (default ON): akka.remote.untrusted-mode with trusted-selection-paths = every path this code base reaches by ActorSelection across nodes, enumerated from the Akka 1.5.62 sources + src/: cluster core daemon + heartbeat receiver, remote-watcher, the DPS mediator, /user/{s} + /user/{s}/{s} for each ControlPlane singleton, /user/driver-host. Remote deployment and peer PoisonPill/Kill are dropped. Receive-side only, so a mixed old/new pair keeps working through a rolling upgrade. Drops (Akka logs them at Debug) become a Warning per path + otopcua.cluster.remoting.untrusted_drops. AdditionalTrustedSelectionPaths / UntrustedMode=false are the escape hatches. - Tls (default OFF): mutual TLS on the DotNetty transport (PFX or store cert, mutual auth on by default, thumbprint pinning or chain validation, optional hostname check). Seeds and the diagnostics selection follow the transport scheme (akka.ssl.tcp); the bootstrap guard parses it. Validated at boot. Proven on real clusters: pair formation, singleton via proxy + hand-over on leave, DPS, zero drops; untrusted selection dropped (and delivered with the mode off); pinned TLS peers form, an unpinned node cannot join; full two-node Host harness (deploys from both nodes, diagnostics, node restart) with zero drops + positive control. Guards fail when a new singleton or ActorSelection appears without its trusted path.
This commit is contained in:
@@ -173,6 +173,9 @@ Security__Ldap__GroupToRole__<AD group>=Viewer
|
||||
| `Port` | int | `4053` | Cluster transport port. **Duplicated as `ClusterNode.AkkaPort` in the Config DB** — see the note below. |
|
||||
| `PublicHostname` | string | `127.0.0.1` | Hostname advertised in cluster gossip; must be reachable by peers. **Duplicated as `ClusterNode.Host`** — see the note below. |
|
||||
| `SeedNodes` | string[] | `[]` | Seed nodes for bootstrapping. **Ordered:** a node that appears in its own list must be entry 0 (only `seed-nodes[0]` can form a new cluster), or the host refuses to start — see [Redundancy.md § Bootstrap: self-first seed ordering](Redundancy.md#bootstrap-self-first-seed-ordering). **Per-pair since Phase 6:** each application `Cluster`'s pair is its own Akka mesh, so a node's `SeedNodes` lists only itself (first) and its own pair partner (second) — never a node from another cluster's pair. |
|
||||
| `Remoting:UntrustedMode` | bool | `true` | Akka `untrusted-mode` with the trusted selection paths this code base uses (lmxopcua#1003). Receive-side only; a drop is a Warning naming the path. See [security.md § Akka remoting hardening](security.md#akka-remoting-hardening-clusterremoting-lmxopcua1003). |
|
||||
| `Remoting:AdditionalTrustedSelectionPaths` | string[] | `[]` | Extra `/user/…` / `/system/…` paths a peer may reach by selection. |
|
||||
| `Remoting:Tls:*` | object | `Enabled=false` | Opt-in mutual TLS on the remoting transport (`CertificatePath`+`CertificatePassword` or `CertificateThumbprint`+store, `RequireMutualAuthentication=true`, `AllowedThumbprints`, `ValidateCertificateHostname`). Both nodes of a pair change together. |
|
||||
| `Roles` | string[] | `[]` | Cluster roles for this node. When empty, falls back to `OTOPCUA_ROLES` (see the note below). Values are trimmed and (for a plain role) lower-cased; a cluster role's ClusterId suffix keeps the operator's spelling. An unknown role from either source **fails host start**. Allowed values: `admin`, `driver`, `dev`, plus a per-cluster `cluster-{ClusterId}` role (e.g. `cluster-MAIN`, `cluster-SITE-A`) — see [Per-cluster mesh split (Phase 6)](#per-cluster-mesh-split-phase-6-cluster-clusterid-roles--splittopologytransportvalidator) below. |
|
||||
|
||||
> **One role authority, one precedence, both consumers (archreview R3-04).** `EffectiveRoles.Resolve` (`ZB.MOM.WW.OtOpcUa.Cluster`) is the SINGLE place a node's roles are decided: `Cluster:Roles` wins outright when non-empty, else `OTOPCUA_ROLES`, else empty. Both `Program.cs`'s conditional host wiring (which subsystems mount) AND the Akka `AkkaClusterOptions.Roles` gossiped to the cluster are the SAME `EffectiveRoles` instance's `Gossiped` list — not two separate derivations that happen to usually agree. The boot banner (`OtOpcUa.Host starting with roles=[...] source=...`) names which source won. Setting both sources to *different* normalized role sets logs a Warning at boot (still resolves from `Cluster:Roles`) — almost certainly not what an operator intended.
|
||||
|
||||
+70
-1
@@ -1823,7 +1823,76 @@ The page used to feed `?node=` (or the typed host:port box) straight into an Akk
|
||||
|
||||
The page policy stays `AuthenticatedRead`: `/fleet` and `/hosts`, which link to it and show the same driver-health data, are the same tier, and with the closed set a Viewer can no longer steer the admin node's outbound connections.
|
||||
|
||||
**Open (not fixed here): Akka remoting is not hardened.** The embedded HOCON (`Cluster/Resources/akka.conf`) sets no `akka.remote.untrusted-mode` / `trusted-selection-paths`, and `WithRemoting` configures no TLS. Untrusted mode is not a drop-in switch on a cluster node (it blocks the system messages and `/system/...` selections that cluster gossip, DistributedPubSub and singletons rely on), so it needs its own design — see the follow-up issue.
|
||||
**Akka remoting itself** is hardened since lmxopcua#1003 — untrusted mode on by default, mutual TLS opt-in; see the
|
||||
next section.
|
||||
|
||||
### Akka remoting hardening (`Cluster:Remoting`, lmxopcua#1003)
|
||||
|
||||
Every node listens for Akka remoting on `Cluster:Port` (4053). Two independent controls, configured under
|
||||
`Cluster:Remoting`:
|
||||
|
||||
**1. Untrusted mode — ON by default.** `akka.remote.untrusted-mode = on` with an explicit
|
||||
`trusted-selection-paths` list (`RemotingHardening.TrustedSelectionPaths`). What it does in Akka.NET 1.5 (read off
|
||||
`Akka.Remote.DefaultMessageDispatcher`, the setting's only consumer): an inbound `ActorSelection` is delivered only to a
|
||||
listed path; messages for the remote daemon (**remote deployment**) are dropped; an `IPossiblyHarmful` message
|
||||
(`PoisonPill`, `Kill`, …) sent by a peer to any actor reference is dropped; a message a peer asks this node to forward to a
|
||||
third system is dropped. Messages to actor *references* (DistributedPubSub delivery, replies, `Ask` temp actors) and
|
||||
system messages (remote watch) are unaffected — so, contrary to the earlier note here, untrusted mode does **not** break
|
||||
cluster gossip, DPS or singletons, provided their selection paths are trusted. The trusted set is every path this code
|
||||
base reaches by selection across nodes, enumerated from the Akka 1.5.62 sources and this repo:
|
||||
|
||||
| Path | Used by |
|
||||
|---|---|
|
||||
| `/system/cluster/core/daemon` | Akka.Cluster gossip, InitJoin/Join/Welcome, the seed-node processes, leave/exiting |
|
||||
| `/system/cluster/heartbeatReceiver` | cluster failure-detector heartbeats |
|
||||
| `/system/remote-watcher` | remote-watch heartbeats |
|
||||
| `/system/distributedPubSubMediator` | DistributedPubSub registry gossip (redundancy-state, the DPS transports, secrets replication) |
|
||||
| `/user/{name}`, `/user/{name}/{name}` for each singleton (`config-publish`, `admin-operations`, `audit-writer`, `redundancy-state`, `cluster-node-address-reconciler`, `deployment-retention`) | manager-to-manager hand-over; the proxies' `Identify` |
|
||||
| `/user/driver-host` | `/fleet/diagnostics` (`FleetDiagnosticsClient`), also across meshes |
|
||||
|
||||
Coverage is proven, not asserted: `RemotingHardeningClusterTests` (real pairs through the shipped bootstrap — formation,
|
||||
a singleton reached through its proxy and handed over on leave, DPS across nodes, zero drops; a selection to any other
|
||||
path dropped; the same selection delivered with the mode off) and `UntrustedModeHarnessTests` (the full two-node Host
|
||||
stack — every ControlPlane singleton + proxy, the redundancy singleton, runtime actors, deploys from both nodes, the
|
||||
diagnostics selection, node B restarting — zero drops, with a positive control that the monitor records one).
|
||||
`RemotingTrustedPathsCoverageTests` fails when a new singleton constant or a new `ActorSelection` in `src/` appears
|
||||
without its path. A drop is logged as a **Warning** naming the path (once per path; Akka logs it at Debug) and counted on
|
||||
`otopcua.cluster.remoting.untrusted_drops`.
|
||||
|
||||
What it does **not** do: authenticate the peer. The cluster daemon must stay reachable for joining to work, so any host
|
||||
that can reach the port can still associate — and join. That is what TLS is for.
|
||||
|
||||
- **Upgrade:** nothing to configure; the filter is receive-side only, so a mixed old/new pair keeps working through a
|
||||
rolling upgrade (both send the same selections). If a drop Warning ever names a path OtOpcUa itself uses, add it to
|
||||
`Cluster:Remoting:AdditionalTrustedSelectionPaths` (and file it); `Cluster:Remoting:UntrustedMode = false` is the
|
||||
escape hatch.
|
||||
|
||||
**2. Mutual TLS — opt-in (`Cluster:Remoting:Tls:Enabled`, default `false`).** The DotNetty transport runs TLS, and with
|
||||
`RequireMutualAuthentication` (default `true`) the accepting side demands a client certificate too — so only a peer
|
||||
holding an accepted certificate can associate at all.
|
||||
|
||||
| Key | Default | Meaning |
|
||||
|---|---|---|
|
||||
| `Enabled` | `false` | TLS on the remoting transport. The address scheme becomes `akka.ssl.tcp`; `Cluster:SeedNodes` may keep `akka.tcp://` (rewritten at startup). |
|
||||
| `CertificatePath` / `CertificatePassword` | — | The node certificate as an absolute-path `.pfx` with its private key; supply the password as `${secret:…}` or an env var. |
|
||||
| `CertificateThumbprint` / `CertificateStoreName` / `CertificateStoreLocation` | — / `My` / `LocalMachine` | Alternatively, a certificate in a store (Windows). Exactly one source is required. |
|
||||
| `RequireMutualAuthentication` | `true` | Demand a client certificate on inbound associations. Turning it off leaves the link encrypted but open to any client. |
|
||||
| `AllowedThumbprints` | `[]` | SHA-1 thumbprints accepted from peers. Non-empty ⇒ pin only (self-signed works, no CA). Empty ⇒ the peer chain must validate against the machine trust store. |
|
||||
| `ValidateCertificateHostname` | `false` | Also require the peer certificate's CN/SAN to match the host it was dialled at. |
|
||||
|
||||
Startup refuses `Enabled` with no certificate source (or two), a relative or missing `CertificatePath`, a malformed
|
||||
thumbprint, or a certificate without a private key. Proven by
|
||||
`RemotingHardeningClusterTests.Mutual_tls_forms_a_mesh_between_pinned_peers_and_keeps_an_unpinned_node_out`.
|
||||
|
||||
- **Rollout (TLS is all-or-nothing per link).** A TLS node and a plain node cannot associate, so: issue one certificate
|
||||
per node (or one per pair), put every peer's thumbprint in `AllowedThumbprints` on **both** nodes of a pair, then
|
||||
**stop both nodes, set `Cluster:Remoting:Tls` on both, start both** — a one-at-a-time restart leaves the pair split
|
||||
across the change (each side forms its own cluster ⇒ two Primaries until the second node is converted). An admin
|
||||
node's `/fleet/diagnostics` dials every node's `driver-host` over remoting, so either convert the whole fleet or
|
||||
expect diagnostics of a node on the other transport to come back empty (it degrades, it does not fail). The
|
||||
certificates of the admin nodes must be pinned on the nodes they query.
|
||||
- Rolling back is the same in reverse (both nodes together).
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user