Commit d095f1a
fix(litellm): strip CR/LF from provider API keys at startup (defense-in-depth)
A trailing newline in OPENROUTER_API_KEY (the GCP SM secret had been stored with
one) made httpx reject the outgoing Authorization header ("Newline, carriage
return, or null byte detected in headers. Potential header injection attack."),
silently breaking ~half of the codex->nemotron fallback (2026-06-24). The source
secret was fixed (newline stripped at the GCP SM source), but a malformed key
from ANY source must never be able to break routing again.
Sanitize the provider key env vars (OPENROUTER_API_KEY, OPENROUTER_API_KEY_2,
OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY) by stripping CR/LF in the
startup script before exec litellm; litellm inherits the cleaned env. Logs which
keys it sanitized. Validated in POSIX sh.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 3610295 commit d095f1a
1 file changed
Lines changed: 14 additions & 0 deletions
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
199 | 213 | | |
200 | 214 | | |
201 | 215 | | |
| |||
0 commit comments