Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: extend field-level checks to bulk user update path

Yuneng Jiang128d32d2494b
diff --git a/litellm/proxy/management_endpoints/internal_user_endpoints.py b/litellm/proxy/management_endpoints/internal_user_endpoints.py
index b763d0704c0..476625f50ae 100644
--- a/litellm/proxy/management_endpoints/internal_user_endpoints.py
+++ b/litellm/proxy/management_endpoints/internal_user_endpoints.py
@@ -1518,6 +1518,23 @@ async def bulk_user_update(
detail={"error": "Database not connected"},
)
+ # Only proxy admins can modify user_role in bulk updates
+ _bulk_role = (
+ getattr(data.user_updates, "user_role", None) if data.user_updates else None
+ )
+ if _bulk_role is None and data.users:
+ _bulk_role = next(
+ (u.user_role for u in data.users if u.user_role is not None), None
+ )
+ if (
+ _bulk_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.",
+ )
+
# Determine the list of users to update
users_to_update: Union[
List[UpdateUserRequest], List[UpdateUserRequestNoUserIDorEmail]