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]

Merge branch 'litellm_internal_staging' into fix/admin-viewer-write-route-blocklist

Krrish Dholakia684174ca58a7
diff --cc litellm/proxy/auth/route_checks.py
index 5f49b5eb354,dba29f84133..8bcfbb67539
--- a/litellm/proxy/auth/route_checks.py
+++ b/litellm/proxy/auth/route_checks.py
@@@ -655,45 -664,35 +708,60 @@@ class RouteChecks
detail=f"user not allowed to access this OpenAI routes, role= {_user_role}",
)
+ # Check if this is a write operation on management routes
+ if RouteChecks.check_route_access(
+ route=route, allowed_routes=LiteLLMRoutes.management_routes.value
+ ):
+ # For management routes, only allow read operations or specific allowed updates
+ if route == "/user/update":
+ # Check the Request params are valid for PROXY_ADMIN_VIEW_ONLY
+ if request_data is not None and isinstance(request_data, dict):
+ _params_updated = request_data.keys()
+ for param in _params_updated:
+ if param not in ["user_email", "password"]:
+ raise HTTPException(
+ status_code=status.HTTP_403_FORBIDDEN,
+ detail=f"user not allowed to access this route, role= {_user_role}. Trying to access: {route} and updating invalid param: {param}. only user_email and password can be updated",
+ )
+ elif route in _PROXY_ADMIN_VIEW_ONLY_BLOCKED_ROUTES or (
+ route.startswith("/key/")
+ and route.endswith(_PROXY_ADMIN_VIEW_ONLY_BLOCKED_KEY_SUFFIXES)
+ ):
+ # Block write operations for PROXY_ADMIN_VIEW_ONLY
+ raise HTTPException(
+ status_code=status.HTTP_403_FORBIDDEN,
+ detail=f"user not allowed to access this route, role= {_user_role}. Trying to access: {route}",
+ )
+ # Allow read operations on management routes (like /user/info, /team/info, /model/info)
+ method = request.method.upper() if request is not None else "GET"
+ is_safe_method = method in RouteChecks._SAFE_HTTP_METHODS
+
+ # ── Safe HTTP method: default-allow ──────────────────────────────
+ if is_safe_method:
return
- elif RouteChecks.check_route_access(
- route=route, allowed_routes=LiteLLMRoutes.admin_viewer_routes.value
- ):
- # Allow access to admin viewer routes (read-only admin endpoints)
+
+ # ── Unsafe HTTP method: explicit checks ──────────────────────────
+ # Allow `/user/update` for self-service email / password change.
+ if route == "/user/update":
+ if request_data is not None and isinstance(request_data, dict):
+ for param in request_data.keys():
+ if param not in ["user_email", "password"]:
+ raise HTTPException(
+ status_code=status.HTTP_403_FORBIDDEN,
+ detail=(
+ f"user not allowed to access this route, role= {_user_role}. "
+ f"Trying to access: {route} and updating invalid param: {param}. "
+ "only user_email and password can be updated"
+ ),
+ )
return
- elif RouteChecks.check_route_access(
- route=route, allowed_routes=LiteLLMRoutes.global_spend_tracking_routes.value
+
+ # Hard-block known write routes regardless of HTTP method (defensive
+ # — these are POSTs in practice, but pinning them here protects
+ # against future GET-shaped writes).
+ if route in RouteChecks._ADMIN_VIEWER_BLOCKED_WRITE_ROUTES or (
+ route.startswith("/key/") and route.endswith("/regenerate")
):
- # Allow access to global spend tracking routes (read-only spend endpoints)
- # proxy_admin_viewer role description: "view all keys, view all spend"
- return
- else:
- # For other routes, block access
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=f"user not allowed to access this route, role= {_user_role}. Trying to access: {route}",