Skip to content
Crypto Disclosed report Advanced

29: CURLOPT_ISSUERCERT accepts a different-key certificate when issuer metadata collides

The CURLOPT_ISSUERCERT option in curl's OpenSSL and GnuTLS backends checks only certificate metadata, not the cryptographic signature, so a certificate with a matching subject and key identifier but a different key is accepted as the issuer. An attacker who already controls another trusted CA hierarchy could therefore bypass the documented branch restriction, though normal CA and hostname verification still apply.

giant_anteater Follow

Originally disclosed on HackerOne

Informational View original
  • Disclosed after 13 days

Summary

ossl_check_issuer() in lib/vtls/openssl.c uses X509_check_issued() to implement CURLOPT_ISSUERCERT. This OpenSSL function checks metadata (subject/issuer names, key identifiers, algorithm compatibility, key usage) but does not verify the certificate's cryptographic signature. A certificate with matching subject DN and Subject Key Identifier but a completely different public key passes the check.

The documentation at docs/libcurl/opts/CURLOPT_ISSUERCERT.md states the option verifies the issuer is "indeed the one associated with the certificate" and can "enforce that the peer certificate is from a specific branch of the tree." The implementation does not cryptographically enforce this.

The same pattern exists in the GnuTLS backend (gnutls_x509_crt_check_issuer() at lib/vtls/gtls.c:1815).

Root cause

C
// lib/vtls/openssl.c — ossl_check_issuer()
if(X509_check_issued(issuer, server_cert) != X509_V_OK) {

Per OpenSSL docs (X509_check_issued): this checks whether a certificate was "apparently issued" by another — it explicitly does not verify the signature. Normal chain verification runs independently beforehand (line 4828) and does not require the configured issuer to appear in the verified chain.

Reproduction

Expected vs actual output:

The PoC builds two independent CA branches. Both intermediates share the same subject (CN=Colliding Intermediate) and the same hardcoded SKID, but use different RSA keys. The leaf is signed by the real intermediate (trusted root). The decoy intermediate (untrusted root) is passed as CURLOPT_ISSUERCERT.

  • Expected: CURLE_SSL_ISSUER_ERROR (83) — the configured issuer did not sign the leaf.
  • Actual: CURLE_OK (0) — the transfer succeeds.

Controls confirm the check is active: changing the decoy's subject or SKID correctly returns error 83. Direct openssl verify of the leaf against the decoy's key fails with "certificate signature failure."

Impact

This bypasses the PKI branch restriction that CURLOPT_ISSUERCERT is documented to enforce. It does not bypass normal CA verification or hostname verification. Exploitation requires the attacker to already control another CA hierarchy trusted by the application and have authority to issue for the target hostname, which significantly limits practical impact. I believe Low severity is appropriate.

The original report as published on HackerOne, by giant_anteater. 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 code relies on X509_check_issued(), which only checks whether one certificate appears to have issued another based on metadata, and does not verify the cryptographic signature.

Impact

The documented PKI branch restriction is bypassed, but normal CA verification and hostname verification still apply, and exploitation requires the attacker to already control another trusted CA hierarchy with authority to issue for the target hostname, so practical impact is limited.

What the attacker needed

Attacker controls another trusted CA hierarchy; attacker can issue for the target hostname; application uses CURLOPT_ISSUERCERT

How it was found

  1. Build two independent CA branches whose intermediates share the same subject name and key identifier but use different keys.
  2. Sign the leaf certificate with the real intermediate under the trusted root.
  3. Pass the decoy intermediate from the untrusted root as CURLOPT_ISSUERCERT.
  4. Observe that the transfer succeeds instead of returning an issuer error.

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 a program connects to a server, it can be told to accept only certificates issued by one specific authority. This report shows that curl checked only the name and label on that authority's certificate, not the secret signature that proves it really signed the server's certificate. So a different authority with the same name and label could slip through, but only if the attacker already controls another authority the program trusts.

What is Crypto?

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

More by giant_anteater

View all

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