Summary
Botan 3.11.0 contains an improper certificate validation flaw where the Certificate_Store::certificate_known function can incorrectly treat an end-entity certificate as if it were a trusted root, based solely on a matching distinguished name (DN) and optional subject key identifier.
When path validation logic relies on this behavior, an attacker who can present such a certificate may have it accepted as trusted without a proper chain of trust, undermining TLS and other PKI-based security guarantees.
Affected context
This issue affects applications that:
- Use Botan 3.11.0 as their cryptographic library
- Rely on
Certificate_Store::certificate_knownas part of certificate path validation - Treat a positive response from
certificate_knownas proof that a certificate is a specific, trusted root
The risk arises in PKI contexts such as TLS, client certificate authentication, or any protocol where Botan's certificate store is used to determine whether a peer's certificate chains to a trusted root. The vulnerability is most relevant when an attacker can supply arbitrary end-entity certificates and there exists a trusted root whose DN (and subject key identifier, if set) can be duplicated.
Exploit preconditions
- Attack surface: Any network or local protocol relying on Botan 3.11.0 certificate validation (e.g., TLS servers/clients, mutual TLS, certificate-based authentication flows).
- Required access: Ability to present or inject an X.509 certificate to a Botan-using component (e.g., acting as a connecting client, a man-in-the-middle, or a malicious peer).
- Trigger point: Invocation of certificate path validation that calls
Certificate_Store::certificate_knownand interprets a match as that specific certificate being trusted. - Why exploitation is possible:
certificate_knownonly compares distinguished name and subject key identifier, not the full certificate identity (such as serial number, public key, or signature). Path validation logic in 3.11.0 assumes that a true return value means "this exact certificate is a known/trusted root," allowing a non-root certificate that mimics the DN/SKI of a trusted root to be immediately accepted.
Why this happens
The root cause is a mismatch between the semantics implied by the API name and its actual behavior, combined with logic that over-trusts the result. The function Certificate_Store::certificate_known in Botan 3.11.0 checks whether any certificate in the store shares the same distinguished name (and subject key identifier, if present) as the candidate certificate. It does not verify that the found certificate and the candidate are byte-for-byte identical, nor does it enforce that the candidate is itself the stored, trusted root.
This behavior maps to CWE-295: Improper Certificate Validation, because the validation step relies on incomplete matching criteria (DN/SKI only) and incorrectly equates a name match with full trust equivalence. The extended path validation logic assumes certificate_known guarantees certificate identity, so an end-entity certificate crafted to share the DN/SKI of a trusted root can be misclassified as that root, bypassing the intended chain-of-trust evaluation.
Potential impact
- An attacker-controlled end-entity certificate could be accepted as if it were a trusted root certificate.
- Bypass of certificate chain validation, weakening or nullifying PKI protections.
- Potential impersonation of servers, clients, or services that rely on Botan for TLS or certificate-based authentication.
- Facilitation of man-in-the-middle attacks when combined with network positioning and crafted certificates.
- Undermining of integrity and authenticity guarantees for protocols that depend on Botan-based certificate validation.
General mitigation guidance
Mitigation should focus on tightening certificate identity checks and reducing reliance on ambiguous API semantics:
- Ensure that any function used to determine whether a certificate is trusted compares the actual certificate object (or a robust identity set like issuer, serial number, and public key) rather than just DN or subject key identifier.
- Use explicit APIs or abstractions that separate "name lookup" from "trust decision," so code cannot accidentally treat a DN match as a trust signal.
- Implement stricter certificate path validation that always verifies a complete and valid chain from the end-entity certificate to a known root, including signature checks and constraints, instead of shortcutting validation based on partial metadata.
- Design certificate stores and validation logic to be secure by default, for example by:
- Treating ambiguous matches as failures rather than successes.
- Rejecting certificates that appear both as end entities and as nominal roots without explicit policy allowing this.
- Apply least-privilege trust in application logic: minimize the number of trusted roots and constrain where and how they are accepted.
How teams detect issues like this
Detection strategies should seek out weak trust assumptions and ambiguous identity checks:
- Static analysis and code review:
- Search for uses of
Certificate_Store::certificate_knownor similarly named APIs where the return value is treated as proof of a specific certificate's identity or trust status. - Flag patterns where only DN or subject key identifier is compared to infer trust, without verifying the full certificate (including issuer, serial number, public key, and signature).
- Review certificate path validation implementations for any "early accept" logic that bypasses full chain validation when certain metadata matches.
- Policy and design review:
- Establish coding guidelines that disallow using name-based lookups as sole trust indicators.
- Require that certificate validation routines enforce full path construction and verification, supplemented by constraints (key usage, basic constraints, etc.).
- Automated tooling:
- Use security-focused linters or SAST tools configured to detect improper certificate validation patterns (e.g., simplistic DN/SKI comparisons leading to trust decisions).
- Integrate automated checks in CI to ensure that any changes to PKI or TLS handling code are manually inspected for correct trust semantics.

