Repository navigation
Conversation
To avoid corner cases ending up with zero allocations in some codepaths (e.g. WinCNG).
vszakats
marked this pull request as draft
October 4, 2026 13:56
group_ordergroup_order to 512 (was: 0)
vszakats
marked this pull request as ready for review
October 4, 2026 15:14
group_order to 512 (was: 0)group_order to 512 (was: 0) in ssh2_dh_key_pair()
vszakats
force-pushed
the
group-order-min
branch
from
October 4, 2026 15:46
45e97c5 to
8e2800b
Compare
ssh2_dh_secret() in the Windows CNG backend uses the server's Diffie-Hellman public value f without the range check the other four backends apply through ssh2_dh_validate(), so a malicious server can send f of 0, 1 or p-1 and push the shared secret into a trivial subgroup that openssl, libgcrypt, mbedtls and os400qc3 all reject with LIBSSH2_ERROR_PROTO. This adds a WinCNG ssh2_dh_validate() that enforces 1 < f < p-1 and the same minimum-set-bits check on the big-endian value, and calls it at the top of ssh2_dh_secret() like the other backends do. The shared test_ssh2_dh_validate() in tests/test_simple.c was stubbed out on WinCNG only because the function did not exist, so it now runs against the real implementation too.
vszakats
force-pushed
the
group-order-min
branch
from
October 4, 2026 15:53
8e2800b to
45b0ee8
Compare
vszakats
marked this pull request as draft
October 4, 2026 16:05
group_order to 512 (was: 0) in ssh2_dh_key_pair()wcng_bn_mod_exp()
vszakats
marked this pull request as ready for review
October 4, 2026 17:39
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused change correctly handles both zero-length output and resize failure.
Review effort: Balanced
Findings: None
What changed in this PR
Updates WinCNG modular exponentiation error handling.
Changes:
- Avoids zero-length bignum resizing.
- Handles resize allocation failures.
| File | Description |
|---|---|
src/wincng.c |
Validates output length and resize success. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
vszakats
added a commit
that referenced
this pull request
Oct 4, 2026
To silence a warning, in rare failure cases: ``` srclimit_penalise: ipv4: new 172.17.0.1/32 deferred penalty of 1.000 seconds for penalty: connections without attempting authentication ``` Ref: https://github.com/libssh2/libssh2/actions/runs/37207427612/job/111451438515?pr=2649#step:25:537 Also: - seize the opportunity and bump sshd debug level to 2. Level 1 is too low to see clearly in some cases. Ref: #2649 Follow-up to 45aa5c5 #2621 Refs: https://man.openbsd.org/sshd_config#PerSourcePenalties https://www.openssh.org/txt/release-9.8 Closes #2650
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.
check
wcng_bn_resize()success. The only call where this check wasmissing.
check if bignum length is non-zero before calling resize.
To fix this clang-tidy warning after applying pending PR wincng: validate Diffie-Hellman public value in ssh2_dh_secret #2645:
Ref: https://github.com/libssh2/libssh2/actions/runs/37005655840/job/110833185040?pr=2645#step:8:62
Bug: wincng: validate Diffie-Hellman public value in ssh2_dh_secret #2645 (comment)
Ref: https://github.com/libssh2/libssh2/actions/runs/37005655840/job/110833185040?pr=2645#step:8:62