Skip to content

Libssh 0.11.2 bump - #89801

Closed
Revertionist wants to merge 3 commits into
ClickHouse:masterfrom
Revertionist:libssh-0.11.2-bump
Closed

Revertionist wants to merge 3 commits into
ClickHouse:masterfrom
Revertionist:libssh-0.11.2-bump

Conversation

@Revertionist

@Revertionist Revertionist commented Nov 10, 2025 •

Copy link
Copy Markdown
Contributor
  • Bumped libssh version from v0.9.8 to v0.11.2

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

@bharatnc bharatnc added the can be tested Allows running workflows for external contributors label Nov 10, 2025
@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d802082]

Summary: ❌

job_name test_name status info comment
Style check failure
cpp failure cidb
PR formatter dropped
Build (arm_tidy) failure
Checkout Submodules failure cidb
Build (amd_debug) dropped
Build (amd_asan) dropped
Build (amd_tsan) dropped
Build (amd_msan) dropped
Build (amd_ubsan) dropped
Build (amd_binary) dropped
Build (arm_asan) dropped

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR. labels Nov 10, 2025
@alexey-milovidov alexey-milovidov added the st-need-info We need extra data to continue (waiting for response). Either some details or a repro of the issue. label Nov 12, 2025
@alexey-milovidov

Copy link
Copy Markdown
Member

Share the motivation for this update, please.

@Revertionist

Copy link
Copy Markdown
Contributor Author

@alexey-milovidov It is for CVE-2025-5318 that customer needs resolved


void SSHSession::disableSocketOwning()
{
#ifdef SSH_OPTIONS_OWNS_SOCKET

@santrancisco santrancisco Nov 13, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag is not set/used anywhere in our CI - but disableSocketOwning is used as part of SSHPtyHandlerFactory

session.disableSocketOwning();
... 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?

@Revertionist Revertionist Nov 13, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, any chance we can upgrade all the way to 0.11.3 ? it seems there are 2 more CVEs that was patched.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rschu1ze rschu1ze Nov 14, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Revertionist Revertionist Nov 14, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep sorted lists sorted.

Comment thread src/Common/SSHWrapper.cpp

# pragma clang diagnostic pop

extern "C" {

@rschu1ze rschu1ze Nov 14, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, never mind, this pr was never merged to there is no public function I can use for signing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that works, I will try building with the current master branch

@Revertionist Revertionist Nov 17, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have raised a new pr for update of libssh
#90362

Comment thread src/Common/SSHWrapper.cpp
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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(lots of whitespace errors below)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog st-need-info We need extra data to continue (waiting for response). Either some details or a repro of the issue. submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants