Skip to content

PQC W0: refuse SHA-1 SSH key exchange, hybrid-only broker TLS - #30

Open
Yoshiofthewire wants to merge 3 commits into
mainfrom
kyguard/pqc-w0
Open

Yoshiofthewire wants to merge 3 commits into
mainfrom
kyguard/pqc-w0

Conversation

@Yoshiofthewire

Copy link
Copy Markdown
Member

In one line: The SSH connector no longer accepts SHA-1 (or any finite-field DH) key exchange, and the broker channel accepts only the hybrid post-quantum TLS group.

What changed

  • The ssh_passwd connector offers exactly mlkem768x25519-sha256, curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256/384/521. A target offering only diffie-hellman-group14-sha1 is refused before any credential is sent.
  • The broker listener and broker client use only X25519MLKEM768. A peer offering only classical X25519 fails the handshake.
  • The pinned-CA verification (pinVerified/verifyListener) is untouched.
  • x/crypto stays at v0.59.0. It already supports mlkem768x25519-sha256, so there is no bump and no new dependency.
  • DECISIONS 80 and 81, plus a CHANGELOG Security entry.

Review this

  • internal/brokerproto/tls.go: curves is now hybrid-only. Spec §4.1 literally lists [X25519MLKEM768, X25519]. The owner approved the departure on 2026-11-25 (PQC plan Q9). DECISIONS 81 records it, and SPEC.md is left as signed.
  • internal/connectors/sshpasswd/sshpasswd.go: keyExchanges. Under fips140=on, x/crypto registers no curve25519, so the list narrows to the hybrid plus NIST ECDH.
  • Safe to skip: the test files, which are self-contained in-process servers.

Checked: the full Go suite with race, plain and fips140=on, on SQLite and on PostgreSQL 17. The Docker connector suites (Samba AD, OpenSSH 9.2) pass. All 8 mutations below are caught. Not checked: a real OpenSSH ≥ 9.9 negotiating mlkem768x25519-sha256. The CI image is Debian bookworm OpenSSH 9.2 (it negotiates curve25519-sha256), so the ML-KEM case is proven only against the x/crypto server.

Decided for you: diffie-hellman-group14-sha256 and group16/18-sha512 are also refused, because they are not on the approved list. Targets need OpenSSH ≥ 5.7 (ECDH).

You need to: review. Hold unmerged per KyGuard rules.

§13 checklist: none new. This is PQC plan W0 hardening of the Phase 1A SSH connector (#14) and the Phase 0 broker listener (#8).

Detail

Tests

  • TestKeyExchangeNegotiated: an x/crypto server offering each listed exchange alone, plus one offering curve25519, ecdh-p256, mlkem768x25519. The test asserts the negotiated exchange from the server side (AlgorithmsConnMetadata.Algorithms().KeyExchange). The curve25519 cases skip under fips140=on.
  • TestKeyExchangeWithoutAListedAlgorithmIsRefused: servers offering only group14-sha1, group1-sha1 or group14-sha256. Login fails and the server sees no credential.
  • TestBrokerTLSNegotiatesTheHybrid: ServerTLS with ClientTLS. ConnectionState().CurveID == X25519MLKEM768 on both ends.
  • TestListenerRefusesAClassicalClient: an X25519-only client is refused by ServerTLS.
  • TestBrokerClientOffersOnlyTheHybrid: a listener preferring X25519 still gets the hybrid, and an X25519-only listener is refused by ClientTLS.

Mutation table (run on a throwaway copy)

# Mutation Fails
M1 drop Config: ssh.Config{KeyExchanges: …} (library default) …IsRefused/group14-sha1, /group14-sha256
M2 drop mlkem768x25519-sha256 from the list TestKeyExchangeNegotiated/mlkem768x25519-sha256
M3 add diffie-hellman-group14-sha1 to the list …IsRefused/group14-sha1
M4 curves = [X25519MLKEM768, X25519] (the old code) TestListenerRefusesAClassicalClient, TestBrokerClientOffersOnlyTheHybrid
M5 server only appends X25519 TestListenerRefusesAClassicalClient
M6 client only appends X25519 TestBrokerClientOffersOnlyTheHybrid
M7 curves = [X25519] all three TLS tests
M8 remove CurvePreferences (Go defaults) TestListenerRefusesAClassicalClient, TestBrokerClientOffersOnlyTheHybrid

The unmutated copy passes all of them.

Commands

  • kjob <copy> 'gofmt; go mod verify; go vet; go build; go test -p 2 -race ./...; GODEBUG=fips140=on go test -p 2 -race ./...': all K hosts were busy, so this ran on Major. Exit 0, 42 packages ok.
  • PostgreSQL: kjob --pg got exit 75 (all K hosts busy). It ran on Major under kslot with a throwaway postgres:17-alpine container (removed by a trap), race, plain and fips140=on. Exit 0.
  • KY_TEST_DOCKER=1 kslot go test -race -count=1 -v ./internal/connectors/...: exit 0. The OpenSSH image lists curve25519-sha256, its @libssh.org alias and ecdh-sha2-nistp256/384/521 (ssh -Q kex on bookworm OpenSSH_9.2).
  • go mod tidy: no change. scripts/check-release-notes.py --base origin/main: ok.
  • No govulncheck run, because no dependency changed.

Background: ky-primitives#80, docs/superpowers/specs/2026-11-25-pqc-stack-plan.md W0 rows 2 and 10, and Q9.

🤖 Generated with Claude Code

Yoshiofthewire and others added 2 commits November 25, 2026 21:48
The ssh_passwd connector now sets KeyExchanges explicitly (hybrid ML-KEM,
curve25519, NIST ECDH), so a target offering only diffie-hellman-group14-sha1
is refused before any credential is sent. The broker listener and client
use only X25519MLKEM768 (PQC plan W0, Q9; DECISIONS 80, 81).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Copy link
Copy Markdown
Member Author

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪

🧪 PR contains tests

⚡ No major issues detected


Advisory only: this comment never gates the pull request.
gpt-6.1-sol using pr-agent on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Security review - cleared

Detail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kyguard-server-30, where it is readable by the operator and expires seven days after the last post.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Autonomous review - 1/1 personas cleared

  • security: cleared

Merging remains a human decision; this bot never approves.


gpt-6.1-sol using security-audit on behalf of Yoshi

Resolves docs/DECISIONS.md: main's broker decision 78 and this PR's PQC
section (80, 81) are both kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant