CVE-2023-33201: Medium severity bouncycastle bc-java vulnerability
Bouncy Castle For Java before 1.74 is affected by an LDAP injection vulnerability. The vulnerability only affects applications that use an LDAP CertStore from Bouncy Castle to validate X.509 certificates. During the certificate validation process, Bouncy Castle inserts the certificate's Subject Name into an LDAP search filter without any escaping, which leads to an LDAP injection vulnerability.
Other sources
Bouncy Castle provides the X509LDAPCertStoreSpi.java class which can be used in conjunction with the CertPath API for validating certificate paths. Pre-1.73 the implementation did not check the X.500 name of any certificate, subject, or issuer being passed in for LDAP wild cards, meaning the presence of a wild car may lead to Information Disclosure.
A potential attack would be to generate a self-signed certificate with a subject name that contains special characters, e.g: CN=Subject)(objectclass=. This will be included into the filter and provides the attacker ability to specify additional attributes in the search query. This can be exploited as a blind LDAP injection: an attacker can enumerate valid attribute values using the boolean blind injection technique. The exploitation depends on the structure of the target LDAP directory, as well as what kind of errors are exposed to the user.
Changes to the X509LDAPCertStoreSpi.java class add the additional checking of any X.500 name used to correctly escape wild card characters.
Issue affecting: BC 1.73 and earlier.
Fixed versions: BC 1.74
Platform affected: Java 4 and later.
Bouncy Castle provides the X509LDAPCertStoreSpi.java class which can be used in conjunction with the CertPath API for validating certificate paths. Pre-1.73 the implementation did not check the X.500 name of any certificate, subject, or issuer being passed in for LDAP wild cards, meaning the presence of a wild car may lead to Information Disclosure.
A potential attack would be to generate a self-signed certificate with a subject name that contains special characters, e.g: CN=Subject)(objectclass=. This will be included into the filter and provides the attacker ability to specify additional attributes in the search query. This can be exploited as a blind LDAP injection: an attacker can enumerate valid attribute values using the boolean blind injection technique. The exploitation depends on the structure of the target LDAP directory, as well as what kind of errors are exposed to the user.
Changes to the X509LDAPCertStoreSpi.java class add the additional checking of any X.500 name used to correctly escape wild card characters.
https://github.com/bcgit/bc-java/wiki/CVE-2023-33201
— Red Hat
The Bouncy Castle Crypto Package For Java (bc-java) could allow a remote attacker to obtain sensitive information, caused by not validating the X.500 name of any certificate in the implementation of the X509LDAPCertStoreSpi.java class. By using blind LDAP injection attack techniques, an attacker could exploit this vulnerability to obtain sensitive information, and use this information to launch further attacks against the affected system.
— IBM
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
maven/org.bouncycastle:bcprov-debug-jdk14to a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
maven/org.bouncycastle:bcprov-ext-jdk14to a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
maven/org.bouncycastle:bcprov-jdk14to a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
maven/org.bouncycastle:bcprov-debug-jdk18onto a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
maven/org.bouncycastle:bcprov-debug-jdk15to18to a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
maven/org.bouncycastle:bcprov-ext-jdk18onto a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
maven/org.bouncycastle:bcprov-ext-jdk15to18to a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
maven/org.bouncycastle:bcprov-jdk15to18to a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
maven/org.bouncycastle:bcprov-jdk18onto a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
redhat/BouncyCastleto a version that resolves this vulnerability.Fixed in 1.74 - Upgrade
Upgrade
bc-javato a version that resolves this vulnerability.Fixed in 1.74 - Configuration
Ensure the fix that adds additional checking/escaping of any X.500 name used by X509LDAPCertStoreSpi.java is present so that certificate Subject/Issuer X.500 names inserted into LDAP search filters are properly escaped (pre-1.74 they were inserted without escaping).
Bouncy Castle X509LDAPCertStoreSpi.java (CertPath/LDAP CertStore usage) X.500 name escaping in LDAP search filter = escape X.500 wild card characters
Event History
Frequently Asked Questions
What is CVE-2023-33201?
CVE-2023-33201 is an LDAP injection vulnerability in Bouncy Castle for Java before version 1.74.
How does the LDAP injection vulnerability in Bouncy Castle affect me?
The LDAP injection vulnerability in Bouncy Castle allows an attacker to inject malicious LDAP statements, potentially leading to unauthorized access or data leakage.
What is the severity of CVE-2023-33201?
CVE-2023-33201 has a severity rating of 7.1 (high).
How do I fix the LDAP injection vulnerability in Bouncy Castle?
To fix the LDAP injection vulnerability, update Bouncy Castle for Java to version 1.74 or later.
Where can I find more information about CVE-2023-33201?
You can find more information about CVE-2023-33201 on the Bouncy Castle website and the official GitHub page for BC-Java.