Repository navigation
Conversation
"The size check for reading the 4-byte status field is incorrect: `data_len < 8` doesn't account for the variable-length response name that `publickey_response_id()` advances `s` past. A truncated packet like `[len=6]["status"]` (10 bytes total) will pass the current check but still cause an out-of-bounds read in `ssh2_ntohu32(s)`. The check should ensure there are at least 4 bytes remaining at `s`." Bug: libssh2#2144 (comment)
There was a problem hiding this comment.
Pull request overview
This PR fixes a potential out-of-bounds read in the publickey subsystem response parsing by correcting the length check to account for the variable-length response name consumed by publickey_response_id() before reading the 4-byte status value.
Changes:
- Update
publickey_response_success()to validate there are at least 4 bytes remaining at the advanced pointersbefore callingssh2_ntohu32(s).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 5, 2026
Reported-by: Haruki Oyama Follow-up to ceaa7e1 libssh2#2147
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 17, 2026
Reported-by: Haruki Oyama Follow-up to ceaa7e1 libssh2#2147
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.
"The size check for reading the 4-byte status field is incorrect:
data_len < 8doesn't account for the variable-length response namethat
publickey_response_id()advancesspast. A truncated packetlike
[len=6]["status"](10 bytes total) will pass the current checkbut still cause an out-of-bounds read in
ssh2_ntohu32(s). The checkshould ensure there are at least 4 bytes remaining at
s."Reported by Copilot
Bug: #2144 (comment)