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]

fix(proxy): escape slack markup in model deprecation alert fields

mateo9b665380198d
diff --git a/litellm/proxy/common_utils/model_deprecation.py b/litellm/proxy/common_utils/model_deprecation.py
index 4a5654eed1f..8176a8cb642 100644
--- a/litellm/proxy/common_utils/model_deprecation.py
+++ b/litellm/proxy/common_utils/model_deprecation.py
@@ -175,6 +175,11 @@ def collect_model_deprecations(
)
+def _escape_slack_mrkdwn(value: str) -> str:
+ """Neutralize Slack control characters so a model name cannot forge a mention or link"""
+ return value.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
+
+
def _format_entry(info: ModelDeprecationInfo) -> str:
suffix: Final = (
f"already deprecated {abs(info.days_until_deprecation)}d ago"
@@ -182,8 +187,8 @@ def _format_entry(info: ModelDeprecationInfo) -> str:
else f"in {info.days_until_deprecation}d"
)
return (
- f"• `{info.model_name}` "
- f"(provider: {info.litellm_provider or 'unknown'}, "
+ f"• `{_escape_slack_mrkdwn(info.model_name)}` "
+ f"(provider: {_escape_slack_mrkdwn(info.litellm_provider) if info.litellm_provider else 'unknown'}, "
f"deprecates {info.deprecation_date.isoformat()}, {suffix})"
)
diff --git a/tests/test_litellm/proxy/common_utils/test_model_deprecation.py b/tests/test_litellm/proxy/common_utils/test_model_deprecation.py
index 103f9383f5a..051ddd2e78c 100644
--- a/tests/test_litellm/proxy/common_utils/test_model_deprecation.py
+++ b/tests/test_litellm/proxy/common_utils/test_model_deprecation.py
@@ -333,3 +333,30 @@ class TestFormatDeprecationAlertMessage:
assert "`soon`" in message
# Upcoming models must NOT be in the alert (avoid alert fatigue).
assert "`later`" not in message
+
+ def test_should_neutralize_slack_markup_from_model_metadata(self):
+ today = date(2026, 6, 1)
+ router = _make_router(
+ [
+ {
+ "model_name": "<!channel> pwned",
+ "litellm_params": {"model": "openai/whatever"},
+ "model_info": {
+ "id": "1",
+ "deprecation_date": "2026-06-10",
+ "litellm_provider": "<https://evil.example|openai> & co",
+ },
+ }
+ ]
+ )
+
+ snapshot = collect_model_deprecations(
+ llm_router=router, warn_within_days=30, today=today
+ )
+ message = format_deprecation_alert_message(snapshot)
+
+ assert message is not None
+ assert "<!channel>" not in message
+ assert "<https://evil.example|openai>" not in message
+ assert "&lt;!channel&gt; pwned" in message
+ assert "&lt;https://evil.example|openai&gt; &amp; co" in message