CVE-2025-15224: libssh key passphrase bypass without agent set
The libcurl libssh backend treated the public-key authentication option as if agent authentication were also enabled, so it would consult a running ssh-agent even when the application had not asked for that. An attacker with access to a machine where an agent holds the user's key could authenticate to a remote host without knowing the key passphrase.
- Triaged in 1 hour
- Fixed in 9 days
- Disclosed after 9 days
Summary:
libcurl libssh backend CURLOPT_SSH_AUTH_TYPES doesn't implement CURLSSH_AUTH_AGENT flag correctly. Rather if CURLSSH_AUTH_PUBLICKEY is set, the implementation acts as if CURLSSH_AUTH_AGENT is always implicitly defined, and thus no key passphrase is required for authentication.
As a result if the user has ssh-agent /pageant running, libcurl using application that specifically does not set CURLSSH_AUTH_AGENT will still use the ssh-agent / pageant for authentication bypassing the requirement for knowing the key passphrase.
Affected version
8.17.0
Steps To Reproduce:
- Configure and build libcurl with
--with-libssh - Compile the following proof-of-concept app:
#include <curl/curl.h>
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, "sftp://host.example/");
curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PUBLICKEY);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}
- Have the current user have account on
host.example. Have a passphrase set for the user's ssh key. Have the ssh key pubkey added to thehost.exampleusers~/.ssh/authorized_keys. Have ssh-agent running with the user's key added. - Execute the proof of concept application.
As a result the application authenticates to the host.example without needing the ssh key passphrase.
Supporting Material/References:
- libcurl code calling libssh
ssh_userauth_publickey_auto: https://github.com/curl/curl/blob/5c0cdd26d66342efaaf2685f2a539be5db21cacd/lib/vssh/libssh.c#L980 - libssh
ssh_userauth_publickey_autocode talking to ssh-agent: https://github.com/libssh/libssh-mirror/blob/ac6d2fad4a8bf07277127736367e90387646363f/src/auth.c#L1120
Impact
Summary:
Bypassing the SSH key passphrase requirement.
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 the libssh backend maps the public-key auth flag onto libssh's automatic public-key call, which itself falls back to the agent, so the agent flag is effectively always on.
Impact
An application that deliberately excluded agent authentication could still authenticate through a running agent, bypassing the key passphrase requirement.
What the attacker needed
Libcurl built with libssh; passphrase-protected SSH key; ssh-agent running with the key loaded; account on the target host
How it was found
- Build libcurl with the libssh backend enabled.
- Compile a small program that sets the SSH auth types option to public key only and connects to an SFTP URL.
- Ensure the user has an account on the host, a passphrase-protected key whose public part is authorised there, and an agent holding that key.
- Run the program and observe it authenticates without the passphrase.
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.
SSH keys can be protected by a passphrase, a password that unlocks the key. Many people load their key into a helper program called an agent so they do not retype the passphrase. Here a library asked to use only the key file still quietly asked the agent, so the passphrase check was skipped.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.