Skip to content

Fixed prompt text no longer being copied to the prompts struct - #2

Closed
willco007 wants to merge 1 commit into
libssh2:masterfrom
willco007:willco007-patch-1
Closed

willco007 wants to merge 1 commit into
libssh2:masterfrom
willco007:willco007-patch-1

Conversation

@willco007

Copy link
Copy Markdown
Member

Regression in 1.5 from 1.4.4.

@bagder

bagder commented Mar 11, 2015

Copy link
Copy Markdown
Member

Argh, fixed in commit fe3e230. Regression was introduced by me in 031566f.

Thanks!

@bagder bagder closed this Mar 11, 2015
@willco007
willco007 deleted the willco007-patch-1 branch March 11, 2015 22:13
@ghost ghost mentioned this pull request Apr 18, 2016
willco007 pushed a commit that referenced this pull request Jul 15, 2019
…386)

File: userauth.c

Credit: 
Etienne Samson

Notes: 
Caught by ASAN:

=================================================================
==73797==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60700001bcf0 at pc 0x00010026198d bp 0x7ffeefbfed30 sp 0x7ffeefbfe4d8
READ of size 69 at 0x60700001bcf0 thread T0
2019-07-04 08:35:30.292502+0200 atos[73890:2639175] examining /Users/USER/*/libssh2_clar [73797]
    #0 0x10026198c in wrap_memchr (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x1f98c)
    #1 0x1000f8e66 in file_read_publickey userauth.c:633
    #2 0x1000f2dc9 in userauth_publickey_fromfile userauth.c:1513
    #3 0x1000f2948 in libssh2_userauth_publickey_fromfile_ex userauth.c:1590
    #4 0x10000e254 in test_userauth_publickey__ed25519_auth_ok publickey.c:69
    #5 0x1000090c3 in clar_run_test clar.c:260
    #6 0x1000038f3 in clar_run_suite clar.c:343
    #7 0x100003272 in clar_test_run clar.c:522
    #8 0x10000c3cc in main runner.c:60
    #9 0x7fff5b43b3d4 in start (libdyld.dylib:x86_64+0x163d4)

0x60700001bcf0 is located 0 bytes to the right of 80-byte region [0x60700001bca0,0x60700001bcf0)
allocated by thread T0 here:
    #0 0x10029e053 in wrap_malloc (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x5c053)
    #1 0x1000b4978 in libssh2_default_alloc session.c:67
    #2 0x1000f8aba in file_read_publickey userauth.c:597
    #3 0x1000f2dc9 in userauth_publickey_fromfile userauth.c:1513
    #4 0x1000f2948 in libssh2_userauth_publickey_fromfile_ex userauth.c:1590
    #5 0x10000e254 in test_userauth_publickey__ed25519_auth_ok publickey.c:69
    #6 0x1000090c3 in clar_run_test clar.c:260
    #7 0x1000038f3 in clar_run_suite clar.c:343
    #8 0x100003272 in clar_test_run clar.c:522
    #9 0x10000c3cc in main runner.c:60
    #10 0x7fff5b43b3d4 in start (libdyld.dylib:x86_64+0x163d4)

SUMMARY: AddressSanitizer: heap-buffer-overflow (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x1f98c) in wrap_memchr
Shadow bytes around the buggy address:
  0x1c0e00003740: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fd fd
  0x1c0e00003750: fd fd fd fd fd fd fd fa fa fa fa fa 00 00 00 00
  0x1c0e00003760: 00 00 00 00 00 00 fa fa fa fa 00 00 00 00 00 00
  0x1c0e00003770: 00 00 00 fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x1c0e00003780: fd fd fa fa fa fa fd fd fd fd fd fd fd fd fd fa
=>0x1c0e00003790: fa fa fa fa 00 00 00 00 00 00 00 00 00 00[fa]fa
  0x1c0e000037a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0e000037b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0e000037c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0e000037d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0e000037e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
@willco007 willco007 mentioned this pull request Aug 27, 2019
vszakats added a commit that referenced this pull request Apr 24, 2023
TL;DR: Sync test builds between autotools and CMake. Sync sshd
configuration between Docker and non-Docker fixtures. Bump up
sshd_config for recent OpenSSH releases.

This also opens up the path to have non-Docker tests that use a
local sshd process. Though sshd is practically unusable on Windows
CI machines out of the box, so this will need further efforts.

Details:

- cmake: run sshd fixture test just like autotool did already.

- sync tests and their order between autotools and CMake.

  It makes `test_aa_warmup` the first test with both.

- cmake: load test lists from `Makefile.am`.

  Needed to update the loader to throw away certain lines to keep the
  converted output conform CMake syntax. Using regexp might be an
  alternative way of doing this, but couldn't make it work.

- cmake: use the official way to configure test environment variables.
  Switch to syntax that's extendable.

- cmake: allow to run the same test both under Docker and sshd fixture.

  Useful for testing the sshd fixture runner, or how the same test
  behaves in each fixture.

- update test fixture to read the username from `USER` envvar instead of
  using the Dockfile-specific hardwired one, when running outside Docker.

- rework `ssh2.sh` into `sshd_fixture.sh`, to:

  - allow running any tests (not just `test_ssh2`).
  - configure Docker tests for running outside Docker.
  - fixup `SSHD` path when running on Windows (e.g. in AppVeyor CI).
    Fixes: `sshd re-exec requires execution with an absolute path`
  - allow overriding `PUBKEY` and `PRIVKEY` envvars.
  - allow overriding `ssh_config` via `SSHD_FIXTURE_CONFIG`.

- prepare support for running multiple tests via sshd_fixture.

  Add a TAP runner for autotools and extend CMake logic. The TAP runner
  loads the test list from `Makefile.am`.

  Notice however that on Windows, `sshd_fixture.sh` is very flaky with
  GitHub Actions. And consistently broken for subsequent tests in
  AppVeyor CI:
    'libssh2_session_handshake failed (-43): Failed getting banner'

  Another way to try is a single sshd instance serving all tests.
  For CMake this would probably mean using an external script.

- ed25519 test keys were identical for auth and host. Regenerate the
  auth keypair to make them distinct.

- sync the sshd environment between Docker and sshd_fixture.

  - use common via `openssh_server/sshd_config`.
  - accept same auth keys.
  - offer the same host keys.
  - sync TrustedUserCAKeys.
  - delete now unused keypairs: `etc/host*`, `etc/user*`.
  - bump up startup delay for Windows (randomly, to 5 secs, from 3).
  - delete `UsePrivilegeSeparation no` to avoid deprecation warnings.
    `command-line line 0: Deprecated option UsePrivilegeSeparation`
  - delete `Protocol 2` to avoid deprecation warnings.
    It has been the default since OpenSSH 3.0 (2001-11-06).
  - delete `StrictModes no` (CI tests work without it, Docker tests
    never used it).

- bump `Dockerfile` base image to `testing-slim` (from `bullseye-slim`).

  It needed `sshd_config` updates to keep things working with
  OpenSSH 9.2 (compared to bullseye's 8.4).

  - replace `ChallengeResponseAuthentication` alias with
    `KbdInteractiveAuthentication`.
    The former is no longer present in default `sshd_config` since
    OpenSSH 8.7 (2021-08-20). This broke the `Dockerfile` script.
    The new name is documented since OpenSSH 4.9 (2008-03-31)

  - add `PubkeyAcceptedKeyTypes +ssh-rsa,ssh-dss,[email protected]`
    and `HostKeyAlgorithms +ssh-rsa`.

    Original-patch-by: Eric van Gyzen (@vangyzen on github)
    Fixes #691

    There is a new name for `PubkeyAcceptedKeyTypes`:
       `PubkeyAcceptedAlgorithms`.
    It requires OpenSSH 8.5 (2021-03-03) and breaks some envs so we're
    not using it just yet.

- drop `[email protected]` tests and references from config.

  This is a draft alias for `aes256-cbc`. No need to test it twice.
  Also this alias is no longer recognized by OpenSSH 8.5 (2021-03-03).

- update `mansyntax.sh` and `sshd_fixture.sh` to not rely on `srcdir`.

  Hopefully this works with out-of-tree builds.

- fix `test_read_algos.test` to honor CRLF EOLs in their inputs
  (necessary when running on Windows.)

- fix `test_read_algos.test` to honor `EXEEXT`. Might be useful when
  running tests under cross-builds?

- `test_ssh2.c`:

  - use libssh2 API to set blocking mode. This makes it support all
    platforms.
  - adapt socket open timeout logic from `openssh_fixture.c`.
    Sadly this did not help fix flakiness on GHA Windows.

- tests: delete unused C headers and variable initialization.

- delete unused test files: `sshd_fixture.sh.in`, `sshdwrap`,
  `etc/sshd_config`.

  Ref: cf80f2f

- autotools: delete stray `.c` test sources from `EXTRA_DIST` in tests.

- `tests/.gitignore`: drop two stray tests.

- autotools: fix passing `SSHD` containing space (Windows needs this).

- autotools: sort `EXTRA_DIST` in tests.

- cmake: fix to add `test_ssh2` to `TEST_TARGETS`.

- fix `authorized_key` order in `tests/gen_keys.sh`.

- silence shellcheck warning in `ci/checksrc.sh`.

- set `SSHD` for autotools on GitHub Actions Windows. [skipped]

  Auto-detection doesn't work (maybe because sshd is installed via
  Git for Windows and we're using MSYS2's shell.)

  It enables running sshd fixture (non-Docker) tests in these jobs.

  I did not include this in the final patch due to flakiness:
  ```
  Connection to 127.0.0.1:4711 attempt #0 failed: retrying...
  Connection to 127.0.0.1:4711 attempt #1 failed: retrying...
  Connection to 127.0.0.1:4711 attempt #2 failed: retrying...
  Failure establishing SSH session: -43
  ```

  Can be enabled with:
  `export SSHD='C:/Program Files/Git/usr/bin/sshd.exe'`

Closes #996
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 30, 2023
Some DLL is missing, possibly CRT, but did not manage to find out what
exactly.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 1, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 1, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 1, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 1, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 1, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 1, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 2, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 2, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 3, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 3, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 3, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 3, 2023
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
vszakats added a commit that referenced this pull request May 3, 2023
Whenever possible. Due to flakiness/hangs/timeouts, keep sshd
tests disabled on Windows and macOS.

Also keep Docker tests disabled on these platforms, they do not work:

GHA Windows:
```
no matching manifest for windows/amd64 in the manifest list entries
```

GHA macOS:
```
sh: docker: command not found
```

It's not possible to run UWP and ARM64 binaries:
UWP:
```
Test #2: test_simple ......................Exit code 0xc0000135
```
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

ARM64
```
D:/a/libssh2/libssh2/bld/tests/Release/test_ssh2.exe: cannot execute binary file: Exec format error
```

Cherry-picked from #1017
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 26, 2023
Something basic seems to be broken if even the no-op warmup fails.

```
2/43 Test  libssh2#2: test_aa_warmup ............................***Failed    5.59 sec
libssh2_session_handshake failed (-44): Unable to ask for ssh-userauth service
```
Ref: https://github.com/libssh2/libssh2/actions/runs/5085586301/jobs/9139192562#step:12:225

wolfSSL package is fairly recent:
```
Get:1 http://azure.archive.ubuntu.com/ubuntu jammy/universe amd64 libwolfssl32 amd64 5.2.0-2 [818 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu jammy/universe amd64 libwolfssl-dev amd64 5.2.0-2 [1194 kB]
```
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 26, 2023
vszakats added a commit to vszakats/libssh2 that referenced this pull request May 26, 2023
vszakats added a commit that referenced this pull request May 26, 2023
lampmanyao pushed a commit to lampmanyao/libssh2 that referenced this pull request Jul 16, 2023
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
TL;DR: Sync test builds between autotools and CMake. Sync sshd
configuration between Docker and non-Docker fixtures. Bump up
sshd_config for recent OpenSSH releases.

This also opens up the path to have non-Docker tests that use a
local sshd process. Though sshd is practically unusable on Windows
CI machines out of the box, so this will need further efforts.

Details:

- cmake: run sshd fixture test just like autotool did already.

- sync tests and their order between autotools and CMake.

  It makes `test_aa_warmup` the first test with both.

- cmake: load test lists from `Makefile.am`.

  Needed to update the loader to throw away certain lines to keep the
  converted output conform CMake syntax. Using regexp might be an
  alternative way of doing this, but couldn't make it work.

- cmake: use the official way to configure test environment variables.
  Switch to syntax that's extendable.

- cmake: allow to run the same test both under Docker and sshd fixture.

  Useful for testing the sshd fixture runner, or how the same test
  behaves in each fixture.

- update test fixture to read the username from `USER` envvar instead of
  using the Dockfile-specific hardwired one, when running outside Docker.

- rework `ssh2.sh` into `sshd_fixture.sh`, to:

  - allow running any tests (not just `test_ssh2`).
  - configure Docker tests for running outside Docker.
  - fixup `SSHD` path when running on Windows (e.g. in AppVeyor CI).
    Fixes: `sshd re-exec requires execution with an absolute path`
  - allow overriding `PUBKEY` and `PRIVKEY` envvars.
  - allow overriding `ssh_config` via `SSHD_FIXTURE_CONFIG`.

- prepare support for running multiple tests via sshd_fixture.

  Add a TAP runner for autotools and extend CMake logic. The TAP runner
  loads the test list from `Makefile.am`.

  Notice however that on Windows, `sshd_fixture.sh` is very flaky with
  GitHub Actions. And consistently broken for subsequent tests in
  AppVeyor CI:
    'libssh2_session_handshake failed (-43): Failed getting banner'

  Another way to try is a single sshd instance serving all tests.
  For CMake this would probably mean using an external script.

- ed25519 test keys were identical for auth and host. Regenerate the
  auth keypair to make them distinct.

- sync the sshd environment between Docker and sshd_fixture.

  - use common via `openssh_server/sshd_config`.
  - accept same auth keys.
  - offer the same host keys.
  - sync TrustedUserCAKeys.
  - delete now unused keypairs: `etc/host*`, `etc/user*`.
  - bump up startup delay for Windows (randomly, to 5 secs, from 3).
  - delete `UsePrivilegeSeparation no` to avoid deprecation warnings.
    `command-line line 0: Deprecated option UsePrivilegeSeparation`
  - delete `Protocol 2` to avoid deprecation warnings.
    It has been the default since OpenSSH 3.0 (2001-11-06).
  - delete `StrictModes no` (CI tests work without it, Docker tests
    never used it).

- bump `Dockerfile` base image to `testing-slim` (from `bullseye-slim`).

  It needed `sshd_config` updates to keep things working with
  OpenSSH 9.2 (compared to bullseye's 8.4).

  - replace `ChallengeResponseAuthentication` alias with
    `KbdInteractiveAuthentication`.
    The former is no longer present in default `sshd_config` since
    OpenSSH 8.7 (2021-08-20). This broke the `Dockerfile` script.
    The new name is documented since OpenSSH 4.9 (2008-03-31)

  - add `PubkeyAcceptedKeyTypes +ssh-rsa,ssh-dss,[email protected]`
    and `HostKeyAlgorithms +ssh-rsa`.

    Original-patch-by: Eric van Gyzen (@vangyzen on github)
    Fixes libssh2#691

    There is a new name for `PubkeyAcceptedKeyTypes`:
       `PubkeyAcceptedAlgorithms`.
    It requires OpenSSH 8.5 (2021-03-03) and breaks some envs so we're
    not using it just yet.

- drop `[email protected]` tests and references from config.

  This is a draft alias for `aes256-cbc`. No need to test it twice.
  Also this alias is no longer recognized by OpenSSH 8.5 (2021-03-03).

- update `mansyntax.sh` and `sshd_fixture.sh` to not rely on `srcdir`.

  Hopefully this works with out-of-tree builds.

- fix `test_read_algos.test` to honor CRLF EOLs in their inputs
  (necessary when running on Windows.)

- fix `test_read_algos.test` to honor `EXEEXT`. Might be useful when
  running tests under cross-builds?

- `test_ssh2.c`:

  - use libssh2 API to set blocking mode. This makes it support all
    platforms.
  - adapt socket open timeout logic from `openssh_fixture.c`.
    Sadly this did not help fix flakiness on GHA Windows.

- tests: delete unused C headers and variable initialization.

- delete unused test files: `sshd_fixture.sh.in`, `sshdwrap`,
  `etc/sshd_config`.

  Ref: cf80f2f

- autotools: delete stray `.c` test sources from `EXTRA_DIST` in tests.

- `tests/.gitignore`: drop two stray tests.

- autotools: fix passing `SSHD` containing space (Windows needs this).

- autotools: sort `EXTRA_DIST` in tests.

- cmake: fix to add `test_ssh2` to `TEST_TARGETS`.

- fix `authorized_key` order in `tests/gen_keys.sh`.

- silence shellcheck warning in `ci/checksrc.sh`.

- set `SSHD` for autotools on GitHub Actions Windows. [skipped]

  Auto-detection doesn't work (maybe because sshd is installed via
  Git for Windows and we're using MSYS2's shell.)

  It enables running sshd fixture (non-Docker) tests in these jobs.

  I did not include this in the final patch due to flakiness:
  ```
  Connection to 127.0.0.1:4711 attempt #0 failed: retrying...
  Connection to 127.0.0.1:4711 attempt libssh2#1 failed: retrying...
  Connection to 127.0.0.1:4711 attempt libssh2#2 failed: retrying...
  Failure establishing SSH session: -43
  ```

  Can be enabled with:
  `export SSHD='C:/Program Files/Git/usr/bin/sshd.exe'`

Closes libssh2#996
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Whenever possible. Due to flakiness/hangs/timeouts, keep sshd
tests disabled on Windows and macOS.

Also keep Docker tests disabled on these platforms, they do not work:

GHA Windows:
```
no matching manifest for windows/amd64 in the manifest list entries
```

GHA macOS:
```
sh: docker: command not found
```

It's not possible to run UWP and ARM64 binaries:
UWP:
```
Test libssh2#2: test_simple ......................Exit code 0xc0000135
```
Needs but doesn't find: `VCRUNTIME140_APP.dll`.

ARM64
```
D:/a/libssh2/libssh2/bld/tests/Release/test_ssh2.exe: cannot execute binary file: Exec format error
```

Cherry-picked from libssh2#1017
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
vszakats pushed a commit that referenced this pull request Jul 20, 2026
`libssh2_knownhost_readline()` hands the parser a span that is not
NUL-terminated, but knownhost_line_hashed() looks for the salt separator
with a loop that only tests *p and never consults hostlen, and
knownhost_line() can drive keylen to zero on a line whose key field is a
single token with no space or newline, at which point knownhost_add()
falls back to strlen(key) and copies what it finds into entry->key.
Either path walks off the end of the caller buffer: with an
exact-length, unterminated buffer ASAN reports a heap-buffer-overflow
read at knownhost.c:725 for "|1|abc ssh-rsa AAAAB3NzaC1yc2E" and at
knownhost.c:143 for "h AAAAAAAAAAAAAAAAAAAAAA". Bounding the salt scan
by hostlen and rejecting an empty key in the parser keeps both reads
inside the buffer without touching the public knownhost_add() contract,
where a zero keylen legitimately means "NUL-terminated string"; valid
plain and hashed lines still parse unchanged.

Fixing:
```
==52==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7bd9a7be4047 at pc 0x55e309b9a76b bp 0x7ffec35dc810 sp 0x7ffec35dbfd8
READ of size 1 at 0x7bd9a7be4047 thread T0
SCARINESS: 12 (1-byte-read-heap-buffer-overflow)
    #0 0x55e309b9a76a in strlen /src/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:425:5
    #1 0x55e309c686ae in knownhost_add /src/libssh2/src/knownhost.c:143:18
    #2 0x55e309c705ff in knownhost_line_legacy /src/libssh2/src/knownhost.c:689:18
    #3 0x55e309c6d8b6 in knownhost_line /src/libssh2/src/knownhost.c:870:16
    #4 0x55e309c6cbf4 in libssh2_knownhost_readline /src/libssh2/src/knownhost.c:969:10
```
Ref: https://github.com/libssh2/libssh2/actions/runs/29666842385/job/88138609820?pr=2350#step:5:729

and:
```
==52==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7c55dfbe19f4 at pc 0x562f17a35b1b bp 0x7ffc3d389470 sp 0x7ffc3d389468
READ of size 1 at 0x7c55dfbe19f4 thread T0
SCARINESS: 12 (1-byte-read-heap-buffer-overflow)
    #0 0x562f17a35b1a in knownhost_line_hashed /src/libssh2/src/knownhost.c:725:19
    #1 0x562f17a3297d in knownhost_line /src/libssh2/src/knownhost.c:882:16
    #2 0x562f17a31be4 in libssh2_knownhost_readline /src/libssh2/src/knownhost.c:976:10
```
Ref: https://github.com/libssh2/libssh2/actions/runs/29745783525/job/88363260911?pr=2365#step:5:833

Closes #2363
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jul 25, 2026
```
Direct leak of 395 byte(s) in 1 object(s) allocated from:
    #0 0x56485558fe04 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:67:3
    libssh2#1 0x5648555e8fbc in ssh2_default_alloc /src/libssh2/src/session.c:67:12
    libssh2#2 0x5648555f849d in ssh2_transport_read /src/libssh2/src/transport.c:677:26
    libssh2#3 0x56485565138b in ssh2_packet_burn /src/libssh2/src/packet.c:1534:15
    libssh2#4 0x56485563802d in kex_diffie_hellman_sha /src/libssh2/src/kex.c:537:25
    libssh2#5 0x56485563b3f8 in kex_method_diffie_hellman_group14_key_exchange /src/libssh2/src/kex.c:905:11
    libssh2#6 0x56485563af24 in kex_method_diffie_hellman_group14_sha256_key_exchange /src/libssh2/src/kex.c:933:12
    libssh2#7 0x56485562458a in ssh2_kex_exchange /src/libssh2/src/kex.c:3741:23
```
Ref: https://github.com/libssh2/libssh2/actions/runs/29953989502/job/89038339664#step:5:53
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jul 26, 2026
```
Direct leak of 395 byte(s) in 1 object(s) allocated from:
    #0 0x56485558fe04 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:67:3
    libssh2#1 0x5648555e8fbc in ssh2_default_alloc /src/libssh2/src/session.c:67:12
    libssh2#2 0x5648555f849d in ssh2_transport_read /src/libssh2/src/transport.c:677:26
    libssh2#3 0x56485565138b in ssh2_packet_burn /src/libssh2/src/packet.c:1534:15
    libssh2#4 0x56485563802d in kex_diffie_hellman_sha /src/libssh2/src/kex.c:537:25
    libssh2#5 0x56485563b3f8 in kex_method_diffie_hellman_group14_key_exchange /src/libssh2/src/kex.c:905:11
    libssh2#6 0x56485563af24 in kex_method_diffie_hellman_group14_sha256_key_exchange /src/libssh2/src/kex.c:933:12
    libssh2#7 0x56485562458a in ssh2_kex_exchange /src/libssh2/src/kex.c:3741:23
```
Ref: https://github.com/libssh2/libssh2/actions/runs/29953989502/job/89038339664#step:5:53
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jul 29, 2026
```
=================================================================
==45==ERROR: AddressSanitizer: attempting double-free on 0x7d0048c16680 in thread T0:
SCARINESS: 42 (double-free)
    #0 0x564127d3eb66 in free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:51:3
    libssh2#1 0x564127d986bc in ssh2_default_free /src/libssh2/src/session.c:74:5
    libssh2#2 0x564127dd403e in ssh2_kex_exchange /src/libssh2/src/kex.c:3735:9
    libssh2#3 0x564127df99af in ssh2_packet_add /src/libssh2/src/packet.c:1362:14
    libssh2#4 0x564127dadb59 in transport_fullpacket /src/libssh2/src/transport.c:338:14
    libssh2#5 0x564127da9b5b in ssh2_transport_read /src/libssh2/src/transport.c:869:18
    libssh2#6 0x564127e0034d in ssh2_packet_require /src/libssh2/src/packet.c:1462:15
    libssh2#7 0x564127d9a927 in session_startup /src/libssh2/src/session.c:765:14
    libssh2#8 0x564127d998bf in libssh2_session_handshake /src/libssh2/src/session.c:813:5
    libssh2#9 0x564127d82cda in LLVMFuzzerTestOneInput /src/libssh2/tests/ossfuzz/ssh2_client_fuzzer.cc:64:8
    libssh2#10 0x564127c204ad in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    libssh2#11 0x564127c1fae5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
    libssh2#12 0x564127c21e22 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:834:7
    libssh2#13 0x564127c22128 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:872:3
    libssh2#14 0x564127c10fb5 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:917:6
    libssh2#15 0x564127c3cc22 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    libssh2#16 0x7fb049bbb082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 5792732f783158c66fb4f3756458ca24e46e827d)
    libssh2#17 0x564127c0430d in _start (build-out/ssh2_client_fuzzer+0x6430d)

DEDUP_TOKEN: __interceptor_free--ssh2_default_free--ssh2_kex_exchange
0x7d0048c16680 is located 0 bytes inside of 491-byte region [0x7d0048c16680,0x7d0048c1686b)
freed by thread T0 here:
    #0 0x564127d3eb66 in free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:51:3
2026-07-26 22:58:44,277 - root - INFO - Fuzzer: ssh2_client_fuzzer. Detected bug.
2026-07-26 22:58:44,277 - root - INFO - Trying to reproduce crash using: /tmp/tmptfcvdhdx/crash-1987022631d6b7820f7f2167f23beb45bca9909b.
    libssh2#1 0x564127d986bc in ssh2_default_free /src/libssh2/src/session.c:74:5
    libssh2#2 0x564127da7bbf in ssh2_transport_read /src/libssh2/src/transport.c:678:17
    libssh2#3 0x564127e0034d in ssh2_packet_require /src/libssh2/src/packet.c:1462:15
    libssh2#4 0x564127de7a62 in kex_diffie_hellman_sha /src/libssh2/src/kex.c:555:14
    libssh2#5 0x564127deab58 in kex_method_diffie_hellman_group14_key_exchange /src/libssh2/src/kex.c:899:11
    libssh2#6 0x564127dea684 in kex_method_diffie_hellman_group14_sha256_key_exchange /src/libssh2/src/kex.c:927:12
    libssh2#7 0x564127dd3d0a in ssh2_kex_exchange /src/libssh2/src/kex.c:3719:23
    libssh2#8 0x564127df99af in ssh2_packet_add /src/libssh2/src/packet.c:1362:14
    libssh2#9 0x564127dadb59 in transport_fullpacket /src/libssh2/src/transport.c:338:14
    libssh2#10 0x564127da9b5b in ssh2_transport_read /src/libssh2/src/transport.c:869:18
    libssh2#11 0x564127e0034d in ssh2_packet_require /src/libssh2/src/packet.c:1462:15
    libssh2#12 0x564127d9a927 in session_startup /src/libssh2/src/session.c:765:14
    libssh2#13 0x564127d998bf in libssh2_session_handshake /src/libssh2/src/session.c:813:5
    libssh2#14 0x564127d82cda in LLVMFuzzerTestOneInput /src/libssh2/tests/ossfuzz/ssh2_client_fuzzer.cc:64:8
    libssh2#15 0x564127c204ad in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    libssh2#16 0x564127c1fae5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
    libssh2#17 0x564127c21e22 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:834:7
    libssh2#18 0x564127c22128 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:872:3
    libssh2#19 0x564127c10fb5 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:917:6
    libssh2#20 0x564127c3cc22 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    libssh2#21 0x7fb049bbb082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 5792732f783158c66fb4f3756458ca24e46e827d)

DEDUP_TOKEN: __interceptor_free--ssh2_default_free--ssh2_transport_read
previously allocated by thread T0 here:
    #0 0x564127d3ee04 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:67:3
    libssh2#1 0x564127d9864c in ssh2_default_alloc /src/libssh2/src/session.c:67:12
    libssh2#2 0x564127da7c33 in ssh2_transport_read /src/libssh2/src/transport.c:679:26
    libssh2#3 0x564127e0034d in ssh2_packet_require /src/libssh2/src/packet.c:1462:15
    libssh2#4 0x564127d9a927 in session_startup /src/libssh2/src/session.c:765:14
    libssh2#5 0x564127d998bf in libssh2_session_handshake /src/libssh2/src/session.c:813:5
    libssh2#6 0x564127d82cda in LLVMFuzzerTestOneInput /src/libssh2/tests/ossfuzz/ssh2_client_fuzzer.cc:64:8
    libssh2#7 0x564127c204ad in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
    libssh2#8 0x564127c1fae5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
    libssh2#9 0x564127c21e22 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:834:7
    libssh2#10 0x564127c22128 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:872:3
    libssh2#11 0x564127c10fb5 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:917:6
    libssh2#12 0x564127c3cc22 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    libssh2#13 0x7fb049bbb082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 5792732f783158c66fb4f3756458ca24e46e827d)

DEDUP_TOKEN: __interceptor_malloc--ssh2_default_alloc--ssh2_transport_read
SUMMARY: AddressSanitizer: double-free /src/libssh2/src/session.c:74:5 in ssh2_default_free
==45==ABORTING
```
https://github.com/libssh2/libssh2/actions/runs/30224178881/job/89851604319?pr=2398
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