Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-87865 Overview
CVE-2026-87865 affects libcurl when built against libssh2 and configured to use a hashed known_hosts file. Under specific conditions, host key validation misreports a key mismatch as a missing key to the application via the CURLOPT_SSH_KEYFUNCTION callback. The incorrect status can cause host-key-verification logic to accept a server whose key has actually changed, weakening the SSH trust model that known_hosts is designed to enforce. The flaw is tracked in the curl.se CVE-2026-87865 Documentation and the HackerOne Report #3975408.
Critical Impact
Applications relying on CURLOPT_SSH_KEYFUNCTION to distinguish a mismatched host key from a missing one may silently trust an attacker-controlled SSH server, undermining man-in-the-middle protection.
Affected Products
- libcurl when built against libssh2
- Deployments using a hashed known_hosts file
- Applications implementing the CURLOPT_SSH_KEYFUNCTION callback for host key decisions
Discovery Timeline
- 2026-10-20 - CVE-2026-87865 published to NVD
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2026-87865
Vulnerability Analysis
The defect lies in how libcurl interprets libssh2 host key verification results when the known_hosts file stores entries as salted SHA-1 hashes rather than plaintext hostnames. During lookup, libcurl iterates through entries and relies on the libssh2 response to determine whether a provided host key matches, mismatches, or is absent.
When an unrelated hashed entry appears first in the file, that entry influences the state returned to the caller. The CURLOPT_SSH_KEYFUNCTION callback then receives CURLKHMATCH_MISSING instead of CURLKHMATCH_MISMATCH. Applications typically treat a missing key as a first-contact event, often prompting a save or auto-accept, while a mismatch is treated as a potential interception event.
Root Cause
The root cause is incorrect handling of hashed known_hosts entries during iteration. libcurl does not correctly reconcile the per-entry hash comparison with the final match verdict when multiple entries exist. The classification error maps to [CWE-295] Improper Certificate Validation applied to SSH host keys, and more specifically to a logic flaw rather than a memory safety issue.
Attack Vector
An attacker who can intercept SSH traffic between a libcurl client and the intended server can present a different host key. If the targeted host already has a correct entry in a hashed known_hosts file, but an unrelated hashed entry precedes it, the callback is told the key is missing. Applications that auto-accept missing keys will trust the attacker-supplied key and establish a session that the operator believes is authenticated. Full technical narrative is published in the HackerOne Report #3975408.
No verified exploit code is published. See the curl.se CVE-2026-87865 JSON Detail for the structured advisory data.
Detection Methods for CVE-2026-87865
Indicators of Compromise
- Unexpected new entries written to hashed known_hosts files on hosts that previously had a validated key for the same server.
- SSH or SFTP sessions from libcurl-based tooling to hosts whose fingerprints no longer match historical values.
- Application logs showing CURLKHMATCH_MISSING events for destinations that were already provisioned.
Detection Strategies
- Audit application code paths that implement CURLOPT_SSH_KEYFUNCTION and compare observed callback outcomes against expected state for known destinations.
- Compare client-side known_hosts fingerprints against an authoritative inventory of server host keys to surface silent mismatches.
- Inventory libcurl builds in the environment and flag those linked against libssh2 for prioritized patching.
Monitoring Recommendations
- Centralize SSH host key fingerprint telemetry from endpoints and compare against a trusted baseline.
- Alert on first-contact SSH events to destinations previously recorded as trusted.
- Monitor outbound SSH/SFTP connections initiated by curl-based automation for anomalous destinations or routing.
How to Mitigate CVE-2026-87865
Immediate Actions Required
- Upgrade libcurl to the fixed release referenced in the curl.se CVE-2026-87865 Documentation.
- Review every application that implements CURLOPT_SSH_KEYFUNCTION and ensure a CURLKHMATCH_MISSING verdict is not auto-accepted for production destinations.
- Rebuild and redistribute any statically linked tools that embed vulnerable libcurl or libssh2 versions.
Patch Information
Refer to the vendor advisory at curl.se CVE-2026-87865 Documentation for the affected version range, fixed release, and patch commit. The structured advisory data is available in the curl.se CVE-2026-87865 JSON Detail.
Workarounds
- Switch to a plaintext (non-hashed) known_hosts file until the patched libcurl is deployed.
- Replace reliance on CURLOPT_SSH_KEYFUNCTION auto-accept logic with strict fingerprint pinning validated against an external source of truth.
- Use a different SSH backend such as libcurl built with the OpenSSH tooling chain where organizational policy allows.
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

