Skip to content
Crypto Disclosed report Advanced CVE-2026-87865CVE-2026-9547

CVE-2026-87865: knownhost callback mismatches key as missing

When libcurl uses libssh2 with a hashed OpenSSH known_hosts file, an unrelated first hashed entry can cause a hostile key for an already pinned SFTP/SCP host to be reported to the key callback as missing rather than mismatched. A network attacker controlling the reached SSH endpoint can then make a pinned host look new, so libcurl authenticates to the hostile endpoint and sends the configured SSH password.

1rhino2 Follow

Originally disclosed on HackerOne

  • Triaged in 11 days
  • Fixed in 47 days
  • Disclosed after 47 days

When libcurl uses libssh2 with a hashed OpenSSH known_hosts file, an unrelated first entry can make a hostile key for an already pinned SFTP/SCP host reach CURLOPT_SSH_KEYFUNCTION as CURLKHMATCH_MISSING instead of CURLKHMATCH_MISMATCH.

At https://github.com/curl/curl/blob/68720b4837284335b2d63cb358f8f6ce65f5bc55/lib/vssh/libssh2.c#L653-L687, curl treats the first hashed entry whose public name is NULL as the destination and forces that entry's key algorithm without checking its hostname hash.

With an unrelated hashed RSA entry before the target's hashed Ed25519 entry, a hostile RSA server negotiates successfully; libssh2 then filters out the Ed25519 pin and curl passes NOTFOUND to the callback as MISSING.

To reproduce on curl 8.21.0 commit 68720b4837284335b2d63cb358f8f6ce65f5bc55, build shared libcurl with cmake -S . -B build -DCURL_USE_LIBSSH2=ON -DBUILD_SHARED_LIBS=ON, extract the attachment, and run python3 poc.py --build-dir /absolute/path/to/build --output run.json.

Both exploit runs exit 0, the callback receives MISSING, the hostile server receives the password canary, and libcurl returns ATTACKER_SFTP_BODY; the target-first and same-type MISMATCH controls send no password.

This is a separate libssh2 root from CVE-2026-9547, whose advisory says libssh2 is unaffected; I used AI to assist the source audit and drafting, then personally reran the exact-release, current-master, control, and fixed-control tests.

Impact

A network attacker who controls or intercepts the reached SSH endpoint can make an already pinned host appear genuinely new to a trust-on-first-use callback. Libcurl then authenticates to the hostile endpoint; in the proof, the server receives the configured SSH password and libcurl accepts attacker-controlled SFTP data. The default callback and curl command-line tool are not claimed affected.

The original report as published on HackerOne, by 1rhino2. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely curl picks the first hashed known_hosts entry whose public name is NULL as the destination and forces that entry's key algorithm without checking its hostname hash.

Impact

A network attacker who controls or intercepts the reached SSH endpoint could make a pinned host appear new, causing libcurl to authenticate to the hostile endpoint and send the configured SSH password; the default callback and the curl command-line tool are not claimed affected.

What the attacker needed

Hashed OpenSSH known_hosts file; libcurl built with libssh2; attacker controls or intercepts SSH endpoint

How it was found

  1. Build a shared libcurl with libssh2 enabled using the given cmake command.
  2. Extract the attachment and run the proof-of-concept script against the build directory.
  3. Observe that the callback receives MISSING and the hostile server receives the password canary.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you connect to a server over SSH, your computer keeps a list of the server's known fingerprints so it can warn you if the server suddenly looks different. This report shows that with a particular kind of saved list, libcurl could be tricked into thinking a fake server was simply a new one it had never seen, rather than a changed one. That meant it would happily log in to the fake server and hand over the password.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by 1rhino2

View all

12 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.