Skip to content

fix: reject service messages while keying - #1200

Merged
philljj merged 1 commit into
wolfSSL:masterfrom
ejohnstown:sf21
Aug 28, 2026
Merged

fix: reject service messages while keying#1200
philljj merged 1 commit into
wolfSSL:masterfrom
ejohnstown:sf21

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

RFC 4253 section 7.1 bars SERVICE_REQUEST and SERVICE_ACCEPT between a
KEXINIT and the matching NEWKEYS. The admission check now consults
ssh->isKeying, which acceptState and connectState do not track.

  • gate MSGID_SERVICE_REQUEST on isKeying in IsMessageAllowedServer()
  • gate MSGID_SERVICE_ACCEPT on isKeying in IsMessageAllowedClient()
  • add unit and receive-path coverage in tests/regress.c

Issue: F-10569

Copilot AI lite review requested due to automatic review settings August 27, 2026 19:57

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.

Pull request overview

This PR enforces RFC 4253 §7.1 by rejecting SERVICE_REQUEST / SERVICE_ACCEPT messages that arrive while a key exchange (initial KEX or rekey) is in flight, using ssh->isKeying as the definitive signal rather than relying only on acceptState / connectState.

Changes:

  • Block MSGID_SERVICE_REQUEST on the server side when ssh->isKeying is set.
  • Block MSGID_SERVICE_ACCEPT on the client side when ssh->isKeying is set.
  • Add regression tests covering both the direct “IsMessageAllowed” path and the full receive path during rekey.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/internal.c Adds isKeying-based gating for service messages to comply with RFC 4253 §7.1 during rekey/keying windows.
tests/regress.c Adds unit + receive-path regression coverage to ensure service messages are rejected during keying and accepted afterward.

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

RFC 4253 section 7.1 bars SERVICE_REQUEST and SERVICE_ACCEPT between a
KEXINIT and the matching NEWKEYS. The admission check now consults
ssh->isKeying, which acceptState and connectState do not track. It tests
WOLFSSH_PEER_IS_KEYING, as the KEXINIT gate below it does: a peer that
has not seen our KEXINIT yet may still legally send.

- gate MSGID_SERVICE_REQUEST on isKeying in IsMessageAllowedServer()
- gate MSGID_SERVICE_ACCEPT on isKeying in IsMessageAllowedClient()
- record the refusals as WS_MSGID_NOT_ALLOWED_E, the code DoReceive()
  stores anyway, rather than WS_REKEYING, a soft retry-later status
- add unit and receive-path coverage in tests/regress.c

Issue: F-10569

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #1200

Scan targets checked: wolfssh-bugs, wolfssh-src

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

@ejohnstown
ejohnstown requested a review from philljj August 28, 2026 22:30
@philljj philljj self-assigned this Aug 28, 2026
@philljj
philljj merged commit 89b8055 into wolfSSL:master Aug 28, 2026
166 checks passed
@ejohnstown
ejohnstown deleted the sf21 branch August 28, 2026 22:54
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.

4 participants