Skip to content

Remediate vulnerabilities for backend services from OS - #7157

Merged
beastoin merged 12 commits into
mainfrom
task/remediate-vulnerabilities-for-backend-services-from-os
May 4, 2026
Merged

beastoin merged 12 commits into
mainfrom
task/remediate-vulnerabilities-for-backend-services-from-os

Conversation

@thainguyensunya

Copy link
Copy Markdown
Collaborator

Changes:

  • Update base OS from Debian 13 (Trixie) to 14 (Forky) for backend services to get rid of vulnerabilities
  • Install CUDA Runtime 13.2 Update 1 only for VAD and diarizer to reduce infected packages.
  • Upgrade speechbrain new version for VAD (required by pyannote-audio

@thainguyensunya
thainguyensunya requested a review from beastoin May 4, 2026 02:09
@thainguyensunya thainguyensunya self-assigned this May 4, 2026
@greptile-apps

greptile-apps Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR remediates OS-level vulnerabilities by migrating all backend service Dockerfiles to a custom Debian 14 (Forky) base image (gcr.io/based-hardware-dev/python:3.11-slim-forky), upgrades CUDA from 12.6 to 13.2 for the diarizer and modal services, and upgrades SpeechBrain to the 1.x line with the required API compatibility fix.

  • CUDA package OS mismatch (P1): Both backend/diarizer/Dockerfile and backend/modal/Dockerfile download cuda-repo-debian13-13-2-local (targeting Debian 13 / Trixie) but the base image is Debian 14 (Forky). The NVIDIA local repo .deb embeds Debian-version-specific dependency metadata; installing it on the wrong OS version can cause dpkg to fail or produce a silently broken CUDA environment at runtime.
  • Unbounded speechbrain version (P1): speechbrain>=1.0.0 has no upper bound, making the build non-reproducible against any future breaking release.

Confidence Score: 3/5

Not safe to merge as-is — the CUDA Debian 13 package on a Debian 14 base image will likely fail to build or produce a broken GPU runtime for the diarizer and modal services.

Two P1 findings: a hard OS/package mismatch for CUDA affecting two GPU-critical services, and an unbounded dependency version. Non-GPU Dockerfiles are clean, but the score is pulled below the P1 ceiling of 4 due to the CUDA mismatch appearing in two separate files on the critical inference path.

backend/diarizer/Dockerfile and backend/modal/Dockerfile need the CUDA repo package updated to a Debian 14 (Forky) compatible version; backend/modal/requirements.txt needs the speechbrain upper bound added.

Security Review

  • Shell injection risk (gcp_plugins.yml): ${{ github.event.inputs.environment }} is directly interpolated into a bash if condition. Only repository write-access holders can trigger this workflow, which limits exposure, but the correct pattern is to assign the expression to an environment variable first to prevent any metacharacter injection.

Important Files Changed

Filename Overview
backend/diarizer/Dockerfile Switches base image to Debian 14 (Forky) but installs a Debian 13 (Trixie) CUDA repo package — OS mismatch that can break the CUDA installation at build or runtime. Also unnecessarily keeps build-essential in the runtime stage.
backend/modal/Dockerfile Same CUDA Debian 13 package on Debian 14 base image mismatch as diarizer; also retains build-essential in runtime stage despite runtime-only intent.
backend/modal/requirements.txt Upgrades speechbrain from pinned 0.5.16 to unbounded >=1.0.0, making the build non-reproducible against future breaking releases.
.github/workflows/gcp_plugins.yml Converted from push-triggered to manual workflow_dispatch; adds environment validation and branch selection. Direct expression interpolation in shell is a minor injection risk.
backend/modal/speech_profile_modal.py Correctly adapts device argument to a string for SpeechBrain 1.x compatibility ('cuda:0' instead of torch.device).
backend/Dockerfile Straightforward base image swap to python:3.11-slim-forky; no CUDA involved, no issues found.
backend/agent-proxy/Dockerfile Single-line base image swap to Forky; no other changes.
backend/modal/Dockerfile.notifications_job Base image updated to Forky; adds git+gcc to builder stage. No CUDA, no issues.
backend/pusher/Dockerfile Base image swap to Forky only; clean change.
plugins/Dockerfile Base image swap to Forky only; clean change.
.github/workflows/gcp_models.yml Workflow name renamed from Cloud RUN to GKE; no functional changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    BASE["gcr.io/based-hardware-dev/python:3.11-slim-forky\n(Debian 14 / Forky)"]

    BASE --> B1["backend/Dockerfile\n✅ Clean swap"]
    BASE --> B2["backend/agent-proxy/Dockerfile\n✅ Clean swap"]
    BASE --> B3["backend/pusher/Dockerfile\n✅ Clean swap"]
    BASE --> B4["backend/modal/Dockerfile.notifications_job\n✅ Clean swap"]
    BASE --> B5["plugins/Dockerfile\n✅ Clean swap"]

    BASE --> D["backend/diarizer/Dockerfile\n⚠️ CUDA Debian13 pkg on Debian14 base"]
    BASE --> M["backend/modal/Dockerfile\n⚠️ CUDA Debian13 pkg on Debian14 base"]

    D --> CUDA["cuda-repo-debian13-13-2-local\n(targets Debian 13 / Trixie)\n❌ OS mismatch"]
    M --> CUDA

    M --> REQ["backend/modal/requirements.txt\n⚠️ speechbrain>=1.0.0 (unbounded)"]
    M --> PY["speech_profile_modal.py\n✅ device string fix for SpeechBrain 1.x"]
Loading

Reviews (1): Last reviewed commit: "Only install CUDA runtime instead of CUD..." | Re-trigger Greptile

Comment on lines +18 to +23
wget https://developer.download.nvidia.com/compute/cuda/13.2.1/local_installers/cuda-repo-debian13-13-2-local_13.2.1-595.58.03-1_amd64.deb && \
dpkg -i cuda-repo-debian13-13-2-local_13.2.1-595.58.03-1_amd64.deb && \
cp /var/cuda-repo-debian13-13-2-local/cuda-*-keyring.gpg /usr/share/keyrings/ && \
apt-get update && \
apt-get -y install cuda-toolkit-12-6 && \
rm -rf /var/lib/apt/lists/* cuda-repo-debian11-12-6-local_12.6.3-560.35.05-1_amd64.deb
apt-get -y install cuda-runtime-13-2 && \
rm -rf /var/lib/apt/lists/* cuda-repo-debian13-13-2-local_13.2.1-595.58.03-1_amd64.deb

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 CUDA repo targets Debian 13, but base image is Debian 14

The downloaded package is cuda-repo-debian13-13-2-local which targets Debian 13 (Trixie), but the base image python:3.11-slim-forky is Debian 14 (Forky). The NVIDIA local installer .deb embeds OS-version-specific metadata and library dependency hints; installing a Debian 13 package on Debian 14 can cause dpkg to reject the package, or result in a silently broken CUDA installation where CUDA libraries are missing at runtime. The same mismatch is present in backend/modal/Dockerfile line 24.

Comment thread backend/modal/requirements.txt Resolved
Comment thread .github/workflows/gcp_plugins.yml Resolved

# Install CUDA Toolkit 12.6 Update 3
# Install CUDA Runtime 13.2 Update 1 only; the pod runs inference and does not need build tools like nvcc.
RUN apt-get update && apt-get -y install build-essential ffmpeg curl unzip wget && \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 build-essential installed in runtime image contradicts the stated goal

The inline comment says "the pod runs inference and does not need build tools like nvcc", yet build-essential (which includes gcc, g++, make, etc.) is still installed in the runtime stage. This adds unnecessary packages that increase the attack surface the PR is trying to reduce. The same pattern exists in backend/modal/Dockerfile line 23.

@beastoin
beastoin merged commit 00377ac into main May 4, 2026
2 checks passed
@beastoin
beastoin deleted the task/remediate-vulnerabilities-for-backend-services-from-os branch May 4, 2026 02:25
@beastoin

beastoin commented May 4, 2026

Copy link
Copy Markdown
Collaborator

lgtm

@thainguyensunya

Copy link
Copy Markdown
Collaborator Author

This PR is to remediate vulnerabilities in issue #7136

mdmohsin7 added a commit that referenced this pull request May 5, 2026
Third of four service-sync PRs propagating backend's #7126 + #7127 +
#7146 + #7149 bumps to the sub-services that don't auto-inherit
`backend/requirements.txt`. Follows #7173 (agent-proxy) and #7177
(pusher).

## What this PR does

8 atomic commits, 10 pins lifted to match backend. Diarizer doesn't use
langchain so no major-cascade work — much smaller than pusher.

| # | Commit | Package(s) | Was → Now |
|---|---|---|---|
| 1 | aiohttp | aiohttp | 3.13.2 → 3.13.4 |
| 2 | python-multipart | python-multipart | 0.0.21 → 0.0.26 |
| 3 | requests | requests | 2.32.5 → ~=2.33.0 |
| 4 | filelock | filelock | 3.20.1 → 3.20.3 |
| 5 | mako | mako | 1.3.10 → 1.3.11 |
| 6 | pillow | pillow | 12.0.0 → 12.2.0 |
| 7 | fastapi+starlette | fastapi / starlette | 0.112.0 / 0.37.2 →
0.121.0 / 0.49.1 |
| 8 | pydantic+pydantic-core | pydantic / pydantic-core | 2.8.2 / 2.20.1
→ 2.11.10 / 2.33.2 |

Diarizer was already mostly aligned with backend after #7157 (the recent
base-image bump). The other 47 shared packages either match exactly or
are AHEAD of backend (e.g. `aiohappyeyeballs 2.6.1 > 2.5.0`, `anyio
4.12.0 > 4.4.0`, `numpy 2.4.0 > 1.26.4`, `protobuf 6.33.2 > 5.29.6`) —
those were left untouched. Never downgrade.

## CVEs closed (~14)

- **From #7126 / #7146 (aiohttp 3.13.x rollup):** 4× MEDIUM
CVE-2026-22815 / -34515 / -34516 / -34525 + 6× LOW (CVE-2026-34520 et
al.)
- **From #7127 + #7146 (fastapi/starlette):** HIGH 7.5 CVE-2024-47874,
HIGH 7.5 CVE-2025-62727, MEDIUM 5.3 CVE-2025-54121
- **From #7146 (Python MEDIUMs):** MEDIUM CVE-2025-68146 +
CVE-2026-22701 (filelock), MEDIUM 7.5 CVE-2026-41205 (mako), MEDIUM 5.3
CVE-2026-40347 (python-multipart), MEDIUM 5.5 CVE-2026-25645 (requests)
- **From #7127 (pillow cascade):** HIGH 7.5 CVE-2026-25990, HIGH 7.5
CVE-2026-40192

## Test plan

End-to-end smoke test in a Python 3.12 venv (local platform: ARM64;
diarizer's runtime target is amd64+CUDA):

- [x] `pip install` of all bumped packages clean; `pip check` reports no
broken deps
- [x] All 12 bumped packages resolve to expected pins;
`typing_extensions==4.15.0` auto-resolved
- [x] **Full `uvicorn main:app` boot** with `diarization` and
`embedding` modules stubbed (pyannote-audio's transitive
`torchcodec==0.7.0` is amd64-only — pre-existing platform pin, not
affected by these bumps):
- `Started server process` + `Application startup complete` — zero
errors, zero warnings
  - `GET /health` → 200 `{"status":"healthy"}`
- `POST /v1/diarization` with multipart file upload → 200 (exercises
`starlette 0.49.1` + `python-multipart 0.0.26` upload hot path under
`fastapi 0.121`)
  - `POST /v2/embedding` with multipart upload → 200
- `GET /openapi.json` → 200, schema is OpenAPI 3.1.0 (fastapi 0.121's
output)
  - All four endpoints registered with proper signatures
  - Clean shutdown
- [x] `pydantic 2.11.10` + `fastapi 0.121.0` + `starlette 0.49.1`
interop verified (built diarizer-shape app, instantiated `BaseModel`,
validation round-trip)
- [ ] Confirm post-deploy Artifact Registry rescan shows the targeted
CVEs cleared on the diarizer GKE image

### On `pydantic 2.11` + `torch` / `lightning` / `pyannote-audio`
interop

Can't fully exercise locally because `pyannote-audio 4.0.3` requires
`torchcodec==0.7.0` which is amd64-only (only `0.0.0.dev0` / `0.11.x`
are available on Python 3.12 + aarch64). This is a pre-existing platform
constraint, not affected by my bumps.

The combination is implicitly proven by backend's #7149
(`pydantic==2.11.10` running in prod since this morning) and
`backend/modal` (which combines `torch` + `lightning` + `pyannote-audio`
+ `pydantic 2.11` — already inherits backend's `requirements.txt` via
`-r ../requirements.txt` and is running in prod on modal today).

## Follow-ups in this series

- plugins (`plugins/`) — 110 shared packages, biggest fan-out

vad (`backend/modal/`) and notifications-job already auto-inherit
`backend/requirements.txt` via `-r ../requirements.txt`.
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