Skip to content
Crypto Disclosed report Advanced

CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 comparison disaster

The SSH host public key SHA256 fingerprint comparison in curl was accidentally case-insensitive, so a forged SSH host key could match the expected fingerprint. An attacker could spoof the host identity.

nyymi Follow

Originally disclosed on HackerOne

  • Disclosed after 19 hours

Summary:

CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 base64 encoded host fingerprint is compared case-insensitive by accident. This means that it is technically possible (however still difficult) to create forged ssh host key that matches in this comparison.

The bug appears to have been introduced when adding CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 support, and then copying the case insensitive comparison of the string for CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (where it is appropriate since the MD5 fingerprint is a hex string).

This bug as added by commit https://github.com/curl/curl/commit/d1e7d9197b7fe417fb4d62aad5ea8f15a06d906c

Impact

Host identify spoofing

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

Likely the code reused a case-insensitive string comparison from the MD5 fingerprint check, which is appropriate for hex but not for base64-encoded SHA256 fingerprints.

Impact

An attacker could spoof the SSH host identity, though creating a matching forged key is still difficult.

What the attacker needed

Curl using SSH host key SHA256 check; attacker can present a forged host key

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 curl connects to an SSH server, it can check the server's fingerprint to make sure it is talking to the right machine. The check compared the fingerprint without caring about upper or lower case letters, which is wrong for base64 text. This made it easier for an attacker to present a fake server key that still passed the check.

What is Crypto?

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

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.

Cryptographic weaknesses

The lesson behind this report.

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