diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a60b85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/CloudronManifest.json b/CloudronManifest.json index c72a0fa..d078e7b 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "LiteLLM AI Gateway \u2014 OpenAI-compatible proxy with per-user API keys, usage tracking, rate limiting, and model routing. Packaged for Cloudron with SSO/OIDC and PostgreSQL.", "tagline": "AI gateway for cooperative inference", "version": "1.0.0", - "upstreamVersion": "1.103.2", + "upstreamVersion": "1.108.3", "healthCheckPath": "/health/readiness", "httpPort": 4000, "memoryLimit": 2147483648, diff --git a/Dockerfile b/Dockerfile index 3c0f448..1dfaff4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/berriai/litellm:v1.103.2 +FROM ghcr.io/berriai/litellm:v1.108.3 # v1.84.0 is the fix line for CVE-2026-35029 (auth bypass on # /config/update, fixed 1.83.0) and CVE-2026-59822 (MCP session auth diff --git a/README.md b/README.md index 7a701f1..c442f55 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A Cloudron app package for [LiteLLM](https://litellm.ai/), the open-source AI ga LiteLLM is the single gateway between members and the inference backends. It handles per-member API keys, usage metering, rate limiting (via budget caps), and model routing — all behind one OpenAI-compatible endpoint. -**Current base image:** LiteLLM **v1.103.2**, pinned to the exact tag (fix line for CVE-2026-35029 / CVE-2026-59822, CISA KEV-listed; also carries the streaming-usage fix for prompt_tokens_details). See [Updating LiteLLM](#updating-litellm). +**Current base image:** LiteLLM **v1.108.3**, pinned to the exact tag (upgraded from v1.103.2 in the 2026-11-08/09 maintenance window; minimum supported line remains v1.84.0, the fix line for CVE-2026-35029 / CVE-2026-59822, CISA KEV-listed). See [Updating LiteLLM](#updating-litellm). ## What this provides @@ -149,6 +149,19 @@ expect a 15–20 min maintenance window and **never panic-restart mid-migration* 1. **Pick a target version** from the [LiteLLM changelog](https://github.com/BerriAI/litellm/releases). Stay at or above v1.84.0 (the fix line for CVE-2026-35029 and CVE-2026-59822, the latter on CISA's KEV list). + **Re-validate the build patches against the target's real sources first** — the + scripts fail soft (a moved anchor prints a WARN and exits 0), so a silently + skipped patch ships. Ten patches are in the Dockerfile today; each must print + its `applied` line in the build log. The cheapest rehearsal is to unpack the + target wheel into a scratch tree and run the scripts against it (2026-11-09, + v1.108.3: all ten apply — the CORS anchor needs the 1.108.x fallback already + carried by `patch_expose_cost_headers.py`). Two gotchas in that harness: + `patch_audio_request_cost.py` finds its target by `import litellm`, which fails + outside a full install — point `LITELLM_COST_CALCULATOR` at the scratch + `cost_calculator.py` instead, or it exits with "could not locate"; and running + the scripts by hand leaves files owned by your user, which is fine in scratch + and never in the image. + 2. **Bump the pin** in `Dockerfile`: ```dockerfile diff --git a/__pycache__/patch_expose_cost_headers.cpython-314.pyc b/__pycache__/patch_expose_cost_headers.cpython-314.pyc deleted file mode 100644 index 7fac41f..0000000 Binary files a/__pycache__/patch_expose_cost_headers.cpython-314.pyc and /dev/null differ diff --git a/patch_expose_cost_headers.py b/patch_expose_cost_headers.py index 72f9bc1..e302ef9 100644 --- a/patch_expose_cost_headers.py +++ b/patch_expose_cost_headers.py @@ -4,7 +4,9 @@ MEMBER REQUEST (co-op/support#39, 2026-10-31). Browser JS calling the gateway fr another origin cannot read a response header unless the server names it in Access-Control-Expose-Headers. LiteLLM sets - expose_headers=LITELLM_UI_ALLOW_HEADERS + expose_headers=LITELLM_UI_ALLOW_HEADERS # through 1.103.x + expose_headers=[*LITELLM_UI_ALLOW_HEADERS, + *trace_response_expose_headers()] # from 1.108.0 which covers seven names (semantic-filter, guardrail, cache-key, ...) and none of the cost ones — so `x-litellm-response-cost*` reads as null in JS even though the @@ -62,6 +64,20 @@ NEW = ( + " ],\n" ) +# 1.108.0 refactored the middleware call (upstream added the trace-response +# header set to expose_headers). Same operation, new anchor; tried when the +# 1.103.2 shape is absent so the script works against either base image. +OLD_V1108 = ( + " expose_headers=[*LITELLM_UI_ALLOW_HEADERS, *trace_response_expose_headers()],\n" +) +NEW_V1108 = ( + " expose_headers=[\n" + " *LITELLM_UI_ALLOW_HEADERS,\n" + " *trace_response_expose_headers(),\n" + + "".join(f' "{h}",\n' for h in EXPOSED_HEADERS) + + " ],\n" +) + def main() -> int: # Glob rather than pin a Python version: the venv path moves when the base @@ -76,13 +92,22 @@ def main() -> int: if "x-litellm-response-cost-input" in src: print("expose-cost-headers: already applied") return 0 - found = src.count(OLD) - if found != 1: - print(f"WARN expose-cost-headers: expected exactly 1 CORS middleware call, found {found} — skipping") - return 0 - - target.write_text(src.replace(OLD, NEW)) - print(f"expose-cost-headers: appended {len(EXPOSED_HEADERS)} cost header names to expose_headers in {target}") + for old, new, shape in ((OLD, NEW, "1.103.x"), (OLD_V1108, NEW_V1108, "1.108.x")): + found = src.count(old) + if found == 1: + target.write_text(src.replace(old, new)) + print( + f"expose-cost-headers: appended {len(EXPOSED_HEADERS)} cost header names " + f"to expose_headers (anchor {shape}) in {target}" + ) + return 0 + if found > 1: + print(f"WARN expose-cost-headers: expected exactly 1 {shape} CORS middleware call, found {found} — skipping") + return 0 + print( + "WARN expose-cost-headers: no known expose_headers anchor found " + "(neither 1.103.x nor 1.108.x shape) — skipping" + ) return 0