fix: reject service messages while keying - #1200
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_REQUESTon the server side whenssh->isKeyingis set. - Block
MSGID_SERVICE_ACCEPTon the client side whenssh->isKeyingis 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
ejohnstown
requested review from
wolfSSL-Fenrir-bot
and removed request for
wolfSSL-Fenrir-bot
August 27, 2026 20:53
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
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.
philljj
approved these changes
Aug 28, 2026
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.
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.
Issue: F-10569