10000 Access Token IDs have less than 128 bits of entropy · Issue #38663 · keycloak/keycloak · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Access Token IDs have less than 128 bits of entropy #38663
Closed
@abstractj

Description

@abstractj

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

core

Describe the bug

In several parts of the codebase, UUID.randomUUID() is used to generate values like authorization codes and token identifiers. While this produces 128-bit UUIDs, only ~122 bits are truly random, as 6 bits are fixed by the UUID specification (version and variant fields).

Security standards such as ANSSI R18 and NIST SP 800-90A/57 require at least 128 bits of entropy for secrets, tokens, and other security-sensitive identifiers. This means the current use of UUID.randomUUID() falls short of compliance and introduces a theoretical reduction in security strength.

Version

26.1.4

Regression

  • The issue is a regression

Expected behavior

Access token identifiers should be generated with at least 128 bits of entropy, aligning with general cryptographic best practices and recommendations.

Actual behavior

Access token IDs are generated using java.util.UUID.randomUUID(), resulting in Type 4 UUIDs. These UUIDs have constraints that limit their maximum entropy to 122 bits.

How to Reproduce?

  1. Generate an access token within Keycloak.
  2. Inspect the generation logic, specifically the KeycloakModelUtils.generateId() method, confirming its reliance on UUID.randomUUID().  
  3. Analyze the properties of the generated token ID (e.g., the jti claim if it's a JWT).
  4. Confirm the ID is a Type 4 UUID and thus limited to a theoretical maximum of 122 bits of entropy due to the fixed bits in its format.  

Anything else?

Entropy Requirements Comparison – NIST vs ANSSI

Use Case Recommended Entropy NIST Guidance ANSSI Guidance (R18, R24, etc.) UUID.randomUUID() Status
Authorization Codes ≥ 128 bits SP 800-63B §5.1.4.2: At least 128 bits for high assurance [R18] Requires random generation with ≥ 128 bits of entropy Only ~122 bits
Access Tokens / Bearer Tokens ≥ 128 bits SP 800-133 Rev. 2: Secure key generation requires full entropy [R24] Requires access tokens to be randomly generated with ≥ 128 bits of entropy Only ~122 bits
Client Secrets / Shared Keys ≥ 128 bits SP 800-57 Part 1 Rev. 5: Symmetric keys must have at least 128-bit strength [R35] Must be generated by CSPRNG with ≥ 128-bit entropy Often falls short
Nonce / Anti-Replay Values ≥ 128 bits SP 800-90A Rev.1: Nonces should be random or unique enough to avoid reuse [R14, R15] Requires CSPRNG and ≥ 128-bit entropy ~122 bits
Session Identifiers / Correlation IDs ≥ 112 bits [SP 800-63B]: At least 112 bits of entropy for session IDs Not explicitly covered, but same 128-bit rule often applies Borderline
Random Identifiers (non-security sensitive) ≥ 64–80 bits (low risk) Acceptable for non-sensitive use cases Acceptable if not used for authentication/authorization Acceptable

Proposal

Based on the assessment from the team on the findings below, to evaluate the impact, I’d like us to replace UUID.randomUUID() by SecureRandom to produce full 128-bit entropy values. Please review the findings and comment on whether or not the idea makes sense.

Findings

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0