GHSL-2023-045: LDAP injection in Bounty Castle For Java - CVE-2023-33201
Bouncy Castle For Java inserts the certificate's Subject Name into an LDAP search filter without escaping, allowing an attacker to inject special characters and alter the query. This can lead to information disclosure through blind LDAP injection, enabling enumeration of valid attribute values.
Originally disclosed on GitHub Security Lab
Bouncy Castle For Java is affected by an LDAP injection vulnerability. The vulnerability only affects applications that use an LDAP CertStore from Bouncy Castle to validate X509 certificates.
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
The LDAP search filter is constructed by concatenating the certificate's subject name without escaping special characters.
Impact
This issue may lead to information disclosure, as an attacker could perform blind LDAP injection to enumerate valid attribute values, depending on the LDAP directory structure and error exposure.
What the attacker needed
Application uses Bouncy Castle LDAP CertStore; attacker can supply a certificate
The fix
The vulnerability was fixed in version 1.74 by properly escaping the subject name before including it in the LDAP filter.
How it was found
- Set up an LDAP server to act as the certificate store.
- Configure Bouncy Castle to use that LDAP server for certificate validation.
- Generate a self-signed certificate with a subject name containing special characters.
- Trigger certificate validation, causing Bouncy Castle to send an LDAP query with the injected filter.
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 Bouncy Castle checks a certificate, it looks up trusted certificates in an LDAP directory. It builds a search query by pasting the certificate's subject name directly into the query without cleaning it. An attacker can craft a certificate with a subject name containing special characters that change the query, potentially revealing extra information from the directory.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.