CVE-2025-15079: libssh global knownhost override
libcurl does not disable libssh's global known_hosts file when a user supplies their own known hosts file, so host key checks fall back to the system-wide file. An attacker whose key is trusted in that global file could pass host identity validation even when the user intended to trust only their own list.
- Triaged in 12 hours
- Fixed in 14 days
- Disclosed after 14 days
Summary:
libssh has SSH_OPTIONS_GLOBAL_KNOWNHOSTS that specifies a global known_hosts file that will be used if the host is not found from the file specified in SSH_OPTIONS_KNOWNHOSTS file. libcurl CURLOPT_SSH_KNOWNHOSTS doesn't specify an invalid (or /dev/null) path to SSH_OPTIONS_GLOBAL_KNOWNHOSTS resulting in libcurl accepting any host identities that might be specified in the default file. This is significant when user tries to limit the known hosts to ones specified in their own file, as the global file will be checked if no match is found from the user specified file.
By default this file is /etc/ssh/ssh_known_hosts, and thus not modifiable by non-privileged user (at least on major platforms). Thus in most situations this issue cannot be exploited by actively modifying the file. This limits the impact of this flaw.
Affected version
8.17.0
Steps To Reproduce:
- Configure and compile curl with
--with-libssh - Add valid host entry for
host.exampleto/etc/ssh/ssh_known_hosts echo "" > knownhostscurl --knownhosts knownhosts [email protected]
The host identity validation succeeds even though it should not.
Remediation
- Make
CURLOPT_SSH_KNOWNHOSTSsetSSH_OPTIONS_GLOBAL_KNOWNHOSTSto/dev/null(or some non-existing path?).
Supporting Material/References:
- https://github.com/libssh/libssh-mirror/blob/ac6d2fad4a8bf07277127736367e90387646363f/src/options.c#L304
- https://github.com/libssh/libssh-mirror/blob/ac6d2fad4a8bf07277127736367e90387646363f/src/knownhosts.c#L1176
Impact
Summary:
Host validation unexpectedly succeeding.
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 libcurl sets the user's known hosts file but never overrides libssh's global known hosts option, so libssh falls back to the system-wide file when no match is found.
Impact
Host identity validation could succeed when the user expected it to fail, but only if the attacker's key is already present in the system-wide file, which a non-privileged user cannot modify, so the impact is limited.
What the attacker needed
Attacker key in system-wide known_hosts; administrator-level write access needed
The fix
libcurl should set the global known hosts option to a non-existent path such as /dev/null whenever the user supplies their own known hosts file.
How it was found
- Build curl against libssh.
- Put a valid host entry for the target host into the system-wide known hosts file.
- Create an empty known hosts file for the user.
- Run curl against the host using that empty file as the known hosts file and observe that validation still succeeds.
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 checks the server's identity against a list of known servers, kept in a file called known_hosts. libcurl lets you point it at your own list, but it forgot to switch off the system-wide list, so a server listed there is still accepted. In practice the system-wide list can only be edited by an administrator, which makes this hard to abuse.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.