Skip to content
Memory corruption Advisory Advanced CVE-2017-2801

Randombit Botan Library X509 Certificate Validation Bypass Vulnerability

A whitespace-skipping comparison function for X.509 distinguished names in the Botan library could read past the end of a string when one name contains a null byte after a space and the other has trailing spaces. A crafted certificate could make equality checks pass or fail unexpectedly, leak memory or crash the application.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

Medium 6.5 View original

A programming error exists in a way Randombit Botan cryptographic library version 2.0.1 implements x500 string comparisons which could lead to certificate verification issues and abuse. A specially crafted X509 certificate would need to be delivered to the client or server application in order to trigger this…

Aleksandar Nikolic, on Cisco Talos

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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 whitespace-skipping loop advances both pointers after a space without first checking that one string has ended while the other has not, so a null byte in one name lets a pointer move past its buffer.

Impact

Depending on memory layout, a crafted certificate could make equality checks pass or fail, disclose information or cause a denial of service; the text notes the CVSS score is 6.5 with high attack complexity.

What the attacker needed

Crafted X.509 certificate; target uses Botan 2.0.1 for DN comparison

The fix

The vendor's patch adds a check that returns false when one string has reached its end and the other has not.

How it was found

  1. Craft an X.509 certificate whose subject and issuer distinguished names contain the malformed space and null byte pattern.
  2. Deliver the certificate to a client or server application that uses Botan to parse and compare it.
  3. Observe the out-of-bounds read during the distinguished name comparison, as shown by the address sanitiser report.

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.

Certificates carry names (like the issuer and subject) that software compares to decide whether two certificates are the same. Botan's comparison code skipped spaces in a way that could step past the end of a name, so a deliberately malformed certificate could confuse that check or crash the program. The result is that a certificate might be treated as matching when it should not.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Aleksandar Nikolic

View all

147 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.