Repository navigation
fix: never fall back to the legacy handshake unless the operator sets legacy_hub - #20
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
JarbasAl
force-pushed
the
fix/no-automatic-legacy-handshake
branch
from
September 10, 2026 20:26
6515a37 to
2ced00b
Compare
… legacy_hub
The client chose the pre-v3 password handshake automatically whenever the
hub could not offer Noise (no PSK, a v2-capped hub, max_protocol_version=2,
or no mutual pattern/suite), violating HIVEMIND-CRYPTO-1 §3 ("The handshake
is mandatory on every connection: there is no cleartext, pre-shared-key, or
password alternative and no protocol-version ladder to negotiate down") and
§5 ("A node MUST run the mandatory Noise handshake on every connection and
reject any peer that cannot complete it, with no cleartext or legacy
fallback").
A hub that cannot complete Noise is now rejected: no shake response is sent
and last_error names the violated clause. legacy_hub (default False) is the
only way to reach a legacy hub; setting it prints a loud warning at connect
time naming the pre-v3 handshake's lack of PAKE/forward secrecy and the
computed next-major removal version. max_protocol_version below 3 now
requires legacy_hub=True at construction time, since it can only ever reach
a hub through that same legacy path.
Fail-before: reverting the source (keeping the new tests) failed 6 of 6
rewritten tests, including a TypeError on the missing legacy_hub kwarg and
an AssertionError expecting rejection where the client instead sent a
plaintext shake. Restoring the fix: full suite 87 passed (baseline 85 at
PR #19's head, +2 net across replaced/added legacy-handshake tests).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
JarbasAl
force-pushed
the
fix/no-automatic-legacy-handshake
branch
from
September 10, 2026 20:53
2ced00b to
e0ce20b
Compare
JarbasAl
marked this pull request as ready for review
September 10, 2026 21:05
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.
Stacked on #19.
The client used to pick the pre-v3 password handshake on its own whenever the hub could not offer Noise: no PSK provisioned, a v2-capped hub,
max_protocol_versionset below 3, or no mutual pattern/suite. This PR removes that automatic choice. A hub that cannot complete Noise is now rejected outright — noshakeresponse is ever sent for it — and the legacy handshake is reachable only through a newlegacy_hubconstructor option, off by default, that prints a loud, removal-dated warning at connect time.max_protocol_versionbelow 3 now requireslegacy_hub=Trueat construction, since it can only ever reach a hub through that same legacy path.HIVEMIND-CRYPTO-1 §3: "The handshake is mandatory on every connection: there is no cleartext, pre-shared-key, or password alternative and no protocol-version ladder to negotiate down." §5: "A node MUST run the mandatory Noise handshake on every connection and reject any peer that cannot complete it, with no cleartext or legacy fallback (§3)."
The removal version is computed from
hivemind/version.py'sVERSIONtuple as the next major (VERSION[0] + 1, currently1.0.0), never hard-coded as a string.Fail-before / green-after (
.venv/bin/python -m pytest test -q -W default -p no:cacheprovider, run against this branch's own venv):test/test_integration.py's existing handshake/bus/ping round-trip tests exercise a v0-v2-only mock hub, so they now passlegacy_hub=Trueexplicitly rather than relying on the removed automatic fallback; nothing else in that suite changed. Baseline at the #19 head was 85 passed; this branch nets 87 (six legacy-fallback tests were rewritten as four rejection tests plus two opt-in tests).Verified by execution: the fail-before/green-after transition above, the full suite pass count, and that no
shakeenvelope is ever sent for a rejected hub (asserted directly inTestNoAutomaticLegacyFallback._assert_rejected). Verified by reading source: the exact clause text, quoted fromJarbasHiveMind/architecture'shivemind-crypto-1.md§3 and its §5 conformance bullet list.