Skip to content

fix(backend): upgrade OS packages in runtime Dockerfiles (#7136) - #11188

Merged
kodjima33 merged 5 commits into
BasedHardware:mainfrom
aryanorastar:fix/7136-backend-os-cve-upgrade
Aug 13, 2026
Merged

kodjima33 merged 5 commits into
BasedHardware:mainfrom
aryanorastar:fix/7136-backend-os-cve-upgrade

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Adds apt-get -y upgrade --no-install-recommends to the final stage of Debian/Ubuntu-based backend/plugin runtime Dockerfiles so each service image applies available OS security updates on top of python:3.11-slim-forky (and the NLLB CUDA Ubuntu base). Fixes #7136 for the service-layer slice of OS CVEs.

Honest scope: #7157 already moved services to Forky / trimmed CUDA. Remaining scanner findings that live only in the shared custom base image (or NVIDIA NeMo/parakeet) still need a base-image rebuild / CUDA-image owner path — this PR cannot clear those in isolation. There is no in-repo Trivy/Grype gate to print a CVE delta here.

Product invariants affected

none

How it was verified

  • backend/.venv / nearby pytest: backend/tests/unit/test_backend_runtime_os_upgrade.py — 1 passed (asserts every listed final stage contains the upgrade).
  • Manual review of each Dockerfile final stage.
  • Not verified: full multi-image docker rebuild + external vulnerability scanner delta (no scanner credentials in this environment). Maintainers should rebuild/redeploy and re-run the scanner to confirm the active-vuln count drops for service layers.

Tests

  • New: backend/tests/unit/test_backend_runtime_os_upgrade.py — regression contract so the upgrade line cannot be dropped from final stages silently.

Failure class (fixes)

Failure-Class: none

Images touched

  • backend/Dockerfile, Dockerfile.desktop_backend, pusher, agent-proxy, agent_vm
  • modal (+ notifications + memory-maintenance jobs), diarizer, nllb_translation
  • plugins/Dockerfile
  • Out of scope: backend/parakeet/Dockerfile (NVIDIA NeMo base — different OS/toolchain; needs separate owner)

Review in cubic

…re#7136)

Patch Debian/Ubuntu packages in final image stages so service layers
pick up security updates beyond the shared slim-forky base.

Co-authored-by: Cursor <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 12 files

Confidence score: 4/5

  • In backend/agent_vm/Dockerfile, using plain apt-get upgrade can leave back security updates that require new dependencies, which increases the chance of shipping a base image with known vulnerabilities — switch to dist-upgrade/full-upgrade (or equivalent update strategy) to avoid held packages.
  • In backend/Dockerfile, --no-install-recommends on apt-get upgrade is ineffective and can create a false sense of hardening, making maintenance intent less clear — remove the flag there or apply it only to apt-get install steps.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/Dockerfile">

<violation number="1" location="backend/Dockerfile:49">
P3: `--no-install-recommends` is a no-op on `apt-get upgrade`: upgrade only updates already-installed packages and never pulls Recommended packages, so the flag does nothing here (it's meaningful only on the `install` command). It gives a misleading impression of minimalism and the regression test hard-codes the redundant string — drop it from the upgrade line and update the test assertion to match.</violation>
</file>

<file name="backend/agent_vm/Dockerfile">

<violation number="1" location="backend/agent_vm/Dockerfile:22">
P2: Consider `apt-get -y dist-upgrade --no-install-recommends` (or `full-upgrade`) instead of plain `upgrade`: plain `upgrade` holds back any package whose update pulls in a new dependency or conflict, so those security fixes silently never apply. That directly undercuts the CVE-remediation purpose of this PR. Note the change also needs the test contract string in `test_backend_runtime_os_upgrade.py` updated in tandem.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread backend/agent_vm/Dockerfile Outdated
ENV PATH="/opt/bun/bin:/opt/venv/bin:$PATH"

# Patch OS packages before Playwright's --with-deps apt installs (#7136).
RUN apt-get update && apt-get -y upgrade --no-install-recommends && rm -rf /var/lib/apt/lists/*

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Consider apt-get -y dist-upgrade --no-install-recommends (or full-upgrade) instead of plain upgrade: plain upgrade holds back any package whose update pulls in a new dependency or conflict, so those security fixes silently never apply. That directly undercuts the CVE-remediation purpose of this PR. Note the change also needs the test contract string in test_backend_runtime_os_upgrade.py updated in tandem.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/agent_vm/Dockerfile, line 22:

<comment>Consider `apt-get -y dist-upgrade --no-install-recommends` (or `full-upgrade`) instead of plain `upgrade`: plain `upgrade` holds back any package whose update pulls in a new dependency or conflict, so those security fixes silently never apply. That directly undercuts the CVE-remediation purpose of this PR. Note the change also needs the test contract string in `test_backend_runtime_os_upgrade.py` updated in tandem.</comment>

<file context>
@@ -18,6 +18,9 @@ WORKDIR /app
 ENV PATH="/opt/bun/bin:/opt/venv/bin:$PATH"
 
+# Patch OS packages before Playwright's --with-deps apt installs (#7136).
+RUN apt-get update && apt-get -y upgrade --no-install-recommends && rm -rf /var/lib/apt/lists/*
+
 COPY --from=bun /usr/local/bin/bun /opt/bun/bin/bun
</file context>

Comment thread backend/Dockerfile Outdated

RUN apt-get update && apt-get -y install ffmpeg curl libjemalloc2 && rm -rf /var/lib/apt/lists/*
# Patch OS packages in this layer before installing runtime deps (#7136).
RUN apt-get update && apt-get -y upgrade --no-install-recommends \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: --no-install-recommends is a no-op on apt-get upgrade: upgrade only updates already-installed packages and never pulls Recommended packages, so the flag does nothing here (it's meaningful only on the install command). It gives a misleading impression of minimalism and the regression test hard-codes the redundant string — drop it from the upgrade line and update the test assertion to match.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/Dockerfile, line 49:

<comment>`--no-install-recommends` is a no-op on `apt-get upgrade`: upgrade only updates already-installed packages and never pulls Recommended packages, so the flag does nothing here (it's meaningful only on the `install` command). It gives a misleading impression of minimalism and the regression test hard-codes the redundant string — drop it from the upgrade line and update the test assertion to match.</comment>

<file context>
@@ -45,7 +45,10 @@ WORKDIR /app
 
-RUN apt-get update && apt-get -y install ffmpeg curl libjemalloc2 && rm -rf /var/lib/apt/lists/*
+# Patch OS packages in this layer before installing runtime deps (#7136).
+RUN apt-get update && apt-get -y upgrade --no-install-recommends \
+    && apt-get -y install --no-install-recommends ffmpeg curl libjemalloc2 \
+    && rm -rf /var/lib/apt/lists/*
</file context>
Suggested change
RUN apt-get update && apt-get -y upgrade --no-install-recommends \
RUN apt-get update && apt-get -y upgrade \

@Git-on-my-level Git-on-my-level added backend Backend Task (python) workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior needs-tests PR introduces logic that should be covered by tests needs-maintainer-review Needs a human maintainer to sign off before merge labels Aug 7, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for taking on the backend OS-package CVE cleanup — this is the right area to harden, and the PR is honest about the remaining scanner/rebuild work.

I'm going to hold this for changes because the current contract and patch scope are not complete enough for this security/workflow-sensitive change:

  • The new test lists the runtime Dockerfiles covered by the contract, but there are still Debian/Python-slim plugin images in the repo, e.g. plugins/Dockerfile.datadog, plugins/composio/Dockerfile, plugins/hume-ai/Dockerfile, and plugins/omi-github-app/Dockerfile, that are not patched or explicitly excluded. Please either include the relevant shipped backend/plugin service images in the patch/test, or narrow the PR/test wording so maintainers can see exactly which images remain out of scope.
  • The test should validate the effective final-stage RUN instruction, not just the presence of a literal string in the final-stage text. Otherwise a comment or unrelated command can satisfy the guard while the shipped image no longer performs the upgrade.
  • Because this is intended to remediate OS CVEs, maintainers should still rebuild the affected images and verify the vulnerability-scanner delta before merge/redeploy.

No sign of anything malicious here; this just needs tighter coverage and verification before it is safe to merge as a CVE-remediation change.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

Use dist-upgrade for covered runtime images, include shipped Debian plugin
images, and assert the effective final-stage RUN instruction.

Failure-Class: none

Co-authored-by: CommandCodeBot <[email protected]>

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OS package upgrades across runtime Dockerfiles look right and are covered by a contract test — holding the merge because this rebuilds every prod runtime image and should land with a deploy window.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level / @kodjima33 follow-up: PR #11188 is fully CI-green at 7efb792. The requested plugin coverage, final-stage RUN contract, dist-upgrade, and no-install-recommends fixes are present; focused contract test passes, and @kodjima33 approved. The remaining block is the stale CHANGES_REQUESTED plus the maintainer decision on rebuild/scanner validation and deploy window. Please dismiss the stale CR or call out any remaining issue.

@Git-on-my-level Git-on-my-level removed the needs-tests PR introduces logic that should be covered by tests label Aug 8, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the follow-up. I rechecked the current head and the previous automation blockers look addressed: the shipped backend/plugin Debian/Ubuntu runtime Dockerfiles now use dist-upgrade, the extra plugin runtime images are included, and the regression test checks effective final-stage RUN instructions instead of just matching text.

I’m not formally approving this one because it is a workflow/security-sensitive runtime-image change and still needs human maintainer sign-off on the rebuild/scanner validation and deploy window. From the diff, though, I do not see a remaining code-level blocker in the PR itself; the important pre-merge step is for maintainers to rebuild the affected images and confirm the vulnerability-scanner delta before deploy.

I’m also clearing the stale needs-tests signal and dismissing my stale change-request review for the old head, since the test/coverage issues it called out have been addressed.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level
Git-on-my-level dismissed their stale review August 8, 2026 08:13

Stale automation change request from older head; current head adds plugin coverage, uses dist-upgrade, and validates effective final-stage RUN instructions. Remaining scanner/deploy validation is maintainer follow-up, not a code-change request.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level need human response — author-side is clear on #11188.

Current head 7efb79223b:

  • Your stale CR is dismissed; prior blockers addressed (plugin coverage, dist-upgrade, effective final-stage RUN contract)
  • @kodjima33 APPROVED (write-access)
  • CI green (18 success / 15 skipped)
  • MERGEABLE; reviewDecision APPROVED

What’s left is the human maintainer gate you already named: rebuild affected runtime images, confirm vulnerability-scanner delta, and pick a deploy window (this touches every prod runtime image).

Please either:

  1. Human / workflow-review APPROVE + schedule the rebuild/scanner pass, or
  2. Explicit hold with the remaining blocker

Happy to help with any follow-up once the deploy window is set. Failure-Class: none.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

apt-get upgrade in runtime Dockerfile final stages — approve only; this makes every prod image build non-deterministic, so Nik should land it deliberately.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin @Git-on-my-level need human response — deploy-window merge for #11188.

Author-clear on tip 9ad361b1b3 (refreshed onto current main; contract test 1 passed):

  • @kodjima33 APPROVED (approve-only; every prod runtime image rebuild / non-deterministic apt)
  • @Git-on-my-level dismissed CR; no remaining code-level blocker (plugin coverage, dist-upgrade, effective final-stage RUN contract)
  • CI was green/MERGEABLE CLEAN before refresh

Remaining gate is the one you already named: rebuild affected images → vulnerability-scanner delta → deliberate deploy window, then merge. Honest gaps unchanged: no in-repo Trivy/Grype delta here; parakeet/NeMo + shared custom base still out of scope.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Tip refresh landed: 3590528185 (merge/main on top of 7efb792 coverage tip). Contract test still 1 passed. Deploy-window merge call above still stands.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin need human response — deploy-window merge for #11188.

Author-clear on tip be649eb729f6 (refreshed onto current main):

  • @kodjima33 APPROVED (approve-only; every prod runtime image rebuild / non-deterministic apt)
  • @Git-on-my-level CR dismissed; no remaining code-level blocker (plugin coverage, dist-upgrade, effective final-stage RUN contract)
  • Contract test: 1 passed after main refresh
  • MERGEABLE · prior CI green · Failure-Class: none

Remaining gate is the one you already named: rebuild affected images → vulnerability-scanner delta → deliberate deploy window, then merge.

Honest gaps unchanged: no in-repo Trivy/Grype delta here; parakeet/NeMo + shared custom base still out of scope.

Please merge when the deploy window is set, or say if you want this held until a specific rebuild/scanner pass is scheduled.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin tip push to clear CI: 97d1bb5d2c16.

Backend unit suite red on be649eb was unrelated to this Dockerfile OS-upgrade diff:

  • Failed file: tests/unit/test_agent_vm_startup.py::test_startup_runs_the_published_python_runtime_with_instance_credentials
  • CalledProcessError exit 141 (SIGPIPE) running startup.sh under the fake-bin harness — classic parallel/pipe flake
  • This PR only touches runtime Dockerfiles + test_backend_runtime_os_upgrade.py (contract still 1 passed locally)
  • main backend unit suite is green on recent runs; author cannot gh run rerun (needs admin)

Retriggering CI. Deploy-window merge call still stands once green again.

@undivisible undivisible added human Human-authored pull request privacy-review Touches user-data persistence, permissions, or privacy-sensitive surfaces labels Aug 10, 2026
@Git-on-my-level Git-on-my-level removed the privacy-review Touches user-data persistence, permissions, or privacy-sensitive surfaces label Aug 10, 2026
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin deploy-window ping: current head is APPROVED, MERGEABLE/CLEAN, and checks are green. Remaining action is the runtime image rebuild/scanner comparison, then merge.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Applies OS security updates in the final stage of the Debian/Ubuntu runtime images (fixes #7136 for the service slice), with a contract test so the line can't be silently dropped. 5/5.

@kodjima33
kodjima33 merged commit 60ed1bc into BasedHardware:main Aug 13, 2026
38 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) human Human-authored pull request needs-maintainer-review Needs a human maintainer to sign off before merge workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remediate OS package vulnerabilities in backend service images - May 3, 2026

4 participants