BerriAI/litellm · error · HTTPException

You are not allowed to access this key's info. Your role={us

Error message

You are not allowed to access this key's info. Your role={user_api_key_dict.user_role}

What it means

After finding the key row, GET /key/info runs _can_user_query_key_info: access is granted to proxy admins (and view-only admins), the caller whose own api_key equals the queried key, users matching the key's user_id, or members of the key's team. Everyone else gets this 403 naming their role. It prevents users from enumerating other users' key details (spend, limits, metadata).

Source

Thrown at litellm/proxy/management_endpoints/key_management_endpoints.py:3690

            include={"litellm_budget_table": True},
        )
        if key_info is None:
            raise ProxyException(
                message="Key not found in database",
                type=ProxyErrorTypes.not_found_error,
                param="key",
                code=status.HTTP_404_NOT_FOUND,
            )

        if (
            await _can_user_query_key_info(
                user_api_key_dict=user_api_key_dict,
                key=key,
                key_info=key_info,
            )
            is not True
        ):
            raise HTTPException(
                status_code=status.HTTP_403_FORBIDDEN,
                detail=f"You are not allowed to access this key's info. Your role={user_api_key_dict.user_role}",
            )
        ## REMOVE HASHED TOKEN INFO BEFORE RETURNING ##
        try:
            key_info = key_info.model_dump()
        except Exception:
            # if using pydantic v1
            key_info = key_info.dict()
        key_token_hash: Final = key_info.pop("token")

        model_max_budget = key_info.get("model_max_budget") or {}
        budget_table: Final = key_info.get("litellm_budget_table") or {}
        if not model_max_budget and isinstance(budget_table, dict):
            model_max_budget = budget_table.get("model_max_budget") or {}
        if model_max_budget and key_token_hash:
            key_info["model_max_budget_usage"] = await _build_model_max_budget_usage(
                api_key_hash=key_token_hash,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Query only your own key (omit the key param — it defaults to the Authorization key).
  2. Use a proxy admin (master) key when you legitimately need other users' key info.
  3. For team keys, ensure the calling user is a member of that team first (POST /team/member_add).

Example fix

# before
client.headers["Authorization"] = "Bearer sk-regular-user"
client.get("/key/info", params={"key": "sk-someone-else"})

# after (admin needs others' info)
client.headers["Authorization"] = "Bearer sk-master"
client.get("/key/info", params={"key": "sk-someone-else"})
Defensive patterns

Strategy: validation

Validate before calling

# Only query keys you're permitted to see:
# - your own key (omit the key param), or
# - keys of a team you belong to (check membership first), or
# - use a proxy-admin key for arbitrary lookups.
def can_query(client, role: str, own_key: str, target_key: str) -> bool:
    return role in ("proxy_admin", "proxy_admin_view_only") or own_key == target_key

Try / catch

try:
    info = client.get("/key/info", params={"key": key})
    info.raise_for_status()
except HTTPError as e:
    if e.response.status_code == 403 and "not allowed to access this key's info" in e.response.text:
        return None  # deliberately not our key; skip silently
    raise

Prevention

When it happens

Trigger: A normal user key calling GET /key/info?key=<someone else's key>; a user who left the team querying a team key they no longer belong to; an auditor-style service key with no team membership or admin role requesting arbitrary keys.

Common situations: Internal tooling built with a shared non-admin key trying to display all keys; team membership removed but cached client still queries old team keys; misunderstanding that key ownership (not just authentication) is enforced for info reads.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/d1245b0dbc3c7ca7. Report an issue: GitHub.