1.7 KiB
1.7 KiB
Keycloak — CWE-407 Scan Result: CLEAN
Target: Keycloak (Java identity/access management) Source: https://github.com/keycloak/keycloak (depth=1) Date: 2026-03-30 Scanner: manual CWE-407 pattern scan
Scan Scope
services/src/main/java/— core services, client registration, OIDC protocol, authorizationserver-spi/src/main/java/— SPI interfaces and utilities (RoleUtils, etc.)server-spi-private/src/main/java/— authorization policy evaluation, permission resolutionmodel/— JPA, Infinispan cache adapters, storage layercommon/— utility classes
Keywords Searched
.contains( on List/ArrayList, .indexOf(, nested loops, dedup patterns via
List membership, visited/seen patterns using ArrayList/LinkedList.
Findings
Keycloak consistently uses HashSet for membership testing throughout:
RoleUtils.expandCompositeRoles()— usesSet<RoleModel> visited- Infinispan cached entities (
CachedUser,CachedClient,CachedClientScope) — all useSet<String>for role mappings, scopes, groups DefaultClientSessionContext— usesSet<ClientScopeModel>,Set<RoleModel>,Set<String>DefaultCors— usesSet<String>for allowed originsWebOriginsUtils— usesHashSet<String>- Authorization policy evaluation (
DecisionPermissionCollector) — usesHashSet/LinkedHashSet
Minor List.contains usage found in ProtocolMappersClientRegistrationPolicy and
ClientScopesClientRegistrationPolicy (admin client registration path), but these
operate on small config lists (<20 items) and are not hot-path. Not reportable.
Verdict
CLEAN — no CWE-407 defects found. Keycloak's codebase is well-disciplined about using Set data structures for membership testing.