CVE-2022-2232: Keycloak ldap federation Keycloak Vulnerable To LDAP Injection Vulnerability

LOW
Advisory Identifier: GHSA-8hc5-rmgf-qx6p
CWE-90
Published
Advisory Summary

CVE-2022-2232 is a LOW keycloak vulnerable to ldap injection vulnerability (CWE-90: Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection')) affecting Keycloak ldap federation libraries in the Maven ecosystem. The issue involves keycloak vulnerable to ldap injection on usernameform login. Remediation is available by upgrading affected packages to version 23.0.1.

CVE-2022-2232 at a Glance

CVE Identifier CVE-2022-2232
GHSA Identifier GHSA-8hc5-rmgf-qx6p
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-90: Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection')
Affected Product Keycloak ldap federation
Package Ecosystem Maven
Published Date
Last Updated

How to Fix CVE-2022-2232

To remediate this vulnerability, upgrade all affected Keycloak ldap federation dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.keycloak:keycloak-ldap-federation fixed: 23.0.1
<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-ldap-federation</artifactId>
    <version>23.0.1</version>
</dependency>
org.keycloak:keycloak-services fixed: 23.0.1
<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-services</artifactId>
    <version>23.0.1</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.keycloak

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2022-2232, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.keycloak

Analyze the terminal output to locate any version of Keycloak ldap federation in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 23.0.1), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.keycloak command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-90: Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection'), where the product constructs all or part of an ldap query using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended ldap query when it is sent to a downstream component. In Keycloak ldap federation, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

A flaw was found in the Keycloak package. This flaw allows an attacker to benefit from an LDAP query and access existing usernames in the server.

CVE-2022-2232 Affected Keycloak ldap federation Versions

2 component(s)
Fixed Versions:
23.0.1
Product / Package Ecosystem Affected Versions Fixed Version
org.keycloak:keycloak-ldap-federation
Maven
< 23.0.1
23.0.1
org.keycloak:keycloak-services
Maven
< 23.0.1
23.0.1

References

Frequently Asked Questions

What is CVE-2022-2232?
CVE-2022-2232 is a security vulnerability in Keycloak ldap federation involving Keycloak vulnerable to LDAP Injection on UsernameForm Login under CWE-90: Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection').
Which Keycloak ldap federation versions are affected?
Affected versions include releases prior to 23.0.1 across affected packages: org.keycloak:keycloak-ldap-federation, org.keycloak:keycloak-services.
What version fixes CVE-2022-2232?
Upgrading to 23.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is keycloak-ldap-federation affected?
Yes, org.keycloak:keycloak-ldap-federation is affected in releases prior to 23.0.1. Upgrade your dependency to 23.0.1 or later.
Is keycloak-services affected?
Yes, org.keycloak:keycloak-services is affected in releases prior to 23.0.1. Upgrade your dependency to 23.0.1 or later.
What CWE is associated with CVE-2022-2232?
CVE-2022-2232 is classified under CWE-90: Improper Neutralization of Special Elements used in an LDAP Query ('LDAP Injection') (The product constructs all or part of an LDAP query using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended LDAP query when it is sent to a downstream component.).
How can I check Maven dependencies for CVE-2022-2232?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.keycloak'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8hc5-rmgf-qx6p",
  "modified" : "2023-11-29T21:33:07Z",
  "published" : "2023-11-29T21:33:07Z",
  "aliases" : [ "CVE-2022-2232" ],
  "summary" : "Keycloak vulnerable to LDAP Injection on UsernameForm Login",
  "details" : "A flaw was found in the Keycloak package. This flaw allows an attacker to benefit from an LDAP query and access existing usernames in the server.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.keycloak:keycloak-ldap-federation"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "23.0.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.keycloak:keycloak-services"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "23.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/keycloak/keycloak/security/advisories/GHSA-8hc5-rmgf-qx6p"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/keycloak/keycloak/commit/4252e394cf725b16f7e4e19aa32b03fd3fe13fde"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/keycloak/keycloak"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-90" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-11-29T21:33:07Z",
    "nvd_published_at" : null
  }
}