Merge security follow-ups: host-side PE-cache signing, worker no longer holds the HMAC key (#1014); Akka remoting untrusted-mode + trusted-selection-paths by default, opt-in mutual TLS (#1003)
This commit is contained in:
+75
-4
@@ -1826,7 +1826,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).
|
||||
|
||||
|
||||
---
|
||||
|
||||
@@ -1966,9 +2035,11 @@ deploy is rejected if any in-use stored script uses an API now refused; see `doc
|
||||
Residual exposure, by design: a script can still burn CPU and memory up to its budget (`ScriptRunGuard`; pre-emptive
|
||||
limits need `OutOfProcess`), read any tag through `ctx.GetTag`, and write virtual tags. Extending the allow-list is a
|
||||
security change — add only types with no I/O, process-wide state, background work, blocking wait or reflection
|
||||
surface. The out-of-process runner's compiled-PE cache is still HMAC-signed by the **worker** with a key it is handed
|
||||
in `Hello`; a worker that had escaped could forge entries for other scripts (follow-up from #971: move signing to the
|
||||
host).
|
||||
surface. The out-of-process runner's compiled-PE cache is owned by the **host** since lmxopcua#1014: the host verifies
|
||||
entries under a key only it holds, ships verified images inside the load, and fills misses with its own compile; the
|
||||
worker is never handed the key or the directory, so a worker that had escaped cannot forge an entry for another script.
|
||||
Entries written by pre-#1014 workers are rejected on upgrade (format version 2). See `docs/VirtualTags.md`
|
||||
§"Out-of-process runner" → Compiled-PE cache.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user