File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
litellm/proxy/management_endpoints Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1344,6 +1344,17 @@ async def update_key_fn(
1344
1344
detail = {"error" : f"Team not found, passed team_id={ data .team_id } " },
1345
1345
)
1346
1346
1347
+ ## sanity check - prevent non-proxy admin user from updating key to belong to a different user
1348
+ if (
1349
+ data .user_id is not None
1350
+ and data .user_id != existing_key_row .user_id
1351
+ and user_api_key_dict .user_role != LitellmUserRoles .PROXY_ADMIN .value
1352
+ ):
1353
+ raise HTTPException (
1354
+ status_code = 403 ,
1355
+ detail = f"User={ data .user_id } is not allowed to update key={ key } to belong to user={ existing_key_row .user_id } " ,
1356
+ )
1357
+
1347
1358
common_key_access_checks (
1348
1359
user_api_key_dict = user_api_key_dict ,
1349
1360
data = data ,
You can’t perform that action at this time.
0 commit comments