Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Fixes #420: Harden Helm chart security defaults (#434)

Rohan Malhotra7c63b3a16f0a
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 942b09bce..55f243e24 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,6 +23,7 @@ jobs:
pull-requests: read
outputs:
packages: ${{ steps.packages.outputs.list }}
+ chart: ${{ steps.filter.outputs.chart }}
store: ${{ steps.filter.outputs.store }}
steps:
@@ -81,6 +82,12 @@ jobs:
- 'pnpm-workspace.yaml'
- 'tsconfig.base.json'
- '.github/workflows/ci.yml'
+ chart:
+ - 'charts/trueforge/**'
+ - 'Dockerfile'
+ - 'Dockerfile.dev'
+ - 'package.json'
+ - '.github/workflows/ci.yml'
- name: Build package matrix
id: packages
@@ -179,6 +186,36 @@ jobs:
- name: Test
run: pnpm "test:${{ matrix.package }}"
+ chart-checks:
+ name: Helm Chart
+ needs: detect-changes
+ if: needs.detect-changes.outputs.chart == 'true'
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+
+ steps:
+ - name: Check out repository code
+ uses: actions/checkout@v7
+
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v6
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v7
+ with:
+ node-version: '24'
+
+ - name: Install Helm
+ uses: azure/setup-helm@v4
+ with:
+ version: v3.16.4
+
+ - name: Build chart dependencies
+ run: pnpm chart:deps
+
+ - name: Lint chart
+ run: pnpm chart:lint
+
# Store contract suites when store paths change. Parallel with typecheck-and-build.
store-tests:
name: Store Tests
@@ -233,6 +270,7 @@ jobs:
- detect-changes
- typecheck-and-build
- package-checks
+ - chart-checks
- store-tests
runs-on: ubuntu-latest
timeout-minutes: 5
@@ -242,11 +280,13 @@ jobs:
DETECT_CHANGES: ${{ needs.detect-changes.result }}
TYPECHECK_AND_BUILD: ${{ needs.typecheck-and-build.result }}
PACKAGE_CHECKS: ${{ needs.package-checks.result }}
+ CHART_CHECKS: ${{ needs.chart-checks.result }}
STORE_TESTS: ${{ needs.store-tests.result }}
run: |
ok() { [ "$1" = success ] || [ "$1" = skipped ]; }
- echo "detect-changes=$DETECT_CHANGES typecheck-and-build=$TYPECHECK_AND_BUILD package-checks=$PACKAGE_CHECKS store-tests=$STORE_TESTS"
+ echo "detect-changes=$DETECT_CHANGES typecheck-and-build=$TYPECHECK_AND_BUILD package-checks=$PACKAGE_CHECKS chart-checks=$CHART_CHECKS store-tests=$STORE_TESTS"
[ "$DETECT_CHANGES" = success ] || exit 1
[ "$TYPECHECK_AND_BUILD" = success ] || exit 1
ok "$PACKAGE_CHECKS" || exit 1
+ ok "$CHART_CHECKS" || exit 1
ok "$STORE_TESTS" || exit 1
diff --git a/Dockerfile b/Dockerfile
index e1433ebe9..afb5dc4b2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -23,7 +23,11 @@ RUN test -n "$APP_VERSION" || (echo "APP_VERSION build-arg is required" >&2 && e
RUN npm install --omit=dev "@truefoundry/trueforge@${APP_VERSION}" \
&& npm cache clean --force
+RUN groupadd --gid 10001 trueforge \
+ && useradd --uid 10001 --gid trueforge --shell /usr/sbin/nologin trueforge
+
EXPOSE 8790
# Same entry as the from-source image / `pnpm start` (launch-only; dist is in the package).
+USER 10001:10001
CMD ["node", "node_modules/@truefoundry/trueforge/dist/main.js"]
diff --git a/Dockerfile.dev b/Dockerfile.dev
index 12744eb8b..6529a27b3 100644
--- a/Dockerfile.dev
+++ b/Dockerfile.dev
@@ -91,7 +91,11 @@ COPY --from=frontend-builder /app/packages/frontend/dist ./packages/trueforge/di
WORKDIR /app/packages/trueforge
+RUN groupadd --gid 10001 trueforge \
+ && useradd --uid 10001 --gid trueforge trueforge
+
EXPOSE 8790
# Launch-only (matches root `pnpm start` / `standalone:start`). Image already contains dist.
+USER 10001:10001
CMD ["node", "dist/main.js"]
diff --git a/charts/trueforge/README.md b/charts/trueforge/README.md
index 407a675ad..9d9a6fc6b 100644
--- a/charts/trueforge/README.md
+++ b/charts/trueforge/README.md
@@ -205,13 +205,19 @@ extraObjects:
| `server.port` | `8790` | Container port (`PORT`). |
| `autoscaling.enabled` | `false` | Enable a HorizontalPodAutoscaler. |
| `podDisruptionBudget.enabled` | `false` | Enable a PodDisruptionBudget (`minAvailable` defaults to `1`). |
-| `resources` | `{}` | Container resource requests/limits. |
+| `podSecurityContext` | non-root UID/GID `10001` | Pod-level restricted security defaults. |
+| `securityContext` | read-only root FS + drop all capabilities | Container-level restricted security defaults. |
+| `resources` | 100m/256Mi requests, 200m/512Mi limits | Container CPU, memory, and ephemeral-storage requests/limits. |
Also available (defaults inert): `strategy`, `priorityClassName`,
`topologySpreadConstraints`, `initContainers`, `extraContainers`,
`extraVolumes`, `extraVolumeMounts`, `service.annotations`, `service.labels`,
`startupProbe`.
+The server container mounts an `emptyDir` at `/tmp` by default so the image can
+run with `readOnlyRootFilesystem: true`. When set, `resources.limits.ephemeral-storage`
+also sets the `/tmp` `emptyDir.sizeLimit`.
+
## Production checklist
- **Enable `configs.oidc`** — leaving it off grants shared admin to anyone who can reach the server.
@@ -220,6 +226,6 @@ Also available (defaults inert): `strategy`, `priorityClassName`,
- Set `server.publicBaseUrl` to the real public origin before using MCP OAuth or OIDC.
- Prefer `valueFrom.secretKeyRef` for Postgres password, Redis URL, and OIDC client secret; do not commit secrets in values files.
- Prefer external managed Postgres/Redis over the bundled subcharts for production HA.
-- Set container `resources` (especially CPU requests) before enabling HPA.
+- Tune container `resources` (especially CPU requests) before enabling HPA.
- Default `tfy.jfrog.io` images and the Helm chart are anonymously pullable — set `imagePullSecrets` only if you override to a private registry.
- Enable `podDisruptionBudget` when running multiple replicas (defaults to `minAvailable: 1`; set exactly one of `minAvailable` or `maxUnavailable`).
diff --git a/charts/trueforge/templates/deployment.yaml b/charts/trueforge/templates/deployment.yaml
index 5d22cb753..14a86c767 100644
--- a/charts/trueforge/templates/deployment.yaml
+++ b/charts/trueforge/templates/deployment.yaml
@@ -75,17 +75,28 @@ spec:
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
- {{- with .Values.extraVolumeMounts }}
volumeMounts:
+ - name: tmp
+ mountPath: /tmp
+ {{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
- {{- end }}
+ {{- end }}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
- {{- with .Values.extraVolumes }}
+ {{- $resources := default dict .Values.resources }}
+ {{- $limits := default dict (index $resources "limits") }}
volumes:
+ - name: tmp
+ {{- with index $limits "ephemeral-storage" }}
+ emptyDir:
+ sizeLimit: {{ . | quote }}
+ {{- else }}
+ emptyDir: {}
+ {{- end }}
+ {{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
- {{- end }}
+ {{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
diff --git a/charts/trueforge/values.yaml b/charts/trueforge/values.yaml
index f1d9ea3b5..612ca0d4b 100644
--- a/charts/trueforge/values.yaml
+++ b/charts/trueforge/values.yaml
@@ -19,8 +19,19 @@ serviceAccount:
name: ""
podAnnotations: {}
podLabels: {}
-podSecurityContext: {}
-securityContext: {}
+podSecurityContext:
+ runAsNonRoot: true
+ runAsUser: 10001
+ runAsGroup: 10001
+ fsGroup: 10001
+ seccompProfile:
+ type: RuntimeDefault
+securityContext:
+ allowPrivilegeEscalation: false
+ readOnlyRootFilesystem: true
+ capabilities:
+ drop:
+ - ALL
# Optional PriorityClass for the server pods.
priorityClassName: ""
# Rolling update controls (omit keys you do not want to set).
@@ -174,7 +185,15 @@ extraContainers: []
# Extra volumes / mounts on the server container (e.g. CA bundles, projected tokens).
extraVolumes: []
extraVolumeMounts: []
-resources: {}
+resources:
+ requests:
+ cpu: 100m
+ memory: 256Mi
+ ephemeral-storage: 256Mi
+ limits:
+ cpu: 200m
+ memory: 512Mi
+ ephemeral-storage: 512Mi
# startupProbe runs until success before liveness/readiness; sized for migrate + Redis connect.
startupProbe:
httpGet: