Skip to content

Commit 98d709d

Browse files
fix(key_management_endpoints.py): retain error check when non proxy admin is trying to update key belonging to a different user
1 parent 97e00f6 commit 98d709d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

litellm/proxy/management_endpoints/key_management_endpoints.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,17 @@ async def update_key_fn(
13441344
detail={"error": f"Team not found, passed team_id={data.team_id}"},
13451345
)
13461346

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+
13471358
common_key_access_checks(
13481359
user_api_key_dict=user_api_key_dict,
13491360
data=data,

0 commit comments

Comments
 (0)