Package org.keycloak.protocol.oidc.utils
Class ClientHostUtils
java.lang.Object
org.keycloak.protocol.oidc.utils.ClientHostUtils
Utility class for validating client host values against a client's registered URLs.
Used to prevent SSRF attacks by ensuring that dynamic host values (like client_session_host)
only reference hosts that are already configured and trusted for the client.
Resolves [CVE-2026-4874] Server-Side Request Forgery via OIDC token endpoint
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisHostAllowedForClient(String hostname, ClientModel client, KeycloakSession session) Validates that a hostname matches one of the client's registered nodes or the management URL/Admin URL.
-
Constructor Details
-
ClientHostUtils
public ClientHostUtils()
-
-
Method Details
-
isHostAllowedForClient
public static boolean isHostAllowedForClient(String hostname, ClientModel client, KeycloakSession session) Validates that a hostname matches one of the client's registered nodes or the management URL/Admin URL. This validation prevents SSRF attacks by ensuring that [1] only hostnames within the Management/Admin URL can be used. [2] hostnames matching registered clustered nodes can be used.- Parameters:
hostname- the hostname to validateclient- the client model containing registered URLssession- the Keycloak session for URL resolution- Returns:
- true if the hostname matches a registered client URL, false otherwise
-