Skip to content

feat(litellm): block compromised proxy versions on startup - #1

Merged
imxj merged 5 commits into
imxj:feat/support_litellm_responsesfrom
kajalj22:feat/litellm-proxy-version-check
Jun 26, 2026
Merged

imxj merged 5 commits into
imxj:feat/support_litellm_responsesfrom
kajalj22:feat/litellm-proxy-version-check

Conversation

@kajalj22

@kajalj22 kajalj22 commented Jun 23, 2026 •

Copy link
Copy Markdown

Summary

Adds a startup version check to LiteLLMModelServer that blocks known-compromised LiteLLM proxy versions.

  • On startup, calls GET /health on the configured proxy and checks litellm_version
  • Hard-fails if v1.82.7 or v1.82.8 is detected (supply chain compromise, March 2026)
  • Logs a non-blocking warning if the proxy doesn't expose version info

Context

Companion to NVIDIA-NeMo#990. LiteLLM v1.82.7 and v1.82.8 contained credential-harvesting malware injected via a PyPI supply chain attack (~40 min window, March 24 2026). The malware exfiltrated env vars, SSH keys, and cloud credentials from the host running the proxy. See: https://docs.litellm.ai/blog/security-update-march-2026

Since LiteLLMModelServer makes real HTTP calls to a LiteLLM proxy at runtime, there is no control over which version the proxy operator runs. This check gives an early, loud failure rather than silently routing traffic through a compromised proxy.

🤖 Generated with Claude Code

kajalj22 and others added 3 commits June 23, 2026 17:37
Adds a startup HTTP check against the LiteLLM proxy's /health endpoint
to detect and hard-fail on v1.82.7 and v1.82.8, which contained
credential-harvesting malware (supply chain incident, March 2026).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
/health/readiness/details is the correct endpoint that exposes
litellm_version — verified against v1.89.3. /health does not
include version info.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
- Add TestVersionCheck with three cases: compromised version blocks
  startup, safe version passes, unreachable proxy only warns
- Add mock_safe_version fixture auto-applied to all server integration
  tests so they don't make real HTTP calls during the startup check

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
@kajalj22
kajalj22 marked this pull request as ready for review June 25, 2026 00:08
@imxj

imxj commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Thanks for adding this. I agree with the direction, but I think the current version check still fails open in a few important cases:

  • it only blocks exact versions 1.82.7 / 1.82.8, rather than enforcing >= 1.83.0
  • /health/readiness/details is auth-gated in newer LiteLLM, but the check does not send the configured proxy key
  • auth failure / unreachable proxy / missing litellm_version should fail startup rather than warning and continuing
  • the integration tests should use TestClient(app) as a context manager so the lifespan startup hook is actually exercised

I pushed a concrete fix here for reference:
https://github.com/imxj/Gym/tree/fix/litellm-proxy-version-check-fail-closed

Commit: 31f61b6e

Could you incorporate those changes into this PR?

…ersion check errors

- Add x-litellm-key to _SENSITIVE_HEADER_RE so the newly introduced
  auth header is redacted alongside Authorization in all error paths
- Wrap the exception interpolation in _check_proxy_version with
  _sanitize_error() so API keys cannot leak into RuntimeError messages
  if aiohttp surfaces request headers in the exception

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
@kajalj22

Copy link
Copy Markdown
Author

Great points, thanks for the fix - added into the PR!
Ready to merge now @imxj

@imxj
imxj merged commit 4d9db89 into imxj:feat/support_litellm_responses Jun 26, 2026
imxj pushed a commit that referenced this pull request Jun 26, 2026
…uting (NVIDIA-NeMo#1367)

## Summary

Two coupled changes that together fix walltime-induced rollout loss on
multi-node GDPVal runs.

**1. Per-task timeout** — default 3h30m, env
`STIRRUP_PER_TASK_TIMEOUT_S` overrides. Wraps `await future` in
`asyncio.wait_for`; on timeout, `ray.cancel(future, force=True)` +
raises `TaskPerAttemptTimeoutError`. Logs once per process at first
dispatch.

**2. Failure classification + sidecar routing** — at the two
`_build_failed_run_payload` callsites, every failure is classified into
one of five classes and persisted accordingly:

| class | persist | retry on chain-hop 2 |
|---|---|---|
| `kill_shaped` (Ray actor died, SIGTERM, OOM, node failure) | NO row
anywhere | yes, unbounded (per-attempt timeout bounds wallclock) |
| `timeout_exceeded` | 1 sidecar entry, `_ng_failure_terminal=True` | no
|
| `skipped` (TaskSampleSkipError) | 1 sidecar entry, terminal | no |
| `transient` (verify-side 5xx, ConnectionError, asyncio.TimeoutError) |
sidecar entry per attempt | yes, up to `NEMO_GYM_MAX_ROLLOUT_ATTEMPTS`
(default 3) |
| `legitimate` (real Python exception with user code in traceback) |
sidecar entry per attempt | yes, up to max_attempts |

Successes still write to `<output_jsonl_fpath>`; failures write to
`<stem>_failures.jsonl`. `_load_from_cache` reads both: main jsonl is
the success ledger, sidecar tracks attempts + terminal flags. The retry
set is `materialized_inputs − (successes ∪ terminal ∪ maxed_out)`.

## Why this matters

Without #1, a single pathological task that exceeds Slurm walltime can
permanently consume every chain-hop's compute and never complete.

Without NVIDIA-NeMo#2, walltime-killed in-flight rollouts permanently disappear on
chain-hop 2. The old `_load_from_cache` dedup keyed on `(task_index,
rollout_index)` regardless of `-failed` status, so synthetic `-failed`
rows written during the SIGTERM grace window looked already-done to the
resumer. Worse, under harsh kills (SIGKILL, OOM) the `-failed` row write
itself is non-atomic — we couldn't depend on it being there to filter.
Using "row absent from main jsonl" as the canonical "needs retry" signal
sidesteps both problems: kill_shaped writes nothing at all, so the disk
state survives arbitrary kill timing.

See the debug write-up for the production incident and design rationale:
https://gitlab-master.nvidia.com/agronskiy/idea/-/blob/main/reports/debug/20260519T1011-gdpval-missing-histories.md

## Kill-shaped detection

`_classify_rollout_failure` uses Ray's actor-died classes
(`RayActorError`, `WorkerCrashedError`, `NodeDiedError`,
`OutOfMemoryError`, `LocalRayletDiedError`) plus a
user-code-in-traceback fallback for `RayTaskError`. The fallback
distinguishes a real user exception (frames under
\`responses_api_agents/\` or \`stirrup/\`) from Ray's internal
post-mortem (e.g. summary-builder hitting a vanished worker log after
Slurm's epilogue scrubbed `/tmp/ray`) — the latter is the walltime /
SIGTERM signature and routes to `kill_shaped`. Detection fails open: if
Ray's exception surface drifts, everything goes to bounded-retry
`legitimate` instead of unbounded-retry `kill_shaped` — safe, not
catastrophic.

## Knobs

- `STIRRUP_PER_TASK_TIMEOUT_S` — per-attempt timeout (default 12600 s =
3h30m).
- `NEMO_GYM_MAX_ROLLOUT_ATTEMPTS` — max retries per `(task_index,
rollout_index)` (default 3).

## Test plan

- \`python -m py_compile\` clean for both edited files.
- ruff format clean.
- Suggested smoke: run a GDPVal eval with
`STIRRUP_PER_TASK_TIMEOUT_S=60`, confirm the log line is emitted once
and that long-running rollouts get cancelled cleanly with
`_ng_failure_class=timeout_exceeded` in `<stem>_failures.jsonl`.
- Suggested integration: deliberately kill the deployment srun mid-run
(`scancel -s TERM`), verify `_failures.jsonl` is unchanged (kill_shaped
writes nothing) and that on chain-hop 2 the killed rollouts re-dispatch.

---------

Signed-off-by: Alex Gronskiy <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
imxj added a commit that referenced this pull request Jun 27, 2026
feat(litellm): block compromised proxy versions on startup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants