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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
security(proxy): keep team callback credentials out of the stored request body (#43217)
devin-ai-integration[bot]703eb4fa6871
diff --git a/.githooks/commit-msg b/.githooks/commit-msgindex b64e38a2286..b602861c672 100755--- a/.githooks/commit-msg+++ b/.githooks/commit-msg@@ -42,7 +42,7 @@ case "$subject" in;;esac-ALLOWED_TYPES="feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert"+ALLOWED_TYPES="feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|security"# Description must not start with an uppercase letter — kept in sync with the# subjectPattern in .github/workflows/conventional-commits.yml so the local# hook is the strictly tighter of the two gates. (Without this guard, a commit@@ -61,7 +61,7 @@ cat >&2 <<EOFExpected: <type>(<scope>)!: <description>(description must start with a lowercase letter)- Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert+ Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert, securityExamples:feat(router): add weighted round-robin strategyfix(bedrock): decouple STS region from aws_region_namediff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.ymlindex eb9eb69f8b6..4ae59ed581f 100644--- a/.github/workflows/conventional-commits.yml+++ b/.github/workflows/conventional-commits.yml@@ -41,6 +41,7 @@ jobs:cichorerevert+ securityrequireScope: falsesubjectPattern: ^(?![A-Z]).+$subjectPatternError: |diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.pyindex 866d84ca8f2..d48451de6b1 100644--- a/litellm/proxy/litellm_pre_call_utils.py+++ b/litellm/proxy/litellm_pre_call_utils.py@@ -196,6 +196,9 @@ from litellm.types.utils import (SupportedCacheControls,)+_CALLBACK_CREDENTIAL_KEYS: Final = frozenset(StandardCallbackDynamicParams.__annotations__) | frozenset(+ {TRUSTED_CALLBACK_VARS_FIELD}+)service_logger_obj: Final = ServiceLogging() # used for tracking latency on OTEL# Bounded dedup for stale-alias warnings (FIFO eviction when over cap)._MAX_STALE_ALIAS_WARNING_KEYS: Final = 10_000@@ -1958,7 +1961,9 @@ def refresh_proxy_server_request_body_snapshot(if not isinstance(proxy_server_request, dict):return_body_snapshot_exclude: Final = (- frozenset({"secret_fields", "proxy_server_request", "litellm_logging_obj"}) | _TRANSPORT_ONLY_CREDENTIAL_KEYS+ frozenset({"secret_fields", "proxy_server_request", "litellm_logging_obj"})+ | _TRANSPORT_ONLY_CREDENTIAL_KEYS+ | _CALLBACK_CREDENTIAL_KEYS)body: Final = { # mutable-ok: audit JSON serialization requires a dict with shared nested messagesk: v for k, v in data.items() if k not in _body_snapshot_excludediff --git a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py b/tests/test_litellm/proxy/test_litellm_pre_call_utils.pyindex 1a3ffecb0a5..84266325226 100644--- a/tests/test_litellm/proxy/test_litellm_pre_call_utils.py+++ b/tests/test_litellm/proxy/test_litellm_pre_call_utils.py@@ -870,6 +870,31 @@ def test_initial_snapshot_refresh_clears_a_previous_guardrail_checkpoint() -> Noassert proxy_request == {"body": {"messages": [{"role": "user", "content": "new request"}]}}+def test_body_snapshot_excludes_team_callback_credentials() -> None:+ from litellm.proxy.litellm_pre_call_utils import refresh_proxy_server_request_body_snapshot+ from litellm.types.litellm_params import TRUSTED_CALLBACK_VARS_FIELD++ callback_vars: Final = {+ "langfuse_public_key": "pk-lf-team",+ "langfuse_secret_key": "sk-lf-team-secret",+ "langfuse_host": "https://cloud.langfuse.com",+ }+ proxy_request: Final = {"body": None}+ data: Final = {+ "messages": [{"role": "user", "content": "hi"}],+ "proxy_server_request": proxy_request,+ "success_callback": ["langfuse"],+ **callback_vars,+ TRUSTED_CALLBACK_VARS_FIELD: callback_vars,+ }++ refresh_proxy_server_request_body_snapshot(data)++ assert proxy_request == {+ "body": {"messages": [{"role": "user", "content": "hi"}], "success_callback": ["langfuse"]}+ }, proxy_request++@pytest.mark.asyncio@pytest.mark.parametrize("pre_call_ran", [False, True])async def test_post_guardrail_snapshot_preserves_logging_only_masking_in_spend_logs(