ARC 5Own Runtime OperationsChapters 19–22

Chapter 20 — Message Security and Convergence Preconditions

Chapter objective: After this chapter, a developer can separate cluster admission, authenticity, confidentiality, replay prevention, abuse control, and audit, and explain the compatibility window during key rotation.

Learning objectives

  1. Define ordered security gates for a remote envelope.
  2. Distinguish HMAC authentication, payload encryption, and nonce replay prevention.
  3. Explain key version, minimum acceptable version, and rotation window.
  4. Map every rejection to a structured error, metric, and audit event.

Prerequisites

Case progress

The fulfillment cluster begins receiving cross-node deltas. It needs to reject nodes with a wrong token, detect payload tampering, expire old signing keys, stop replay of a valid message, and limit senders that consume validation resources through repeated failures.

Five gates answer five questions

Security gates before a remote message reaches a collection

Gate Question Typical component
Admission Does the node hold the cluster credential? SharedKeyClusterTokenValidator
Authenticity Was the message signed by a trusted key and left intact? HmacMessageAuthenticator
Confidentiality Was required payload encryption applied and decrypted? AES-GCM / ChaCha20 encryptor
Replay Is the nonce fresh and unseen? SlidingWindowNonceTracker
Abuse Should a repeatedly failing sender be blocked temporarily? SenderRateLimiter

Encryption does not authenticate a sender, and authentication does not stop replay of a valid packet. One "security enabled" flag hides configuration and diagnosis details.

Key rotation is a window

The security integration test validates rolling migration: old and new signatures coexist temporarily. Receivers choose the verification key by version. After every sender moves, raising min-acceptable-key-version rejects old envelopes.

phase A: active=1, accept >=1
phase B: publish key 2, send active=2, receive accept >=1
phase C: after all nodes switch, accept >=2

Keeping only the new key immediately disconnects nodes not yet rolled. Never raising the minimum leaves exposure from an old key indefinitely.

Nonce window and memory bound

SlidingWindowNonceTracker accepts an increasing nonce or an unseen nonce inside the window, and rejects duplicates, stale values, and zero. maxTrackedSenders plus LRU eviction prevents unknown senders from consuming unbounded memory. Too small a limit repeatedly forgets senders; too large a limit expands memory exposure.

Audit is not a debug log

SecurityAuditLog records token mismatch, signature failure, replay, challenge timeout, sender ban, and fencing rejection. An event contains stable reason, sender, and time without secrets, plaintext keys, or a full sensitive payload.

Counterexample and fault injection

Experiment

cd submodule/dsm
mvn -q -pl dsm-security,dsm-integration-test -am \
  -Dtest='HmacMessageAuthenticatorTest,SlidingWindowNonceTrackerTest,'\
'SharedKeyClusterTokenValidatorTest,SenderRateLimiterTest,'\
'BuiltInMessageEncryptorTest,SecurityIntegrationTest' \
  -Dsurefire.failIfNoSpecifiedTests=false test

Use security-gates.json to check input, rejection reason, metric, and audit outcome for each gate; secret values are excluded.

Experiment acceptance card

Field Content
Command The security unit/integration tests above plus book assets
Input or fault token mismatch, tamper, plaintext mismatch, replay, sender ban, and old key
Observable result messages fail closed; structured failure, metric, and audit agree; rolling rotation remains compatible
Evidence level E2 cryptographic/state components plus E3 security integration
This experiment does not prove Key custody, certificate infrastructure, production rotation, retention compliance, or audited network boundaries

Review

Next

Chapter 21 defines startup, registry freeze, readiness, and shutdown so deployment automation does not treat STARTING as RUNNING.