-
Notifications
You must be signed in to change notification settings - Fork 115
fix: validate DH GEX request bounds #1089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7253,6 +7253,16 @@ static int DoKexDhGexRequest(WOLFSSH* ssh, | |
| ret = GetUint32(&ssh->handshake->dhGexMaxSz, buf, len, &begin); | ||
| } | ||
|
|
||
| if (ret == WS_SUCCESS) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [Medium] New DH GEX request validation has no regression coverage This PR changes externally visible server behavior by rejecting malformed DH GEX request sizes, but no tests were added. The only existing Recommendation: Cover the new rejection paths through |
||
| if (ssh->handshake->dhGexMinSz < WOLFSSH_DEFAULT_GEXDH_MIN || | ||
| ssh->handshake->dhGexMaxSz > WOLFSSH_DEFAULT_GEXDH_MAX || | ||
| ssh->handshake->dhGexMinSz > ssh->handshake->dhGexPreferredSz || | ||
| ssh->handshake->dhGexPreferredSz > ssh->handshake->dhGexMaxSz) { | ||
| WLOG(WS_LOG_DEBUG, "Invalid DH GEX request parameters"); | ||
| ret = WS_BAD_ARGUMENT; | ||
| } | ||
|
Comment on lines
+7256
to
+7263
|
||
| } | ||
|
Comment on lines
+7256
to
+7264
|
||
|
|
||
| if (ret == WS_SUCCESS) { | ||
| WLOG(WS_LOG_INFO, " min = %u, preferred = %u, max = %u", | ||
| ssh->handshake->dhGexMinSz, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 [High] DH GEX validation accepts ranges the server cannot satisfy
🚫 BLOCK
bugThe new validation accepts any ordered request inside
WOLFSSH_DEFAULT_GEXDH_MIN..WOLFSSH_DEFAULT_GEXDH_MAX, then immediately callsSendKexDhGexGroup(). That send path always emitsdhPrimeGroup14, a 2048-bit group. A request such asmin=3072, preferred=3072, max=4096passes the new check but cannot be satisfied by the current server implementation, so the server still sends a group outside the client's requested range. The PR-added validation gate should match what this path can actually produce, or select a supported group within the requested range.Recommendation: Reject unsatisfiable ranges such as
dhGexMinSz > 2048ordhGexMaxSz < 2048while the GEX server path is hard-coded to group14, or implement group selection before sending.