この記事は英語で公開されています。

By UNST33R

LiteLLM as a red-team gateway: pinned versions, virtual keys, and multi-model sweeps behind one egress

After October's trojanized 1.107.0 release, a LiteLLM proxy is simultaneously your best control point and a supply-chain liability. A worked setup: three model tiers behind one OpenAI-compatible gateway, per-engagement virtual keys with budgets, harness wiring for PyRIT, promptfoo, and garak, and the pinning posture that would have survived the backdoor.

On October 21, 2026, a trojanized LiteLLM 1.107.0 spent two hours on PyPI stealing credentials from every host that installed it, and the payload's first database query was SELECT * FROM "LiteLLM_CredentialsTable" LIMIT 500. If you run offensive-security workloads, that sentence collapses two ideas into one box. The gateway layer is where your key hygiene, spend control, and model routing live, so it is your best control point. It is also a pip package with release infrastructure, so it is a supply-chain dependency like any other. This guide sets up both halves deliberately: a LiteLLM proxy fronting the three UNST33R tiers, with per-engagement keys and budgets, then the pinning posture that makes the next 1.107.0 a non-event for your fleet.

The pattern is worth stating plainly before the config. Harnesses come and go; the gateway is the stable seam. PyRIT, promptfoo, garak, OpenClaw, and custom agent loops all speak the OpenAI-compatible Chat Completions contract, and every one of them lets you point that contract at a base URL. Point them all at one gateway you control, and key rotation becomes a config edit instead of a fleet-wide scramble.

What the gateway buys you

Problem in a red-team fleetGateway control
One static API key copied into five harness configsHarnesses hold disposable virtual keys; the real key exists only in the proxy's env
Engagement A burning budget meant for engagement BPer-key max_budget and budget_duration, enforced by the proxy
Sweeps stalling when a tier rate-limits mid-runRouter-level retries, cooldowns, and fallbacks across tiers
Cost attribution across phases and clientsPer-key spend tracking in one database instead of five log greps
Provider change forcing harness rewritesHarness configs stay fixed; backends change behind model_name

The config

Three tiers behind stable names. The proxy reads the real key from the environment; nothing else ever sees it.

# config.yaml
model_list:
  - model_name: unst33r-flash          # GLM-5.3-Flash, high-volume recon loops
    litellm_params:
      model: openai/unst33r-flash
      api_base: https://api.unst33r.si/v1
      api_key: os.environ/UNST33R_API_KEY
  - model_name: unst33r-deepseek       # DeepSeek-V4.1-Flash, 1M-context source audits
    litellm_params:
      model: openai/unst33r-deepseek
      api_base: https://api.unst33r.si/v1
      api_key: os.environ/UNST33R_API_KEY
  - model_name: unst33r-pro            # GLM-5.3, long-horizon terminal chains
    litellm_params:
      model: openai/unst33r-pro
      api_base: https://api.unst33r.si/v1
      api_key: os.environ/UNST33R_API_KEY

litellm_settings:
  drop_params: true          # harnesses send provider-specific extras; absorb them
  num_retries: 2
  request_timeout: 120       # long agent turns, generous ceiling

router_settings:
  routing_strategy: usage-based-routing-v2
  allowed_fails: 3
  cooldown_time: 60

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

Tier-to-workload mapping is a model-selection question covered in which model tier for which security workload; the gateway deliberately makes that choice reversible at request time by model name.

Launch it pinned (more on pinning below):

pip install litellm==<audited-version>   # never floating "latest"
export UNST33R_API_KEY=sk-...            # the one real credential
export LITELLM_MASTER_KEY=sk-...         # admin, never leaves the ops host
litellm --config config.yaml --port 4000

Per-engagement virtual keys

The October payload went straight for the credentials table because that table is the crown jewel: it holds every upstream key the proxy can use. Virtual keys invert the exposure. Harnesses get short-lived, budget-capped keys that mint from the master key, and a leaked sweep config leaks a capped artifact instead of your provider account.

curl -X POST http://localhost:4000/key/generate \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "key_alias": "engagement-acme-phase1-recon",
        "models": ["unst33r-flash", "unst33r-deepseek"],
        "max_budget": 25,
        "budget_duration": "7d"
      }'

That key authorizes exactly two tiers, twenty-five dollars, and one week. Phase 2 of the same engagement gets its own key, so the client's invoice reads like your actual work phases. Rotate by revoking and re-minting; harness configs only ever contained the disposable half. Budget enforcement and spend reporting follow the official virtual keys and cost tracking docs.

Pointing harnesses at it

Every tool below keeps working if you swap the gateway's backends tomorrow, which is the whole point of the seam. PyRIT connects through LiteLLMChatTarget, the same target our multi-model sweep guide uses against the direct endpoint; here the endpoint is your proxy:

from pyrit.models import LiteLLMChatTarget

target = LiteLLMChatTarget(
    model="unst33r-flash",
    endpoint="http://localhost:4000",      # the gateway
    api_key="sk-acme-phase1-...",          # virtual key
)

promptfoo's provider config takes the same shape, matching the red-team regression setup we documented for CI:

providers:
  - openai:chat:unst33r-pro
    config:
      apiBaseUrl: http://localhost:4000
      apiKey: sk-acme-phase1-...

garak takes --model_type openai --model_name unst33r-deepseek with OPENAI_API_BASE pointed at the proxy. Agent runtimes wire up the same way via the OpenClaw and Hermes integration guides, and ad-hoc client work follows the base-URL switch guide. One gateway, five consumers, zero real credentials in any of them.

The pinning posture that survives the next backdoor

The October incident had a clean boundary: fleets pinned below 1.107.0 were untouched, and the attack analysis showed the malicious commits rode a lookalike org and stolen OAuth tokens into the release chain. Your gateway posture should assume a repeat is possible on any package you install.

  • Pin exact versions in requirements with ==, upgrade deliberately after reading the diff, and treat a surprise version bump in a lockfile as an incident signal.
  • Prefer hash-pinned installs or digest-pinned images so a re-pushed tag cannot silently change what you run.
  • Egress-allowlist the proxy host. The payload exfiltrated to a lookalike domain the operator had no reason to contact; a default-deny egress policy from the gateway box turns that into a blocked connection and an alert.
  • Protect the proxy database like a secrets store, because it is one. Restrict it to localhost or a private subnet, back it up encrypted, and scope its credentials to the proxy alone.
  • Keep the master key off every config and harness. It exists in one environment on one ops host, with usage-based alerting, so a misconfigured sweep surfaces immediately.

None of this is novel discipline; it is the standard treatment for internet-facing infrastructure, applied to the box that holds all your model credentials.

FAQ

Does the gateway add latency to tight agent loops? A local proxy adds single-digit milliseconds per call against remote inference that costs hundreds. The retry and cooldown logic pays for itself the first time a tier rate-limits mid-sweep instead of killing a forty-minute run.

Why run a gateway at all instead of pointing harnesses at the provider endpoint directly? Direct wiring works, and our own guides use it for single-harness setups. The gateway earns its keep the moment you have more than one consumer, more than one engagement, or a rotation event, which in practice is the second week of any serious program.

What about the September LiteLLM vulnerabilities, the auth bypass? The authentication-bypass chain made exposed proxy admin panels a known target class. The answer is topology, mostly: the proxy binds to an internal interface, sits behind zero-trust access, and its master key never rides a config file. Run the gateway as private infrastructure, and the public-instance attack surface stops applying to you.

Is this within acceptable use for offensive testing? The gateway changes where requests flow, never what they authorize. Scope and authorization still come first, per the acceptable-use policy, with signed engagement documents behind every key alias you mint.


Setup verified against LiteLLM proxy config, virtual keys, and cost tracking documentation, checked November 13, 2026. Incident details from the Wiz analysis of the trojanized 1.107.0 release and our own attack breakdown. Tier pricing lives on the pricing page; keys are available at registration.