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]

chore(container,skills): drop legacy-access opt-out env vars

userde682c810e40
diff --git a/litellm/llms/litellm_proxy/skills/handler.py b/litellm/llms/litellm_proxy/skills/handler.py
index e5caf3cffc7..086dccd4032 100644
--- a/litellm/llms/litellm_proxy/skills/handler.py
+++ b/litellm/llms/litellm_proxy/skills/handler.py
@@ -5,7 +5,6 @@ This module contains the actual database operations for skills CRUD.
Used by the transformation layer and skills injection hook.
"""
-import os
import time
import uuid
from collections import OrderedDict
@@ -21,8 +20,6 @@ from litellm.proxy.common_utils.resource_ownership import (
user_can_access_resource_owner,
)
-ALLOW_UNOWNED_SKILL_ACCESS_ENV = "LITELLM_ALLOW_UNOWNED_SKILL_ACCESS"
-
# Skills are looked up on every chat completion that has skills enabled
# (`LiteLLMSkillsHandler.fetch_skill_from_db` in the injection hook). Cache
# the Prisma skill row for a short window so the hot path doesn't issue a DB
@@ -62,27 +59,14 @@ def _invalidate_skill_cache(skill_id: str) -> None:
_SKILL_CACHE.pop(skill_id, None)
-def _allow_unowned_skill_access() -> bool:
- return os.getenv(ALLOW_UNOWNED_SKILL_ACCESS_ENV, "").lower() in {
- "1",
- "true",
- "yes",
- }
-
-
def _user_can_access_skill_owner(
owner: Optional[str],
user_api_key_dict: Optional[UserAPIKeyAuth],
) -> bool:
- if owner is None and user_api_key_dict is not None:
- if is_proxy_admin(user_api_key_dict):
- return True
- if _allow_unowned_skill_access():
- verbose_logger.warning(
- "Allowing unowned skill access because %s is enabled",
- ALLOW_UNOWNED_SKILL_ACCESS_ENV,
- )
- return True
+ # Pre-isolation skills with no ``created_by`` are admin-only — same
+ # rule as untracked containers. Owners need to either re-create via
+ # the now-tracked flow or have an admin assign ``created_by`` on the
+ # row.
return user_can_access_resource_owner(owner, user_api_key_dict)
@@ -216,15 +200,7 @@ class LiteLLMSkillsHandler:
owner_scopes = get_resource_owner_scopes(user_api_key_dict)
if not owner_scopes:
return []
- if _allow_unowned_skill_access():
- find_many_kwargs["where"] = {
- "OR": [
- {"created_by": {"in": owner_scopes}},
- {"created_by": None},
- ]
- }
- else:
- find_many_kwargs["where"] = {"created_by": {"in": owner_scopes}}
+ find_many_kwargs["where"] = {"created_by": {"in": owner_scopes}}
skills = await store.list_skills(find_many_kwargs)
diff --git a/litellm/proxy/container_endpoints/ownership.py b/litellm/proxy/container_endpoints/ownership.py
index 4905c6537db..6bfea87ebf6 100644
--- a/litellm/proxy/container_endpoints/ownership.py
+++ b/litellm/proxy/container_endpoints/ownership.py
@@ -1,4 +1,3 @@
-import os
import time
from collections import OrderedDict
from typing import Any, Dict, List, Optional, Set, Tuple
@@ -19,7 +18,6 @@ from litellm.proxy.container_endpoints.ownership_store import (
)
from litellm.responses.utils import ResponsesAPIRequestUtils
-ALLOW_UNTRACKED_CONTAINER_ACCESS_ENV = "LITELLM_ALLOW_UNTRACKED_CONTAINER_ACCESS"
MAX_IN_MEMORY_CONTAINER_OWNERS = 10000
_IN_MEMORY_CONTAINER_OWNERS: "OrderedDict[str, str]" = OrderedDict()
@@ -64,14 +62,6 @@ def _invalidate_container_owner_cache(model_object_id: str) -> None:
_CONTAINER_OWNER_CACHE.pop(model_object_id, None)
-def _allow_untracked_container_access() -> bool:
- return os.getenv(ALLOW_UNTRACKED_CONTAINER_ACCESS_ENV, "").lower() in {
- "1",
- "true",
- "yes",
- }
-
-
def _remember_container_owner(model_object_id: str, owner: str) -> None:
existing_owner = _IN_MEMORY_CONTAINER_OWNERS.get(model_object_id)
if existing_owner is not None:
@@ -280,14 +270,11 @@ async def assert_user_can_access_container(
if is_proxy_admin(user_api_key_dict):
return original_container_id, resolved_provider
+ # Untracked containers (no ownership row) are admin-only. Pre-isolation
+ # rows that pre-date this enforcement need the admin to either re-create
+ # via the now-tracked flow or explicitly assign ``created_by`` on the
+ # ``litellm_managedobjecttable`` row.
owner = await _get_container_owner(original_container_id, resolved_provider)
- if owner is None and _allow_untracked_container_access():
- verbose_proxy_logger.warning(
- "Allowing untracked container access because %s is enabled",
- ALLOW_UNTRACKED_CONTAINER_ACCESS_ENV,
- )
- return original_container_id, resolved_provider
-
if not user_can_access_resource_owner(owner, user_api_key_dict):
raise HTTPException(status_code=403, detail="Forbidden")
diff --git a/tests/test_litellm/containers/test_container_proxy_ownership.py b/tests/test_litellm/containers/test_container_proxy_ownership.py
index 2d175ceedb6..2e82b5b6b2d 100644
--- a/tests/test_litellm/containers/test_container_proxy_ownership.py
+++ b/tests/test_litellm/containers/test_container_proxy_ownership.py
@@ -12,10 +12,9 @@ from litellm.types.containers.main import ContainerListResponse, ContainerObject
@pytest.fixture(autouse=True)
-def clear_in_memory_container_owners(monkeypatch):
+def clear_in_memory_container_owners():
ownership._IN_MEMORY_CONTAINER_OWNERS.clear()
ownership._CONTAINER_OWNER_CACHE.clear()
- monkeypatch.delenv(ownership.ALLOW_UNTRACKED_CONTAINER_ACCESS_ENV, raising=False)
yield
ownership._IN_MEMORY_CONTAINER_OWNERS.clear()
ownership._CONTAINER_OWNER_CACHE.clear()
@@ -384,23 +383,26 @@ async def test_should_fail_closed_when_owner_lookup_fails_without_memory(monkeyp
@pytest.mark.asyncio
-async def test_should_allow_untracked_container_access_when_enabled(monkeypatch):
+async def test_untracked_container_is_admin_only(monkeypatch):
+ """Pre-isolation containers with no ownership row are admin-only.
+ Non-admin callers see them as 403, with no opt-out flag re-opening
+ the cross-tenant access primitive."""
+ from fastapi import HTTPException
+
monkeypatch.setattr(
ownership,
"_get_prisma_client",
AsyncMock(return_value=None),
)
- monkeypatch.setenv(ownership.ALLOW_UNTRACKED_CONTAINER_ACCESS_ENV, "true")
auth = UserAPIKeyAuth(user_id="user-1")
- original_id, provider = await ownership.assert_user_can_access_container(
- container_id="cntr_untracked",
- user_api_key_dict=auth,
- custom_llm_provider="openai",
- )
-
- assert original_id == "cntr_untracked"
- assert provider == "openai"
+ with pytest.raises(HTTPException) as exc:
+ await ownership.assert_user_can_access_container(
+ container_id="cntr_untracked",
+ user_api_key_dict=auth,
+ custom_llm_provider="openai",
+ )
+ assert exc.value.status_code == 403
@pytest.mark.asyncio
diff --git a/tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py b/tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py
index d6c0601a57c..cef5f8a554b 100644
--- a/tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py
+++ b/tests/test_litellm/llms/litellm_proxy/test_skills_ownership.py
@@ -18,8 +18,7 @@ from litellm.skills import main as skills_main
@pytest.fixture(autouse=True)
-def clear_skill_ownership_env(monkeypatch):
- monkeypatch.delenv(skills_handler.ALLOW_UNOWNED_SKILL_ACCESS_ENV, raising=False)
+def clear_skill_cache():
skills_handler._SKILL_CACHE.clear()
yield
skills_handler._SKILL_CACHE.clear()
@@ -358,7 +357,10 @@ async def test_should_hide_unowned_skill_by_default(monkeypatch):
@pytest.mark.asyncio
-async def test_should_allow_unowned_skill_when_enabled(monkeypatch):
+async def test_unowned_skill_is_admin_only(monkeypatch):
+ """Pre-isolation skills with no ``created_by`` are admin-only — non-admin
+ callers see the same "not found" they'd see for a missing row, with no
+ opt-out env var that re-opens the cross-tenant access primitive."""
table = AsyncMock()
table.find_unique.return_value = _skill("litellm_skill_unowned", None)
prisma_client = type(
@@ -369,22 +371,22 @@ async def test_should_allow_unowned_skill_when_enabled(monkeypatch):
"_get_prisma_client",
AsyncMock(return_value=prisma_client),
)
- monkeypatch.setenv(skills_handler.ALLOW_UNOWNED_SKILL_ACCESS_ENV, "true")
auth = UserAPIKeyAuth(user_id="user-1")
- skill = await LiteLLMSkillsHandler.get_skill(
- "litellm_skill_unowned",
- user_api_key_dict=auth,
- )
-
- assert skill.skill_id == "litellm_skill_unowned"
+ with pytest.raises(ValueError, match="Skill not found"):
+ await LiteLLMSkillsHandler.get_skill(
+ "litellm_skill_unowned",
+ user_api_key_dict=auth,
+ )
@pytest.mark.asyncio
-async def test_should_include_unowned_skills_in_list_when_enabled(monkeypatch):
+async def test_list_skills_excludes_unowned_for_non_admin(monkeypatch):
+ """Non-admin list queries scope to ``created_by IN owner_scopes``; rows
+ with ``created_by IS NULL`` are excluded — admin-only."""
table = AsyncMock()
- table.find_many.return_value = [_skill("litellm_skill_unowned", None)]
+ table.find_many.return_value = []
prisma_client = type(
"Prisma", (), {"db": type("DB", (), {"litellm_skillstable": table})()}
)()
@@ -393,18 +395,13 @@ async def test_should_include_unowned_skills_in_list_when_enabled(monkeypatch):
"_get_prisma_client",
AsyncMock(return_value=prisma_client),
)
- monkeypatch.setenv(skills_handler.ALLOW_UNOWNED_SKILL_ACCESS_ENV, "true")
auth = UserAPIKeyAuth(user_id="user-1")
+ await LiteLLMSkillsHandler.list_skills(user_api_key_dict=auth)
- skills = await LiteLLMSkillsHandler.list_skills(user_api_key_dict=auth)
-
- assert [skill.skill_id for skill in skills] == ["litellm_skill_unowned"]
where = table.find_many.await_args.kwargs["where"]
- assert where["OR"] == [
- {"created_by": {"in": ["user-1", "user:user-1"]}},
- {"created_by": None},
- ]
+ # No OR fallback to ``created_by IS NULL`` — strict scope only.
+ assert where == {"created_by": {"in": ["user-1", "user:user-1"]}}
@pytest.mark.asyncio