Skip to content

Reject the KEX replies a server never receives - #1221

Merged
ejohnstown merged 1 commit into
wolfSSL:masterfrom
gasbytes:zd-22394
Sep 2, 2026
Merged

Reject the KEX replies a server never receives#1221
ejohnstown merged 1 commit into
wolfSSL:masterfrom
gasbytes:zd-22394

Conversation

@gasbytes

@gasbytes gasbytes commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Refuse the two key exchange messages that only a server ever sends (31 and 33), at any point in the connection, so a peer cannot make the server run expensive prime-number checks on a value of its own choosing.

Also added a regression test called TestServerOnlyKexMsgsBlocked in tests/regress.c.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is a small, targeted hardening in the server message gate and is backed by a focused regression test covering both initial key exchange and rekey behavior.

Pull request overview

This PR hardens the server receive path by rejecting server-only key exchange message IDs (31 and 33) at any point in a connection, preventing a peer from triggering expensive DH prime/group processing on attacker-controlled inputs.

Changes:

  • Block server-only KEX messages (KEXDH_REPLY / KEXDH_GEX_GROUP and KEXDH_GEX_REPLY) in the server-side message-allowance gate.
  • Add a regression test (TestServerOnlyKexMsgsBlocked) validating the server rejects these messages both during initial keying and during rekey, while still accepting the expected client GEX request message.
File summaries
File Description
tests/regress.c Adds regression coverage ensuring server-only KEX message IDs are rejected across relevant states.
src/internal.c Extends server-side message filtering to refuse server-only KEX replies early in packet dispatch.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/internal.c
@gasbytes
gasbytes marked this pull request as ready for review September 2, 2026 08:59
@gasbytes gasbytes assigned ejohnstown and unassigned gasbytes Sep 2, 2026
@ejohnstown
ejohnstown self-requested a review September 2, 2026 15:13
@ejohnstown
ejohnstown merged commit a472f1e into wolfSSL:master Sep 2, 2026
172 of 173 checks passed
ejohnstown pushed a commit that referenced this pull request Sep 2, 2026
This is just a follow-up PR to (#1221), that mirrors pretty much the same changes for the client side too.
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.

3 participants