Repository navigation
src: check the return value from _libssh2_bn_*() functions - #1354
Merged
vszakats merged 9 commits intoApr 8, 2024
Merged
Conversation
_libssh2_bn_from_bin
vszakats
reviewed
Apr 5, 2024
_libssh2_bn_from_bin_libssh2_bn_from_bin()
vszakats
reviewed
Apr 8, 2024
Co-authored-by: Viktor Szakats <[email protected]>
vszakats
reviewed
Apr 8, 2024
Contributor
Author
|
I have no further changes for this PR. Thank you so much, @vszakats for pointing out a few issues. |
_libssh2_bn_from_bin()_libssh2_bn_*() functions
Member
|
No worries, thank you for the PR! |
agreppin
pushed a commit
to agreppin/libssh2
that referenced
this pull request
Jul 14, 2024
…#1354) Found by oss-fuzz. In `diffie_hellman_sha_algo()`, we were calling `_libssh2_bn_from_bin()` with data recieved by the server without checking whether that data was zero-length or ridiculously long. In the OpenSSL backend, this would cause `_libssh2_bn_from_bin()` to fail an allocation, which would eventually lead to a NULL dereference when the bignum was used. Add the same check for `_libssh2_bn_set_word()` and `_libssh2_bn_to_bin()`.
vszakats
added a commit
that referenced
this pull request
Sep 7, 2026
It was returning a non-NULL address on success, which translated to permanent failure as mapped to this internal crypto API. Fix to match it with the rest of crypto backends and the expectation of callers. Reported by Copilot Bug: #2595 (comment) Follow-up to 95c824d #1354 Follow-up to c9d40af Closes #2596
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.
Found by oss-fuzz. In
diffie_hellman_sha_algo(), we were calling_libssh2_bn_from_bin()with data recieved by the server withoutchecking whether that data was zero-length or ridiculously long.
In the OpenSSL backend, this would cause
_libssh2_bn_from_bin()to fail an allocation, which would eventually lead to a NULL
dereference when the bignum was used.
Add the same check for
_libssh2_bn_set_word()and_libssh2_bn_to_bin().