Skip to content

fix(security): FastAPI 0.143.1 / Starlette 1.7.0 to clear last HIGH CVEs in lite image - #16

Closed
dvejsada wants to merge 2 commits into
claude/upstream-mistral-eu-cvesfrom
claude/fastapi-starlette-1x
Closed

dvejsada wants to merge 2 commits into
claude/upstream-mistral-eu-cvesfrom
claude/fastapi-starlette-1x

Conversation

@dvejsada

Copy link
Copy Markdown
Collaborator

Stacked on #15. Merge that first; GitHub will retarget this PR to main.

Why

With #15 in place, the lite image still had 3 fixable HIGH CVEs, all in Starlette. fastapi==0.115.12 held it at starlette<0.47:

CVE Fixed in
CVE-2025-62727 (FileResponse Range DoS) 0.49.1
CVE-2026-48818 (StaticFiles UNC SSRF, Windows) 1.1.0
CVE-2026-54283 (request.form() limits ignored for urlencoded) 1.3.1

Changes (requirements.txt and requirements.lite.txt)

  • fastapi 0.115.12 → 0.143.1
  • starlette → 1.7.0, now pinned explicitly because FastAPI ≥0.133 sets no upper bound. FastAPI's own CI runs against 1.7.0, and Starlette has no known vulnerabilities newer than 1.3.1.
  • mistralai 2.6.0 → 2.10.1. FastAPI ≥0.142 requires opentelemetry-api>=1.44. mistralai 2.6.0 blocked that through its opentelemetry-semantic-conventions<0.61 cap, which 2.10 removes. The breaking changes in mistralai 2.7–2.10.1 are in the evaluations, workflows and campaigns APIs, not OCR.

No app code changes:

  • Startup/shutdown: Starlette 1.0 removed on_startup/on_shutdown/on_event; the app already uses lifespan.
  • Decorators: Starlette 1.0 also removed its own app.middleware/app.exception_handler decorators, but the ones the app calls are FastAPI's own methods.
  • Middleware and uploads: BaseHTTPMiddleware, CORS and UploadFile work unchanged.
  • uvicorn and the test client: uvicorn 0.28.0 and httpx 0.28.1 (used by TestClient) need no change.

Behaviour change to be aware of

Since FastAPI 0.132, JSON requests without a JSON Content-Type header are rejected. LibreChat sends application/json (axios default), and uploads are multipart. Any other client that posts JSON without the header would now be rejected. FastAPI(strict_content_type=False) restores the old behaviour if needed.

Verification (Dockerfile.lite)

  • docker build -f Dockerfile.lite succeeds and pip check is clean.
  • Resolved versions: fastapi 0.143.1, starlette 1.7.0, mistralai 2.10.1, opentelemetry-api 1.45.1, uvicorn 0.28.0, httpx 0.28.1, anyio 4.15.1.
  • OPENAI_API_KEY=test_key python -m pytest: 385 passed, 1 skipped (same as before).
  • Trivy (--severity CRITICAL,HIGH --ignore-unfixed): 0.
  • The unit tests replace mistralai with a fake module, so I also ran the real mistralai 2.10.1 library against a mocked server. Mistral(server_url="https://api.eu.mistral.ai") with ocr.process sent both document_url and image_url requests to /v1/ocr, and .pages[].markdown read back correctly.

Not done: a live OCR call with a real key, and a build of the full Dockerfile (its extra packages don't constrain Starlette or OpenTelemetry).

🤖 Generated with Claude Code

Daniel Vejsada and others added 2 commits October 15, 2026 07:41
fastapi 0.115.12 capped starlette<0.47, holding the lite image on three
fixable HIGH CVEs: CVE-2025-62727 (fixed 0.49.1), CVE-2026-48818 (fixed
1.1.0) and CVE-2026-54283 (fixed 1.3.1). 0.133.0 is the oldest FastAPI
that drops the <1.0 cap ("Add support for Starlette 1.0.0+"). Since it no
longer bounds Starlette, pin it explicitly to 1.7.0 (no advisories after
1.3.1; the version FastAPI's own CI moved to).

Starlette 1.0 removed on_startup/on_shutdown, on_event, and the
Starlette-level route/middleware/exception_handler decorators. The app
already uses lifespan, and app.middleware/app.exception_handler are
FastAPI's own methods, so no code changes are needed. uvicorn 0.28.0 and
httpx 0.28.1 (TestClient) work unchanged; anyio resolves to 4.x as
Starlette 1.7 requires.

Verified in Dockerfile.lite: 385 passed / 1 skipped, and Trivy reports 0
fixable CRITICAL/HIGH.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0.133.0 was only the oldest FastAPI without the starlette<1.0 cap. It
shipped before Starlette 1.0 final and was never tested upstream against
the pinned starlette 1.7.0, which FastAPI 0.142.3+ CI runs against.
Nothing in 0.134-0.143 affects this app: the router-tree refactor
(0.137) only matters to code reading router.routes (none here), and the
native OpenTelemetry support (0.142) has exporter setup opt-in since 0.143.

fastapi>=0.142 requires opentelemetry-api>=1.44, which mistralai 2.6.0
blocked through its opentelemetry-semantic-conventions<0.61 cap. 2.10
drops that cap. The 2.7-2.10.1 breaking changes are limited to the
evaluations/workflows/campaigns APIs, not OCR.

Verified in Dockerfile.lite: pip check clean, 385 passed / 1 skipped,
Trivy 0 fixable CRITICAL/HIGH. Also ran a smoke test of the real
mistralai 2.10.1 OCR surface (Mistral(server_url=...),
ocr.process with document_url/image_url, response .pages[].markdown)
against a mocked transport, since the unit tests stub the SDK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant