mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
fix(security): redact logging callback_vars in key info/list endpoints
This commit is contained in:
parent
f155385e3e
commit
e104f42965
1 changed files with 13 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ from litellm.proxy.auth.auth_checks import (
|
|||
)
|
||||
from litellm.proxy.auth.auth_utils import abbreviate_api_key
|
||||
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
|
||||
from litellm.proxy.common_utils.callback_utils import redact_sensitive_logging_metadata
|
||||
from litellm.proxy.common_utils.timezone_utils import get_budget_reset_time
|
||||
from litellm.proxy.hooks.key_management_event_hooks import KeyManagementEventHooks
|
||||
from litellm.proxy.management_endpoints.common_utils import (
|
||||
|
|
@ -2708,6 +2709,9 @@ async def info_key_fn_v2(
|
|||
except Exception:
|
||||
k_dict = k.dict()
|
||||
k_dict.pop("token", None)
|
||||
k_dict["metadata"] = redact_sensitive_logging_metadata(
|
||||
k_dict.get("metadata")
|
||||
)
|
||||
filtered_key_info.append(k_dict)
|
||||
return {"key": data.keys, "info": filtered_key_info}
|
||||
|
||||
|
|
@ -2791,6 +2795,12 @@ async def info_key_fn(
|
|||
key_info = key_info.dict()
|
||||
key_info.pop("token")
|
||||
|
||||
# Scrub credentials stored in metadata.logging[].callback_vars so
|
||||
# Langfuse / other integration secrets are never returned in plaintext.
|
||||
key_info["metadata"] = redact_sensitive_logging_metadata(
|
||||
key_info.get("metadata")
|
||||
)
|
||||
|
||||
# Attach object_permission if object_permission_id is set
|
||||
key_info = await attach_object_permission_to_dict(key_info, prisma_client)
|
||||
|
||||
|
|
@ -4934,6 +4944,9 @@ async def _list_key_helper(
|
|||
}
|
||||
|
||||
if return_full_object is True or (expand and "user" in expand):
|
||||
key_dict["metadata"] = redact_sensitive_logging_metadata(
|
||||
key_dict.get("metadata")
|
||||
)
|
||||
if use_deleted_table:
|
||||
# Use deleted key type to preserve deleted_at, deleted_by, etc.
|
||||
key_list.append(LiteLLM_DeletedVerificationToken(**key_dict))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue