Repository navigation
Requirements Fixes - #6
Merged
Merged
Conversation
dwoz
pushed a commit
that referenced
this pull request
Aug 20, 2019
Move provider config setup into Setup/Teardown class
dwoz
added a commit
that referenced
this pull request
Jan 2, 2026
SECURITY FIX: Upgrade cryptographic hash from SHA-1 to SHA-256 for
cluster public key signature verification.
SHA-1 is cryptographically broken and vulnerable to collision attacks.
Using SHA-1 for cluster public key verification creates a security risk
where an attacker could potentially create a malicious cluster public
key with the same SHA-1 hash as a legitimate one.
Changes:
- Line 1717: hashlib.sha1() → hashlib.sha256()
- Updated comment to clarify security reasoning
- Digest length changes from 40 hex chars (SHA-1) to 64 hex chars (SHA-256)
Security Impact:
- Protects against SHA-1 collision attacks
- Aligns with modern cryptographic best practices
- Makes cluster_pub_signature verification collision-resistant
Breaking Change Note:
Any existing cluster_pub_signature configuration values will need to be
regenerated using SHA-256 instead of SHA-1. Users can regenerate with:
python3 -c 'import hashlib; print(hashlib.sha256(open("cluster.pub").read().encode()).hexdigest())'
The digest length difference (40 vs 64 chars) makes this change
detectable - mismatched configs will fail validation and log warnings.
Attack Prevented:
Previously, an attacker with collision-finding capabilities could craft
a malicious cluster_pub with the same SHA-1 hash as a legitimate key,
bypassing signature verification. SHA-256 is currently collision-resistant.
Resolves security issue #6 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz
added a commit
that referenced
this pull request
Apr 2, 2026
SECURITY FIX: Upgrade cryptographic hash from SHA-1 to SHA-256 for
cluster public key signature verification.
SHA-1 is cryptographically broken and vulnerable to collision attacks.
Using SHA-1 for cluster public key verification creates a security risk
where an attacker could potentially create a malicious cluster public
key with the same SHA-1 hash as a legitimate one.
Changes:
- Line 1717: hashlib.sha1() → hashlib.sha256()
- Updated comment to clarify security reasoning
- Digest length changes from 40 hex chars (SHA-1) to 64 hex chars (SHA-256)
Security Impact:
- Protects against SHA-1 collision attacks
- Aligns with modern cryptographic best practices
- Makes cluster_pub_signature verification collision-resistant
Breaking Change Note:
Any existing cluster_pub_signature configuration values will need to be
regenerated using SHA-256 instead of SHA-1. Users can regenerate with:
python3 -c 'import hashlib; print(hashlib.sha256(open("cluster.pub").read().encode()).hexdigest())'
The digest length difference (40 vs 64 chars) makes this change
detectable - mismatched configs will fail validation and log warnings.
Attack Prevented:
Previously, an attacker with collision-finding capabilities could craft
a malicious cluster_pub with the same SHA-1 hash as a legitimate key,
bypassing signature verification. SHA-256 is currently collision-resistant.
Resolves security issue #6 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz
added a commit
that referenced
this pull request
Apr 7, 2026
SECURITY FIX: Upgrade cryptographic hash from SHA-1 to SHA-256 for
cluster public key signature verification.
SHA-1 is cryptographically broken and vulnerable to collision attacks.
Using SHA-1 for cluster public key verification creates a security risk
where an attacker could potentially create a malicious cluster public
key with the same SHA-1 hash as a legitimate one.
Changes:
- Line 1717: hashlib.sha1() → hashlib.sha256()
- Updated comment to clarify security reasoning
- Digest length changes from 40 hex chars (SHA-1) to 64 hex chars (SHA-256)
Security Impact:
- Protects against SHA-1 collision attacks
- Aligns with modern cryptographic best practices
- Makes cluster_pub_signature verification collision-resistant
Breaking Change Note:
Any existing cluster_pub_signature configuration values will need to be
regenerated using SHA-256 instead of SHA-1. Users can regenerate with:
python3 -c 'import hashlib; print(hashlib.sha256(open("cluster.pub").read().encode()).hexdigest())'
The digest length difference (40 vs 64 chars) makes this change
detectable - mismatched configs will fail validation and log warnings.
Attack Prevented:
Previously, an attacker with collision-finding capabilities could craft
a malicious cluster_pub with the same SHA-1 hash as a legitimate key,
bypassing signature verification. SHA-256 is currently collision-resistant.
Resolves security issue #6 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz
added a commit
that referenced
this pull request
Apr 8, 2026
SECURITY FIX: Upgrade cryptographic hash from SHA-1 to SHA-256 for
cluster public key signature verification.
SHA-1 is cryptographically broken and vulnerable to collision attacks.
Using SHA-1 for cluster public key verification creates a security risk
where an attacker could potentially create a malicious cluster public
key with the same SHA-1 hash as a legitimate one.
Changes:
- Line 1717: hashlib.sha1() → hashlib.sha256()
- Updated comment to clarify security reasoning
- Digest length changes from 40 hex chars (SHA-1) to 64 hex chars (SHA-256)
Security Impact:
- Protects against SHA-1 collision attacks
- Aligns with modern cryptographic best practices
- Makes cluster_pub_signature verification collision-resistant
Breaking Change Note:
Any existing cluster_pub_signature configuration values will need to be
regenerated using SHA-256 instead of SHA-1. Users can regenerate with:
python3 -c 'import hashlib; print(hashlib.sha256(open("cluster.pub").read().encode()).hexdigest())'
The digest length difference (40 vs 64 chars) makes this change
detectable - mismatched configs will fail validation and log warnings.
Attack Prevented:
Previously, an attacker with collision-finding capabilities could craft
a malicious cluster_pub with the same SHA-1 hash as a legitimate key,
bypassing signature verification. SHA-256 is currently collision-resistant.
Resolves security issue #6 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz
added a commit
that referenced
this pull request
Apr 12, 2026
SECURITY FIX: Upgrade cryptographic hash from SHA-1 to SHA-256 for
cluster public key signature verification.
SHA-1 is cryptographically broken and vulnerable to collision attacks.
Using SHA-1 for cluster public key verification creates a security risk
where an attacker could potentially create a malicious cluster public
key with the same SHA-1 hash as a legitimate one.
Changes:
- Line 1717: hashlib.sha1() → hashlib.sha256()
- Updated comment to clarify security reasoning
- Digest length changes from 40 hex chars (SHA-1) to 64 hex chars (SHA-256)
Security Impact:
- Protects against SHA-1 collision attacks
- Aligns with modern cryptographic best practices
- Makes cluster_pub_signature verification collision-resistant
Breaking Change Note:
Any existing cluster_pub_signature configuration values will need to be
regenerated using SHA-256 instead of SHA-1. Users can regenerate with:
python3 -c 'import hashlib; print(hashlib.sha256(open("cluster.pub").read().encode()).hexdigest())'
The digest length difference (40 vs 64 chars) makes this change
detectable - mismatched configs will fail validation and log warnings.
Attack Prevented:
Previously, an attacker with collision-finding capabilities could craft
a malicious cluster_pub with the same SHA-1 hash as a legitimate key,
bypassing signature verification. SHA-256 is currently collision-resistant.
Resolves security issue #6 from CLUSTER_JOIN_SECURITY_ANALYSIS.md
dwoz
added a commit
that referenced
this pull request
May 4, 2026
Closes three gaps identified in the Raft correctness audit. Dynamic join — joiner starts as learner (priority #2 & #6) ----------------------------------------------------------- A master that joins via discover_peers starts _publish_daemon before the join handshake completes, so cluster_peers is empty and RaftService is not started. Once join-reply arrives the MasterPubServerChannel now calls _start_raft_as_learner(), which: - builds pushers to every peer received in join-reply (fixes gap #6: dispatcher had no pushers to reply to the leader) - starts RaftService with voting=False (fixes gap #2: joiner was starting as a voter, risking split-brain before the leader promoted it) salt/channel/server.py - _start_raft_as_learner(known_peers): new helper started from the join-reply handler; builds peer pushers and calls RaftService(voting=False). - join-reply handler: calls _start_raft_as_learner after event.set(). salt/cluster/consensus/service.py - RaftService(voting=True): new optional parameter passed to Node so the node starts in learner mode when the master joined dynamically. Founding CONFIG entry (priority #5) ------------------------------------- The first elected leader of a fresh cluster now writes a CONFIG entry recording the founding voter set before any application entries. This makes cluster membership durably verifiable from the log alone. salt/cluster/consensus/service.py - _maybe_commit_founding_config(): proposes {voters, learners} CONFIG entry when the leader's log is empty; no-ops if the log already has content. - _heartbeat_tick: calls _maybe_commit_founding_config() on every tick while leader (the guard makes it idempotent). Tests ----- tests/pytests/functional/cluster/consensus/test_raft_service.py - TestFoundingConfig: leader writes CONFIG entry on empty log; no-ops if log is non-empty. - TestDynamicJoinerAsLearner: RaftService(voting=False) produces a non-voting node; learner-mode service does not start elections.
dwoz
added a commit
that referenced
this pull request
May 5, 2026
Closes three gaps identified in the Raft correctness audit. Dynamic join — joiner starts as learner (priority #2 & #6) ----------------------------------------------------------- A master that joins via discover_peers starts _publish_daemon before the join handshake completes, so cluster_peers is empty and RaftService is not started. Once join-reply arrives the MasterPubServerChannel now calls _start_raft_as_learner(), which: - builds pushers to every peer received in join-reply (fixes gap #6: dispatcher had no pushers to reply to the leader) - starts RaftService with voting=False (fixes gap #2: joiner was starting as a voter, risking split-brain before the leader promoted it) salt/channel/server.py - _start_raft_as_learner(known_peers): new helper started from the join-reply handler; builds peer pushers and calls RaftService(voting=False). - join-reply handler: calls _start_raft_as_learner after event.set(). salt/cluster/consensus/service.py - RaftService(voting=True): new optional parameter passed to Node so the node starts in learner mode when the master joined dynamically. Founding CONFIG entry (priority #5) ------------------------------------- The first elected leader of a fresh cluster now writes a CONFIG entry recording the founding voter set before any application entries. This makes cluster membership durably verifiable from the log alone. salt/cluster/consensus/service.py - _maybe_commit_founding_config(): proposes {voters, learners} CONFIG entry when the leader's log is empty; no-ops if the log already has content. - _heartbeat_tick: calls _maybe_commit_founding_config() on every tick while leader (the guard makes it idempotent). Tests ----- tests/pytests/functional/cluster/consensus/test_raft_service.py - TestFoundingConfig: leader writes CONFIG entry on empty log; no-ops if log is non-empty. - TestDynamicJoinerAsLearner: RaftService(voting=False) produces a non-voting node; learner-mode service does not start elections.
dwoz
added a commit
that referenced
this pull request
May 5, 2026
Closes three gaps identified in the Raft correctness audit. Dynamic join — joiner starts as learner (priority #2 & #6) ----------------------------------------------------------- A master that joins via discover_peers starts _publish_daemon before the join handshake completes, so cluster_peers is empty and RaftService is not started. Once join-reply arrives the MasterPubServerChannel now calls _start_raft_as_learner(), which: - builds pushers to every peer received in join-reply (fixes gap #6: dispatcher had no pushers to reply to the leader) - starts RaftService with voting=False (fixes gap #2: joiner was starting as a voter, risking split-brain before the leader promoted it) salt/channel/server.py - _start_raft_as_learner(known_peers): new helper started from the join-reply handler; builds peer pushers and calls RaftService(voting=False). - join-reply handler: calls _start_raft_as_learner after event.set(). salt/cluster/consensus/service.py - RaftService(voting=True): new optional parameter passed to Node so the node starts in learner mode when the master joined dynamically. Founding CONFIG entry (priority #5) ------------------------------------- The first elected leader of a fresh cluster now writes a CONFIG entry recording the founding voter set before any application entries. This makes cluster membership durably verifiable from the log alone. salt/cluster/consensus/service.py - _maybe_commit_founding_config(): proposes {voters, learners} CONFIG entry when the leader's log is empty; no-ops if the log already has content. - _heartbeat_tick: calls _maybe_commit_founding_config() on every tick while leader (the guard makes it idempotent). Tests ----- tests/pytests/functional/cluster/consensus/test_raft_service.py - TestFoundingConfig: leader writes CONFIG entry on empty log; no-ops if log is non-empty. - TestDynamicJoinerAsLearner: RaftService(voting=False) produces a non-voting node; learner-mode service does not start elections.
dwoz
added a commit
that referenced
this pull request
May 7, 2026
Closes three gaps identified in the Raft correctness audit. Dynamic join — joiner starts as learner (priority #2 & #6) ----------------------------------------------------------- A master that joins via discover_peers starts _publish_daemon before the join handshake completes, so cluster_peers is empty and RaftService is not started. Once join-reply arrives the MasterPubServerChannel now calls _start_raft_as_learner(), which: - builds pushers to every peer received in join-reply (fixes gap #6: dispatcher had no pushers to reply to the leader) - starts RaftService with voting=False (fixes gap #2: joiner was starting as a voter, risking split-brain before the leader promoted it) salt/channel/server.py - _start_raft_as_learner(known_peers): new helper started from the join-reply handler; builds peer pushers and calls RaftService(voting=False). - join-reply handler: calls _start_raft_as_learner after event.set(). salt/cluster/consensus/service.py - RaftService(voting=True): new optional parameter passed to Node so the node starts in learner mode when the master joined dynamically. Founding CONFIG entry (priority #5) ------------------------------------- The first elected leader of a fresh cluster now writes a CONFIG entry recording the founding voter set before any application entries. This makes cluster membership durably verifiable from the log alone. salt/cluster/consensus/service.py - _maybe_commit_founding_config(): proposes {voters, learners} CONFIG entry when the leader's log is empty; no-ops if the log already has content. - _heartbeat_tick: calls _maybe_commit_founding_config() on every tick while leader (the guard makes it idempotent). Tests ----- tests/pytests/functional/cluster/consensus/test_raft_service.py - TestFoundingConfig: leader writes CONFIG entry on empty log; no-ops if log is non-empty. - TestDynamicJoinerAsLearner: RaftService(voting=False) produces a non-voting node; learner-mode service does not start elections.
dwoz
added a commit
that referenced
this pull request
May 14, 2026
This commit fixes catastrophic FD exhaustion in Salt minions running queued state jobs. The issue manifested as "Too many open files" errors after ~15 queued jobs. Root causes and fixes: 1. Unawaited coroutine (salt/utils/event.py:785) - Changed self.pusher.publish(msg) to await self.pusher.publish(msg) 2. Unclosed event loops in job threads (salt/minion.py) - Added loop.close() in finally blocks of _thread_return() and _thread_multi_return() 3. SyncWrapper __getattr__ preventing cleanup (salt/utils/event.py) - Explicitly call SyncWrapper.close() instead of relying on __getattr__ 4. Missing task cancellation (salt/utils/asynchronous.py) - Cancel pending tasks before closing event loop - Shutdown async generators with shutdown_asyncgens() - Shutdown executor with shutdown_default_executor() 5. IOLoop auto-creation (salt/utils/asynchronous.py) - Changed IOLoop.current() to IOLoop.current(instance=False) 6. Nested SyncWrapper in TCP transport (salt/transport/tcp.py) - Explicitly close pub_sock SyncWrapper in PublishServer.close() 7. Unclosed TCP client (salt/transport/tcp.py) - Added _tcp_client.close() in PublishClient.close() 8. Async generator/executor shutdown (salt/utils/asynchronous.py) - Call shutdown_asyncgens() and shutdown_default_executor() before loop close Impact: - Before: 237 FDs leaked per 15 queued jobs → OSError after ~40 jobs - After: 0 FDs leaked (multiprocessing), minimal leaks (threading) Tests added: - tests/pytests/scenarios/queue/test_queue_fd_leak.py Comprehensive regression test for the reported bug - tests/pytests/scenarios/regression/test_fd_leak_fire_event_async.py Regression test for fix #1 (unawaited coroutine) - tests/pytests/scenarios/regression/test_fd_leak_job_thread_loop.py Regression test for fix #2 (job thread event loop close) - tests/pytests/scenarios/regression/test_fd_leak_syncwrapper_close.py Regression test for fix #3 (SyncWrapper explicit close) - tests/pytests/scenarios/regression/test_fd_leak_task_cancellation.py Regression test for fix #4 (task cancellation and cleanup) - tests/pytests/scenarios/regression/test_fd_leak_ioloop_instance.py Regression test for fix #5 (IOLoop.current(instance=False)) - tests/pytests/scenarios/regression/test_fd_leak_tcp_nested_syncwrapper.py Regression test for fix #6 (nested SyncWrapper in TCP) - tests/pytests/scenarios/regression/test_fd_leak_tcp_client_close.py Regression test for fix #7 (TCP client close) - tests/pytests/scenarios/regression/test_fd_leak_asyncgens_executor.py Regression test for fix #8 (async generator and executor shutdown) All regression tests: - Use real Salt master/minion infrastructure (not mocks) - Measure actual FD counts with psutil - Exercise specific code paths that were leaking - Assert FD leaks are minimal (≤ threshold)
dwoz
pushed a commit
that referenced
this pull request
May 14, 2026
Three of the new tests in tests/pytests/scenarios/regression/ kept failing
across the CI matrix for reasons that have nothing to do with the FD-leak
fix they were meant to guard:
* test_fd_leak_job_thread_loop.py (both tests) fired test.ping with
kwarg={"queue": True}, but `queue=True` is only a parameter of
state.apply / state.sls. test.ping rejects it with SaltInvocationError
so the minion never produces a normal return event, the assertion
`Job did not complete` always trips. The same tests also passed
`minion.id` (a bare string) to LocalClient.get_returns(jid, minions),
which immediately does set(minions) and ends up matching against a
set of single characters.
* test_fd_leak_tcp_client_close.py and test_fd_leak_tcp_nested_syncwrapper.py
spin up their own TCP master+minion pair inside a zmq-default scenarios
session. The TCP auth handshake never converges in that configuration
on a number of CI runners (Ubuntu 24.04, Photon ARM64) and saltfactories
times out with FactoryNotStarted after ~384s. The two TCP fixes those
tests are pointed at (#6, #7) are already exercised by the existing
`scenarios tcp` CI variant, which runs the whole scenarios suite under
a globally configured TCP transport.
Coverage left in place: tests/pytests/scenarios/queue/test_queue_fd_leak.py
(the comprehensive 15-queued-job test, green on both multiprocessing and
threading modes) plus the remaining regression tests in this directory
(asyncgens_executor, fire_event_async x2, ioloop_instance, syncwrapper_close,
task_cancellation, fd_threshold_queuing x2). Those collectively cover fixes
#1, #3, #4, #5, #8, and the FD-threshold queuing safety mechanism.
dwoz
added a commit
that referenced
this pull request
May 14, 2026
This commit fixes catastrophic FD exhaustion in Salt minions running queued state jobs. The issue manifested as "Too many open files" errors after ~15 queued jobs. Root causes and fixes: 1. Unawaited coroutine (salt/utils/event.py:785) - Changed self.pusher.publish(msg) to await self.pusher.publish(msg) 2. Unclosed event loops in job threads (salt/minion.py) - Added loop.close() in finally blocks of _thread_return() and _thread_multi_return() 3. SyncWrapper __getattr__ preventing cleanup (salt/utils/event.py) - Explicitly call SyncWrapper.close() instead of relying on __getattr__ 4. Missing task cancellation (salt/utils/asynchronous.py) - Cancel pending tasks before closing event loop - Shutdown async generators with shutdown_asyncgens() - Shutdown executor with shutdown_default_executor() 5. IOLoop auto-creation (salt/utils/asynchronous.py) - Changed IOLoop.current() to IOLoop.current(instance=False) 6. Nested SyncWrapper in TCP transport (salt/transport/tcp.py) - Explicitly close pub_sock SyncWrapper in PublishServer.close() 7. Unclosed TCP client (salt/transport/tcp.py) - Added _tcp_client.close() in PublishClient.close() 8. Async generator/executor shutdown (salt/utils/asynchronous.py) - Call shutdown_asyncgens() and shutdown_default_executor() before loop close Impact: - Before: 237 FDs leaked per 15 queued jobs → OSError after ~40 jobs - After: 0 FDs leaked (multiprocessing), minimal leaks (threading) Tests added: - tests/pytests/scenarios/queue/test_queue_fd_leak.py Comprehensive regression test for the reported bug - tests/pytests/scenarios/regression/test_fd_leak_fire_event_async.py Regression test for fix #1 (unawaited coroutine) - tests/pytests/scenarios/regression/test_fd_leak_job_thread_loop.py Regression test for fix #2 (job thread event loop close) - tests/pytests/scenarios/regression/test_fd_leak_syncwrapper_close.py Regression test for fix #3 (SyncWrapper explicit close) - tests/pytests/scenarios/regression/test_fd_leak_task_cancellation.py Regression test for fix #4 (task cancellation and cleanup) - tests/pytests/scenarios/regression/test_fd_leak_ioloop_instance.py Regression test for fix #5 (IOLoop.current(instance=False)) - tests/pytests/scenarios/regression/test_fd_leak_tcp_nested_syncwrapper.py Regression test for fix #6 (nested SyncWrapper in TCP) - tests/pytests/scenarios/regression/test_fd_leak_tcp_client_close.py Regression test for fix #7 (TCP client close) - tests/pytests/scenarios/regression/test_fd_leak_asyncgens_executor.py Regression test for fix #8 (async generator and executor shutdown) All regression tests: - Use real Salt master/minion infrastructure (not mocks) - Measure actual FD counts with psutil - Exercise specific code paths that were leaking - Assert FD leaks are minimal (≤ threshold)
dwoz
pushed a commit
that referenced
this pull request
May 14, 2026
Three of the new tests in tests/pytests/scenarios/regression/ kept failing
across the CI matrix for reasons that have nothing to do with the FD-leak
fix they were meant to guard:
* test_fd_leak_job_thread_loop.py (both tests) fired test.ping with
kwarg={"queue": True}, but `queue=True` is only a parameter of
state.apply / state.sls. test.ping rejects it with SaltInvocationError
so the minion never produces a normal return event, the assertion
`Job did not complete` always trips. The same tests also passed
`minion.id` (a bare string) to LocalClient.get_returns(jid, minions),
which immediately does set(minions) and ends up matching against a
set of single characters.
* test_fd_leak_tcp_client_close.py and test_fd_leak_tcp_nested_syncwrapper.py
spin up their own TCP master+minion pair inside a zmq-default scenarios
session. The TCP auth handshake never converges in that configuration
on a number of CI runners (Ubuntu 24.04, Photon ARM64) and saltfactories
times out with FactoryNotStarted after ~384s. The two TCP fixes those
tests are pointed at (#6, #7) are already exercised by the existing
`scenarios tcp` CI variant, which runs the whole scenarios suite under
a globally configured TCP transport.
Coverage left in place: tests/pytests/scenarios/queue/test_queue_fd_leak.py
(the comprehensive 15-queued-job test, green on both multiprocessing and
threading modes) plus the remaining regression tests in this directory
(asyncgens_executor, fire_event_async x2, ioloop_instance, syncwrapper_close,
task_cancellation, fd_threshold_queuing x2). Those collectively cover fixes
#1, #3, #4, #5, #8, and the FD-threshold queuing safety mechanism.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Requirements Fixes