fix(vector_stores): restrict vector store and index deletion to proxy admins only

Non-admin keys could delete vector stores via DELETE /v1/vector_stores/{id}
and delete Azure AI Search indexes via the azure_ai pass-through endpoint.
Added PROXY_ADMIN checks to both paths (registered-index and generic fallthrough).

Made-with: Cursor
This commit is contained in:
shivam 2026-04-25 14:29:06 -07:00
parent 3c0d172d4e
commit 64daf17449
No known key found for this signature in database
2 changed files with 27 additions and 1 deletions

View file

@ -47,6 +47,7 @@ from litellm.types.passthrough_endpoints.pass_through_endpoints import (
)
from litellm.proxy.utils import is_known_model
from litellm.proxy.vector_store_endpoints.utils import (
_is_proxy_admin,
is_allowed_to_call_vector_store_endpoint,
)
from litellm.secret_managers.main import get_secret_str
@ -1369,6 +1370,14 @@ async def azure_proxy_route(
),
)
elif is_vector_store_index:
if request.method == "DELETE" and not _is_proxy_admin(
user_api_key_dict
):
raise HTTPException(
status_code=403,
detail="Only proxy admins can delete vector store indexes.",
)
# get the api key from the provider config
provider_config = (
ProviderConfigManager.get_provider_vector_stores_config(
@ -1428,6 +1437,14 @@ async def azure_proxy_route(
extra_headers=cast(dict, extra_headers),
)
if request.method == "DELETE" and "indexes" in endpoint and not _is_proxy_admin(
user_api_key_dict
):
raise HTTPException(
status_code=403,
detail="Only proxy admins can delete vector store indexes.",
)
base_target_url = get_secret_str(secret_name="AZURE_API_BASE")
if base_target_url is None:
raise Exception(

View file

@ -10,7 +10,10 @@ from litellm.proxy._types import CommonProxyErrors, UserAPIKeyAuth
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
from litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing
from litellm.proxy.utils import jsonify_object
from litellm.proxy.vector_store_endpoints.utils import can_user_access_vector_store
from litellm.proxy.vector_store_endpoints.utils import (
_is_proxy_admin,
can_user_access_vector_store,
)
from litellm.types.vector_stores import IndexCreateRequest
router = APIRouter()
@ -498,6 +501,12 @@ async def vector_store_delete(
API Reference:
https://platform.openai.com/docs/api-reference/vector-stores/delete
"""
if not _is_proxy_admin(user_api_key_dict):
raise HTTPException(
status_code=403,
detail="Only proxy admins can delete vector stores.",
)
from litellm.proxy.proxy_server import (
general_settings,
llm_router,