Summary
LiteLLM's JWT/OIDC authentication layer previously used only the first 20 characters of a token as the cache key for OIDC userinfo responses.
An unauthenticated attacker who can send crafted JWT-like tokens to an instance with JWT authentication enabled can deliberately collide with a victim's cached entry and inherit that user's identity and permissions.
Affected context
This vulnerability affects LiteLLM deployments that:
- Enable JWT/OIDC authentication (
enable_jwt_auth: true) - Use OIDC
userinforesponses that are cached per token - Accept tokens over a network-accessible LiteLLM endpoint
The weakness appears when different tokens can share the same cache key because only a prefix of the token string (the first 20 characters) is used to index cached userinfo data.
Exploit preconditions
- Attack surface: Public or internal LiteLLM HTTP endpoints that accept JWT/OIDC tokens.
- Required access: Ability to submit arbitrary tokens to the LiteLLM instance (no prior authentication required).
- Trigger point: Sending a crafted token whose first 20 characters match those of a legitimate user's token, causing a cache hit in the userinfo cache.
- Why exploitation is possible: The cache key is derived from a truncated token prefix (
token[:20]), so different tokens produced with the same header structure and algorithm can share identical leading characters, allowing deliberate cache collisions.
Why this happens
The core issue is an improper authentication mechanism where the identity cache is keyed by an insufficiently unique token prefix instead of a full, unambiguous identifier.
By using token[:20] for the OIDC userinfo cache key, LiteLLM conflates multiple possible tokens into the same logical identity, violating the expectation that each token maps to exactly one authenticated principal.
This maps to CWE-287: Improper Authentication, as the system relies on a weak token-derived signal for identity binding and authorization decisions, allowing attackers to masquerade as other users without possessing their actual credentials.
Potential impact
- An attacker may impersonate another authenticated user whose token is cached.
- The attacker could gain access to that user's API keys, model access, or LLM routing permissions exposed through LiteLLM.
- The attacker may escalate privileges if the victim account has elevated roles or administrative capabilities.
- Unauthorized requests could be made on behalf of the victim, including data exfiltration or model misuse.
- Audit trails and logs can be polluted with actions falsely attributed to the legitimate user.
General mitigation guidance
Effective mitigation aims to ensure that cached identity data cannot be shared between distinct tokens and that identity is bound to strong, unambiguous keys.
General defensive patterns include:
- Deriving cache keys from the entire token or from stable, unique identifiers such as the token's signature,
jticlaim, or a combination of issuer (iss) and subject (sub). - Avoiding use of short prefixes, truncated values, or non-unique portions of tokens for any security decision or cache indexing.
- Applying a strict separation between authentication artifacts (tokens) and caching identifiers, ensuring caches do not weaken the underlying authentication guarantees.
- Enforcing conservative cache TTLs for userinfo and revocation-aware designs so that stale or hijacked cache entries have limited impact.
- Designing the gateway to treat failed userinfo lookups or ambiguous cache states as authentication failures rather than best-effort fallbacks.
How teams detect issues like this
Detection focuses on surfacing unsafe identity caching patterns and anomalous authentication behavior:
- Code-level review: Look for uses of token substrings (e.g.,
token[:N]) as cache keys, map keys, or identifiers in authentication and authorization flows. - Static analysis rules: Configure linters or custom static checks to flag truncated tokens, non-unique identifiers, and token-based caching in auth code paths.
- Logging and monitoring: Instrument authentication middleware to log token identifiers (safely hashed, not raw tokens) and associated principals, then detect cases where different client IPs, user agents, or sessions are mapped to the same cached identity in suspicious patterns.
- Policy enforcement: Introduce CI/CD checks that prevent changes which derive authentication decisions from partial tokens, predictable IDs, or non-cryptographic identifiers.
- Runtime anomaly detection: Use behavioral analytics to flag accounts that appear to authenticate from multiple unrelated contexts in a pattern consistent with cache impersonation.

