Skip to content

kex: disable SHA1-based methods by default - #2443

Closed
vszakats wants to merge 3 commits into
libssh2:masterfrom
vszakats:disinsec1
Closed

vszakats wants to merge 3 commits into
libssh2:masterfrom
vszakats:disinsec1

Conversation

@vszakats

@vszakats vszakats commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Also:

  • RELEASE-NOTES: announce removal after next release.
  • allow build-time macro to enable in the meantime.
  • keep testing in CI with other legacy options.

@willco007

Copy link
Copy Markdown
Member

Can it just be removed from the default key exchange list? Seems disabling the entire code block isn't strictly necessary?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens libssh2’s default key-exchange (KEX) security posture by compiling out SHA1-based KEX methods unless explicitly re-enabled at build time, while ensuring CI continues to exercise the legacy code paths.

Changes:

  • Guard SHA1-based Diffie-Hellman KEX implementations and method registrations behind LIBSSH2_KEX_SHA1_ENABLE.
  • Document the new default in RELEASE-NOTES, including how to re-enable SHA1-based KEX at compile time.
  • Update CI “legacy-options” builds to define LIBSSH2_KEX_SHA1_ENABLE so the disabled-by-default paths remain tested.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/kex.c Wraps SHA1-based KEX methods and their entries in the KEX method table with #ifdef LIBSSH2_KEX_SHA1_ENABLE.
RELEASE-NOTES Adds a deprecation note indicating SHA1-based KEX methods are disabled by default and can be re-enabled via -DLIBSSH2_KEX_SHA1_ENABLE.
.github/workflows/ci.yml Ensures legacy-option CI jobs compile with -DLIBSSH2_KEX_SHA1_ENABLE so SHA1 KEX code remains covered.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vszakats vszakats closed this in 99f9353 Jul 28, 2026
@vszakats
vszakats deleted the disinsec1 branch July 28, 2026 23:09
vszakats added a commit that referenced this pull request Jul 29, 2026
Also:
- RELEASE-NOTES: announce removal after next release.
- allow build-time macro to enable in the meantime.
- skip in tests if disabled.
- keep testing in CI with other legacy options.
- workaround oss-fuzzer hang and timeout after 10 minutes by keeping
  SHA1-based MACs enabled in the fuzzer build.
  Ref: #2444 (comment)

Follow-up to 99f9353 #2443

Closes #2444
vszakats added a commit that referenced this pull request Jul 30, 2026
vszakats added a commit that referenced this pull request Aug 3, 2026
…x fallouts

They are `ssh-rsa` and `[email protected]`, and insecure due
to their reliance on SHA1 hashes.

Also:
- hostkey: fix to accept all RSA hostkey methods in common
  `hostkey_method_ssh_rsa_init()`.
- mbedtls: add missing RSA SHA1/SHA2 guards.
- mbedtls: cleanup on error in `mbed_pub_priv_key()`.
- os400qc3: add missing RSA SHA1/SHA2 guards. (untested)
- wincng: add missing RSA SHA1/SHA2 guards.
- crypto.h: add missing `#endif` comments.
- GHA: move stray `-DLIBSSH2_DSA_ENABLE` to its place.
  Follow-up to b7ab0fa #1435
- tests: fix to guard RSA tests with `LIBSSH2_RSA`, replacing
  `LIBSSH2_RSA_SHA1` to keep test coverage. Keep using the latter for
  testing SHA1-based signatures in `test_auth_pubkey_ok_rsa_signed`.

Follow-up to 3e14d67 #2444
Follow-up to 99f9353 #2443

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants