Skip to content

fix(litellm): seal the db-ready init container - #524

Merged
jdwillmsen merged 1 commit into
mainfrom
fix/litellm-db-ready-hardening
Oct 23, 2026
Merged

jdwillmsen merged 1 commit into
mainfrom
fix/litellm-db-ready-hardening

Conversation

@jdwillmsen

Copy link
Copy Markdown
Member

Why

Trivy flags the litellm Deployment's db-ready init container as root with a writable root filesystem (KSV-0012/0014/0020/0021).

Needs attention

helm-charts/litellm-helm/templates/deployment.yaml: the init container gets its own db.dbReadySecurityContext (uid 1001, read-only root, drop ALL) plus a /tmp emptyDir. The gateway container is deliberately unchanged: its image runs as root and prisma writes into the app dir, so its alerts get written dismissals instead.

Risk/rollout

Rolls the single platform-litellm pod in ai-sre (RollingUpdate, no end users; Holmes/relay retry). Confirm the pod is Ready after sync.

Verified

  • Image run with --read-only --user 1001 --cap-drop ALL: psql executes, fails only on connection
  • helm lint, kubeconform, server-side dry-run of the rendered Deployment, check-image-pins

The wait container only runs psql under the image's own uid 1001, so it
can run non-root with a read-only root filesystem and an emptyDir for
/tmp. It previously shared the gateway's context, which cannot take
either because that image runs as root and lets prisma write to its app
directory. The gateway context is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jdwlabs-review-bot

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Security Context Alignment

The change correctly applies a more restrictive security context to the db-ready init container, which addresses the Trivy vulnerability KSV-0012/0014/0020/0021. This ensures the init container runs with reduced privileges and a read-only root filesystem, improving overall pod security. The adjustment also properly mounts a temporary volume for the init container's needs.

securityContext:
  {{- toYaml .Values.db.dbReadySecurityContext | nindent 12 }}
Volume Mounting Consistency

The modification introduces a dedicated db-ready-tmp volume mount for the db-ready init container, replacing the previous conditional mounting based on readOnlyRootFilesystem. This ensures consistent handling of temporary files for the init container while maintaining separation from the main container's requirements.

volumeMounts:
  - name: db-ready-tmp
    mountPath: /tmp

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between df3cc12 and bc024ef.

📒 Files selected for processing: 2
  • helm-charts/litellm-helm/templates/deployment.yaml
  • helm-charts/litellm-helm/values.yaml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdwlabs-review-bot

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Security
Harden init container security

The db-ready init container should use a more restrictive security context tailored
for its specific needs, rather than inheriting the broader pod security context.

helm-charts/litellm-helm/templates/deployment.yaml [44-45]

           securityContext:
-            {{- toYaml .Values.securityContext | nindent 12 }}
+            {{- toYaml .Values.db.dbReadySecurityContext | nindent 12 }}
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that the db-ready init container should use a more restrictive security context tailored for its specific needs, which improves security posture. The change from .Values.securityContext to .Values.db.dbReadySecurityContext aligns with the PR's intent to apply a stricter security context to the init container.

High
General
Update volume mount reference

The volume mount for the tmp directory should be updated to use the new dedicated
volume name for consistency and clarity.

helm-charts/litellm-helm/templates/deployment.yaml [104-106]

-          {{ if .Values.securityContext.readOnlyRootFilesystem }}
           volumeMounts:
-            - name: tmp
+            - name: db-ready-tmp
               mountPath: /tmp
-          {{ end }}
Suggestion importance[1-10]: 8

__

Why: The suggestion accurately captures the need to update the volume mount reference to use the new dedicated volume name (db-ready-tmp) for consistency and clarity. This improves code maintainability and reduces confusion about which volume is being used.

Medium
Add dedicated tmp volume for init container

Add the db-ready-tmp volume to ensure the init container has access to a temporary
directory with appropriate size limits.

helm-charts/litellm-helm/templates/deployment.yaml [212-214]

         volumes:
           - name: db-ready-tmp
             emptyDir:
               sizeLimit: 16Mi
+          {{- if .Values.securityContext.readOnlyRootFilesystem }}
+          - name: tmp
+            emptyDir:
+              sizeLimit: 500Mi
+          {{- end }}
Suggestion importance[1-10]: 7

__

Why: The suggestion proposes adding the db-ready-tmp volume, but this is already present in the new hunk (lines 212-214). The improved code incorrectly adds a conditional block for the tmp volume that was already handled in the old hunk. While the intent is good, the implementation duplicates existing functionality and introduces unnecessary complexity.

Medium

@jdwillmsen
jdwillmsen merged commit 5f5724a into main Oct 23, 2026
22 checks passed
@jdwillmsen
jdwillmsen deleted the fix/litellm-db-ready-hardening branch October 23, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant