Skip to content

Tighten MAC guards, boolean decode and KEX guess - #1284

Open
ejohnstown wants to merge 3 commits into
wolfSSL:masterfrom
ejohnstown:sf32
Open

ejohnstown wants to merge 3 commits into
wolfSSL:masterfrom
ejohnstown:sf32

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

Three small fixes in the transport and KEX code.

  • CreateMac() and VerifyMac() guard each HMAC case with its WOLFSSH_NO_HMAC_* flag (F-12545).
  • GetBoolean() stores any nonzero wire byte as 1, per RFC 4251 section 5 (F-12573).
  • Only the server skips a wrongly guessed KEX packet, since every supported KEX opens with a client message; a client logs a server's first_kex_packet_follows flag and ignores it (F-10585).

Wrap the ID_HMAC_SHA2_256 case in CreateMac() and each HMAC case in
VerifyMac() in its WOLFSSH_NO_HMAC_* gate, so a build without a MAC
drops that case in both directions.

Issue: F-12545
GetBoolean() stores any nonzero wire byte as 1, per RFC 4251 section 5,
so callers and callbacks such as hasSignature see only 0 or 1.

- tests: add test_GetBoolean covering 0, 1 and other nonzero bytes

Issue: F-12573
Every supported KEX method opens with a client message, so only the
client can send a guessed packet (RFC 4253 section 7.1). DoKexInit()
sets ignoreNextKexMsg only on the server and logs a server's flag on
the client; DoKexDhReply() and DoKexDhGexGroup() no longer skip.

- tests: client KEXINIT with a wrong-guess follows flag does not skip
- tests: client KEXDH_REPLY and GEX_GROUP parse even with the flag set
- tests: the skip case helper drives only the server

Issue: F-10585
Copilot AI balanced review requested due to automatic review settings September 29, 2026 23:07

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.

Copilot review overview

🟢 Approval recommended

The changes are internally consistent, appropriately guarded, and covered by focused tests.

Review effort: Balanced
Findings: None

What changed in this PR

Tightens SSH transport parsing and algorithm handling for standards compliance and selective builds.

Changes:

  • Normalizes decoded SSH booleans.
  • Limits guessed-KEX packet skipping to servers.
  • Adds per-algorithm HMAC guards and regression tests.
File Description
src/​internal.c Updates boolean, KEX, and MAC handling.
tests/​unit.c Tests boolean normalization and bounds.
tests/​regress.c Tests endpoint-specific KEX guess behavior.

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

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.

2 participants