Fedora Account System
Red Hat Associate
Red Hat Customer
A flaw was found in Keycloaks token sanitization mechanism, which was originally implemented to prevent role forgery. The sanitizer responsible for removing unauthorized resource access claims from tokens only performs a type check for java.util.Map. When a protocol mapper is configured with jsonType=JSON, the resulting value is a Jackson ObjectNode, which bypasses this specific type check. An attacker with client registration privileges or a valid Initial Access Token can exploit this by registering a client with a protocol mapper targeting the resource access claim. By setting the mapper to use the JSON type, the attacker can inject arbitrary client roles into the issued tokens. Successful exploitation allows an attacker to forge administrative roles, which are then accepted by resource servers or relying parties that perform authorization based on the resource access claim.