Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4399,7 +4399,10 @@ async def validate_key_list_check(
key_hash: Optional[str],
prisma_client: PrismaClient,
) -> Optional[LiteLLM_UserTable]:
if user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value:
if user_api_key_dict.user_role in [
LitellmUserRoles.PROXY_ADMIN.value,
LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY.value,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: Bearer-equivalent key hashes exposed to view-only admins

/key/list returns token values from _list_key_helper by default, and _hash_token_if_needed() leaves non-sk- values unchanged during auth lookup. A proxy_admin_viewer can now list every stored key hash and use one directly as Authorization: Bearer <hash> to make requests as that key, bypassing the role's LLM-route restrictions.

Keep the all-key listing for this role only if the response no longer includes bearer-equivalent token hashes, or change authentication so stored hashes are not accepted as presented bearer credentials.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a new concern introduced by this PR. The /key/list endpoint returns SHA-256 hashed tokens to PROXY_ADMIN users today -- adding PROXY_ADMIN_VIEW_ONLY grants the same visibility that full admins already have. The viewer role is designed to have read-only parity with admin. If token hash exposure in /key/list responses is a concern, it applies to the existing PROXY_ADMIN path equally and should be addressed separately.

]:
return None

if user_api_key_dict.user_id is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6509,6 +6509,27 @@ async def test_validate_key_list_check_proxy_admin():
assert result is None


@pytest.mark.asyncio
async def test_validate_key_list_check_proxy_admin_viewer():
mock_prisma_client = AsyncMock()
user_api_key_dict = UserAPIKeyAuth(
user_role=LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY,
user_id=None,
)

result = await validate_key_list_check(
user_api_key_dict=user_api_key_dict,
user_id=None,
team_id=None,
organization_id=None,
key_alias=None,
key_hash=None,
prisma_client=mock_prisma_client,
)

assert result is None


@pytest.mark.asyncio
async def test_validate_key_list_check_team_admin_success():
mock_prisma_client = AsyncMock()
Expand Down
Loading