Repository navigation
knownhost: fix out-of-bounds read in knownhost_line_hashed()
#2363
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
Closed
abdul-khaliq-khalid
wants to merge
1
commit into
libssh2:master
from
abdul-khaliq-khalid:knownhost-parse-bounds
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
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.
Proposing to fix the root cause of this: #2364
Uh oh!
There was an error while loading. Please reload this page.
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.
I suspect this may fix this address sanitizer report seen a few days ago:
https://github.com/libssh2/libssh2/actions/runs/29666842385/job/88138609820?pr=2350#step:5:729
Since this looks like a separate issue, I'd test and merge this change in
a separate PR, if you don't mind?
(till we decide on #2364, which is breaking and needs a decision.)
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.
Merging it as-os, to keep it simple and keep the PR message.
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.
Not at all, that split makes sense to me. I've dropped the keylen hunk here, so this PR is now just the
hostlen-bounded salt scan, and the empty-key path is yours to land wherever it fits best.Agreed that #2364 is the better place for it. Fixing it at the parse layer only papers over the
strlen()fallback, and the fallback is the actual hazard since any caller passing an unterminated key with zero keylen hits the same thing. The one thing worth weighing is that the behavior is documented inlibssh2.h, so returningLIBSSH2_ERROR_BAD_USEwill break callers that rely on it. If that turns out to be too disruptive, the parse-layer check is still available as the narrow fix.Rebuilt with asan after the trim: the hashed case is silent and valid plain plus hashed lines still return rc=0. checksrc and spacecheck are clean.