Skip to content

Derive cluster session keys from cluster.pem so isolated-FS masters agree (#70399) - #70429

Merged
dwoz merged 1 commit into
saltstack:3008.xfrom
dwoz:dwoz/fix/70399-cluster-session-key-isolated-fs
Oct 27, 2026
Merged

dwoz merged 1 commit into
saltstack:3008.xfrom
dwoz:dwoz/fix/70399-cluster-session-key-isolated-fs

Conversation

@dwoz

@dwoz dwoz commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #70399. On a master cluster with cluster_isolated_filesystem: True behind an L4 load balancer (HAProxy round-robin), minions failed every non-auth request with Master did not return a session key for pillar request. The minion auth'd against master A and received session key S_A; a subsequent pillar/publish request round-robined to master B hit "bad load" because B decrypted the payload under its own private random S_B.

Root cause: ReqServerChannel.session_key() wrote a random key to each master's private cachedir/sessions/<minion>. Unlike minion keys (replicated via salt/key/accept) or cluster_aes (distributed in cluster/peer/join-reply), the sessions directory had no replication path in isolated-FS mode.

  • salt/crypt.py: add Crypticle.derive_session_key(cluster_aes, minion_id, key_size=192) — HKDF-SHA256 producing the same base64 shape as generate_key_string so callers feed it to Crypticle(...) unchanged.
  • salt/channel/server.py (ReqServerChannel.session_key, PoolRoutingChannel.session_key) and salt/master.py (AuthFuncs.session_key): when opts["cluster_id"] and opts["cluster_isolated_filesystem"], derive instead of random-file. In-memory cache tuple keyed on current cluster_aes value so a cluster-wide rotation (rotate_cluster_aes_key) auto-invalidates.

Standalone masters and shared-FS clusters keep the existing random-file path verbatim.

Rotation story

cluster_aes is rotated cluster-wide by rotate_cluster_aes_key / SMaster.rotate_cluster_secret. The derivation binds the per-minion session key to cluster_aes, so an aes rotation rotates every minion's session key in lockstep across every peer. The publish_session time-based rotation becomes a no-op on isolated-FS clusters (acceptable: it was never reliable there anyway because the random files diverged per master).

Test plan

  • New regression test tests/pytests/scenarios/cluster/test_isolated_session_key.py asserts session_key(minion_id) returns identical bytes on every cluster master. Pre-fix: three distinct random keys → fails. Post-fix: deterministic HKDF derivation from shared cluster_aes → identical → passes.
  • Verified the test fails on 3008.x without the fix and passes after.
  • tests/pytests/unit/channel: 60 passed.
  • tests/pytests/integration/cluster/test_basic_cluster.py and test_isolated_cluster.py (--run-slow): all pass.
  • tests/pytests/scenarios/cluster/: all pass, including test_haproxy_isolated_fs.py::test_joiner_cache_matches_disk_after_join_reply.
  • Pre-commit clean.

@dwoz
dwoz requested a review from a team as a code owner October 17, 2026 02:40
@dwoz dwoz added the test:full Run the full test suite label Oct 17, 2026
@dwoz dwoz added this to the Argon v3008.5 milestone Oct 17, 2026
@dwoz
dwoz force-pushed the dwoz/fix/70399-cluster-session-key-isolated-fs branch from d46330b to 0202c77 Compare October 17, 2026 21:30
twangboy
twangboy previously approved these changes Oct 19, 2026

@charzl charzl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to confirm if the derived key still agree across masters after cluster_aes rotates?

@dwoz

dwoz commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@charzl Yes, key rotation is replicated to the cluster.

@dwoz
dwoz force-pushed the dwoz/fix/70399-cluster-session-key-isolated-fs branch from 0202c77 to 8adca3d Compare October 20, 2026 21:22
@dwoz dwoz changed the title Derive cluster session keys from cluster_aes so isolated-FS masters agree (#70399) Derive cluster session keys from cluster.pem so isolated-FS masters agree (#70399) Oct 20, 2026
…gree

Fixes saltstack#70399.

With ``cluster_isolated_filesystem: True`` behind an L4 load balancer,
each cluster master's ``session_key(minion)`` wrote a random key to its
private ``cachedir/sessions/<minion>`` and returned it in the auth-reply.
When the minion's next pillar request was round-robined to a peer, that
peer generated its own random key and failed to decrypt the minion's
payload with "bad load", surfacing as "Master did not return a session
key for pillar request".

Derive the per-minion session key via HKDF-SHA256 using ``cluster.pem``
as IKM and ``cluster_aes`` as HKDF salt when the cluster runs with
isolated filesystems.  ``cluster.pem`` is distributed master-to-master
in ``cluster/peer/join-reply`` and never leaves the cluster, so every
peer master can derive the same key but no minion can — even though
minions all share ``cluster_aes`` (received in their auth-reply to
decrypt publish broadcasts, so inherently not a secret from them).
This preserves the per-minion session-key secrecy property that
prevents one minion from decrypting another's request-channel traffic.

``cluster_aes`` as HKDF salt means a cluster-wide aes rotation
(``rotate_cluster_aes_key``) rotates every minion's session key in
lockstep across the cluster.  Standalone masters and shared-filesystem
clusters keep the existing random-file path verbatim.
@dwoz
dwoz force-pushed the dwoz/fix/70399-cluster-session-key-isolated-fs branch from 8adca3d to 48ec474 Compare October 27, 2026 01:05
@dwoz
dwoz merged commit 865519f into saltstack:3008.x Oct 27, 2026
447 checks passed
@twangboy twangboy modified the milestones: Argon v3008.5, Argon v3008.7 Oct 30, 2026
@dwoz
dwoz deleted the dwoz/fix/70399-cluster-session-key-isolated-fs branch November 13, 2026 08:30

This branch was previously deployed

1 inactive deployment
ci — 48ec474f Deployed Oct 27, 2026 by dwoz via Build Onedir Packages / DEB (x86_64) #27893
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants