Skip to content
Business logic Disclosed report Intermediate

CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 bypass if string not 32 chars

The library's handling of the SSH host public key MD5 option only performed the fingerprint check when the supplied string was exactly 32 characters long. If a caller passed a shorter or longer string, the host key verification was skipped and the connection succeeded, allowing an SSH host identity bypass.

nyymi Follow

Originally disclosed on HackerOne

  • Disclosed after 16 hours

Summary:

Due to logic flaw in CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 handling, the host fingerprint validation will be bypassed if the passed a string that is not exactly 32 characters long.

Steps To Reproduce:

  1. curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, "afe17cd62a0f3b61f1ab9cb22ba269a"); // 31 chars
  2. perform sftp:// or scp:// actions

Note: curl command is not affected since it explicitly checks that the --hostpubmd5 string is 32 characters long, and if it is not PARAM_BAD_USE is returned.

The bug is at https://github.com/curl/curl/blob/f7f26077bc563375becdb2adbcd49eb9f28590f9/lib/vssh/libssh2.c#L733

If the string length is other than 32 it should result in signature check failure instead of success. Obvious fix would be to remove the if(pubkey_md5 && strlen(pubkey_md5) == 32)test completely.

Impact

SSH host identify bypass.

For this issue to be realised, a wrong size fingerprint needs to be passed (either by accident or by malice). It is likely that this is far more likely to happen by accident, since if some actor can tamper with the fingerprints they can bypass the validation anyway. Note that curl_easy_setopt CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 does not return an error indicating that something is wrong, hence this is breaking the principle of least surprise.

The original report as published on HackerOne, by nyymi. 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

The fingerprint comparison was wrapped in a length check, so a value of the wrong length skipped verification entirely instead of failing it.

Impact

An SSH host identity check could be bypassed, though the text notes this is most likely to happen by accident and the command-line tool is not affected because it validates the length itself.

What the attacker needed

Application passes a wrong-length fingerprint; uses the library API, not the CLI

The fix

The length test should be removed so that a fingerprint of any wrong length causes the signature check to fail.

How it was found

  1. Set the SSH host public key MD5 option to a string that is not 32 characters long.
  2. Perform an SFTP or SCP transfer using that handle.

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 client can check a fingerprint to make sure it is talking to the right machine. This library option was meant to do that check, but the code only ran the check when the fingerprint text was exactly the expected length. Any other length made the check silently disappear, so a wrong server could be accepted.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by nyymi

View all

51 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.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.