Skip to content

mac: disable SHA1-based MACs by default - #2444

Closed
vszakats wants to merge 5 commits into
libssh2:masterfrom
vszakats:macsha1
Closed

vszakats wants to merge 5 commits into
libssh2:masterfrom
vszakats:macsha1

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.
  • 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: mac: disable SHA1-based MACs by default #2444 (comment)

Follow-up to 99f9353 #2443

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 disables SHA1-based MAC algorithms (hmac-sha1, [email protected], hmac-sha1-96) by default in libssh2, while preserving an opt-in build-time escape hatch (LIBSSH2_HMAC_SHA1_ENABLE). It updates the test harness to skip SHA1 MAC test cases when those algorithms are compiled out, and ensures CI still exercises these legacy algorithms in the “legacy-options” matrix.

Changes:

  • Compile out SHA1-based MAC method implementations and registration unless LIBSSH2_HMAC_SHA1_ENABLE is defined.
  • Skip SHA1 MAC tests by default when SHA1 MACs are disabled at build time.
  • Document the default-disable + opt-in macro in RELEASE-NOTES and enable it in CI legacy-options jobs.

Reviewed changes

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

File Description
tests/session_fixture.c Skips SHA1 MAC-related tests when SHA1 MACs are not enabled at build time.
src/mac.c Gates SHA1 MAC implementations and their registration behind LIBSSH2_HMAC_SHA1_ENABLE.
RELEASE-NOTES Documents that SHA1 MACs are now disabled by default and can be re-enabled via macro.
.github/workflows/ci.yml Ensures legacy CI configurations still test with SHA1 MACs enabled.

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

@vszakats

vszakats commented Jul 28, 2026 •

Copy link
Copy Markdown
Member Author

Nice, the fuzzer is hanging after this change too.
I'm at loss why.

Same effect as seen here: #2199

vszakats added 5 commits July 29, 2026 02:30
… minutes

```
2026-07-28 23:29:54,441 - root - INFO - Starting fuzzing
Traceback (most recent call last):
  File "/opt/oss-fuzz/infra/cifuzz/run_fuzzers_entrypoint.py", line 106, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/oss-fuzz/infra/cifuzz/run_fuzzers_entrypoint.py", line 102, in main
    return run_fuzzers_entrypoint()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oss-fuzz/infra/cifuzz/run_fuzzers_entrypoint.py", line 72, in run_fuzzers_entrypoint
    result = run_fuzzers.run_fuzzers(config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oss-fuzz/infra/cifuzz/run_fuzzers.py", line 316, in run_fuzzers
    if not fuzz_target_runner.run_fuzz_targets():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oss-fuzz/infra/cifuzz/run_fuzzers.py", line 131, in run_fuzz_targets
    result = self.run_fuzz_target(target)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oss-fuzz/infra/cifuzz/run_fuzzers.py", line 259, in run_fuzz_target
    return fuzz_target_obj.fuzz()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/oss-fuzz/infra/cifuzz/fuzz_target.py", line 209, in fuzz
    result = engine_impl.fuzz(self.target_path, options, artifacts_dir,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clusterfuzz/_internal/bot/fuzzers/libFuzzer/engine.py", line 278, in fuzz
    fuzz_result = runner.fuzz(
                  ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clusterfuzz/_internal/bot/fuzzers/libfuzzer.py", line 401, in fuzz
    return LibFuzzerCommon.fuzz(self, corpus_directories, fuzz_timeout,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clusterfuzz/_internal/bot/fuzzers/libfuzzer.py", line 217, in fuzz
    return self.run_and_wait(
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clusterfuzz/_internal/system/new_process.py", line 419, in run_and_wait
    result = ProcessRunner.run_and_wait(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clusterfuzz/_internal/system/new_process.py", line 403, in run_and_wait
    result = wait_process(
             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clusterfuzz/_internal/system/new_process.py", line 110, in wait_process
    output = process.communicate(input_data)[0]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clusterfuzz/_internal/system/new_process.py", line 190, in communicate
    stdout, stderr = self._popen.communicate(input)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/subprocess.py", line 1201, in communicate
    self.wait()
  File "/usr/local/lib/python3.11/subprocess.py", line 1264, in wait
    return self._wait(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/subprocess.py", line 2053, in _wait
    (pid, sts) = self._try_wait(0)
                 ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/subprocess.py", line 2011, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
```
https://github.com/libssh2/libssh2/actions/runs/30407183421
@vszakats

Copy link
Copy Markdown
Member Author

Work around oss-fuzz hang/timeout by keeping the insecure MACs enabled in that build.

It's suspicious that it's now the second hang caused by touching the elements of algo
lists. Is there maybe an issue in the kex_agree_*() functions, or is there perhaps
something wired up in the fuzzer input set that interacts badly with libssh2 changes?

@vszakats vszakats closed this in 3e14d67 Jul 29, 2026
@vszakats
vszakats deleted the macsha1 branch July 29, 2026 00:53
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.

2 participants