Repository navigation
Libssh 0.11.2 bump - #89801
Libssh 0.11.2 bump#89801Revertionist wants to merge 3 commits into
Conversation
|
Workflow [PR], commit [d802082] Summary: ❌
|
|
Share the motivation for this update, please. |
|
@alexey-milovidov It is for CVE-2025-5318 that customer needs resolved |
|
|
||
| void SSHSession::disableSocketOwning() | ||
| { | ||
| #ifdef SSH_OPTIONS_OWNS_SOCKET |
There was a problem hiding this comment.
This flag is not set/used anywhere in our CI - but disableSocketOwning is used as part of SSHPtyHandlerFactory
... From what i can tell and from the comment here by the author of the feature, it seems the socket is passed to SSH lib and in this case, i assume if it closes the socket prematurely , we can end up with dangling pointer/file descriptor? Is there a reason why we do this here?There was a problem hiding this comment.
The #ifdef guard is necessary because SSH_OPTIONS_OWNS_SOCKET was removed/not present in libssh 0.11.2 that we're trying to upgrade to. Without it the build was initially failing. The guard allows the code to work with both the patched older versions and the unpatched newer versions
There was a problem hiding this comment.
ok ... this is quite a problem but I finally got to the bottom of it as I try to understand what logic/code we are removing and could not find SSH_OPTIONS_OWNS_SOCKET anywhere in libssh upstream.
As it turns out, the previous author actually forked & patched libssh in their own forked version (perhaps in attempt to keep the ssh code away from main ClickHouse code?) and these patches actually never made it upstream - So now it becomes problematic as on every update, the team has to maintain the custom code , example from @rschu1ze : ClickHouse/libssh#9
So thank you for this PR as it would be nice to move away from managing these custom logic but can I also trouble you to help taking a look and see what the previous changes need to be brought over from the previous code?
There was a problem hiding this comment.
Also, any chance we can upgrade all the way to 0.11.3 ? it seems there are 2 more CVEs that was patched.
There was a problem hiding this comment.
Ah, I see. This clears up a lot of confusion as a major chunk of code update in this pr was due to me not being able to find 2 private key integration functions in libssh 0.11.2 (pki_sign_string and pki_verify_string). I see that these functions were added manually in Clickhouse/libssh#9.
So do I migrate over all these random changes that are in the example PR you provided?
Also, yes we can upgrade all the way to 0.11.3.
There was a problem hiding this comment.
@santrancisco Sure, I can look into removing the custom logic but before that I would need to know the reason behind why these custom logic were introduced into the library. That reason may prevent me from removing the custom logic still.
From going though all the PRs I see @InfJoker made some patches https://gitlab.com/libssh/libssh-mirror/-/issues/248#note_1849734946 but like me they are also not a core contributor to Clickhouse
Who could help me understand a bit more about the custom logic?
There was a problem hiding this comment.
Wow, that was a time ago. Let's see
Option is not required anymore as far as I can see due to https://gitlab.com/libssh/libssh-mirror/-/commit/07cb0be12f4a3d5691f6a580343cb94d658decf5 and should be in 0.11.
For signing signature, I see it got commited into upstream from commit https://gitlab.com/libssh/libssh-mirror/-/commit/28c0056bca4f5ea3223db8150de4771aedc9eef7, and pr https://gitlab.com/libssh/libssh-mirror/-/merge_requests/536. So can adapt to modified interface during review https://gitlab.com/libssh/libssh-mirror/-/commit/67cf8e370212700e545a30a8b5a10b5e147c34c7. Updating to upstream and killing custom fork should hopefully resolve the pain. Sorry for inconvenience
There was a problem hiding this comment.
FYI: SSH authentication is currently experimental in ClickHouse.
We should indeed try to avoid patching libssh as much as possible and in particular not carry ClickHouse/libssh#9 forward to 0.11.3.
Unfortunately, https://github.com/ClickHouse/libssh is technically not a fork of something, it is a code dump (probably because upstream development doesn't happen on GitHub and the only mirror repo on GitHub I could find is outdated). So this complicates updating.
What confuses me is that this PR references a branch (or tag) libssh-0.11.2 but I couldn't find it in the submodule repository: https://github.com/ClickHouse/libssh/branches/all?query=
But anyways, I just created a proper branch ClickHouse/libssh-0.11.3 (https://github.com/ClickHouse/libssh/tree/ClickHouse/libssh-0.11.3). Kindly reference it from this PR.
There was a problem hiding this comment.
What confuses me is that this PR references a branch (or tag) libssh-0.11.2 but I couldn't find it in the submodule repository
That's a mistake on my part, while building clickhouse on my system I added the gitlab repository as upstream and fetched a commit from there which points to 0.11.2. I did this since as you mentioned, libssh code on GitHub is outdated.
I will correct this by referencing the GitHub libssh PR you provided, thank you.
There was a problem hiding this comment.
@InfJoker this information helps a lot, thank you. And sorry for dragging you back into this issue 😅
| ${LIB_SOURCE_DIR}/src/options.c | ||
| ${LIB_SOURCE_DIR}/src/server.c | ||
| ${LIB_SOURCE_DIR}/src/ttyopts.c | ||
| ${LIB_SOURCE_DIR}/src/getrandom_crypto.c |
There was a problem hiding this comment.
Let's keep sorted lists sorted.
|
|
||
| # pragma clang diagnostic pop | ||
|
|
||
| extern "C" { |
There was a problem hiding this comment.
@Revertionist Please explain why the forward explanations in l. 14-46 are added. Why is include-ing headers from libssh not sufficient?
(Side note: L. 17, 25, 27, 37, 39, 41 contain whitespace errors.)
There was a problem hiding this comment.
This was ment to replace the 2 private key integration functions that were being added as custom code into libssh. But as @InfJoker kindly mentioned there are signing functions added into libssh here https://gitlab.com/libssh/libssh-mirror/-/merge_requests/536/diffs. Perhaps I will try referencing these instead.
Will fix the whitespace error, thanks for pointing them out.
There was a problem hiding this comment.
Ah, never mind, this pr was never merged to there is no public function I can use for signing.
There was a problem hiding this comment.
There was a problem hiding this comment.
then could it be that the change isn't back ported to 0.11.3? because I don't see the functions here https://github.com/ClickHouse/libssh/blob/ClickHouse/libssh-0.11.3/src/libssh.map
There was a problem hiding this comment.
We (ClickHouse) usually prefer to reference non-development versions of submodules, but we can make an exception here and reference master, so we wouldn't need to implement the functions on our end just to throw them out in the next upgrade.
There was a problem hiding this comment.
I suppose that works, I will try building with the current master branch
There was a problem hiding this comment.
I have opened a pr to sync master branch from the GitLab libssh-mirror repo to the GitHub Clickhouse/libssh.
Since I don't have the access to create a ClickHouse/master branch. Could you create one for me to merge into? @rschu1ze
There was a problem hiding this comment.
Here is the branch you are looking for: https://github.com/ClickHouse/libssh/tree/master-2025-11-17
(We could alternatively make the libssh entry in .gitmodules point to the upstream repository ... unfortunately, this tends to break people's repositories (I have done this multiple times)).
There was a problem hiding this comment.
I have raised a new pr for update of libssh
#90362
| if (int rc = pki_sign_string(key, input_str.get(), &output); rc != SSH_OK) | ||
| throw Exception(ErrorCodes::LIBSSH_ERROR, "Error singing with ssh key"); | ||
| SSHString output_str(output); | ||
| enum ssh_keytypes_e key_type = ssh_key_type(key); |
There was a problem hiding this comment.
(lots of whitespace errors below)
Changelog category (leave one):