Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(guardrails): read-only root filesystem on hook pods (N8)
Andy Pavia424af21477cd
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 949683f89..b9aaeba07 100644--- a/host-context-controller/package-lock.json+++ b/host-context-controller/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-host-context-controller",- "version": "0.1.167",+ "version": "0.1.168","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.167",+ "version": "0.1.168","license": "SEE LICENSE IN LICENSE","dependencies": {"@clerum/image-policy": "file:../packages/image-policy",diff --git a/host-context-controller/package.json b/host-context-controller/package.jsonindex 44a681873..947dc9a61 100644--- a/host-context-controller/package.json+++ b/host-context-controller/package.json@@ -1,6 +1,6 @@{"name": "clerum-host-context-controller",- "version": "0.1.167",+ "version": "0.1.168","description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API","main": "dist/main.js","engines": {diff --git a/host-context-controller/src/llmHookReconciler.test.ts b/host-context-controller/src/llmHookReconciler.test.tsindex 5475dfcd7..29065df06 100644--- a/host-context-controller/src/llmHookReconciler.test.ts+++ b/host-context-controller/src/llmHookReconciler.test.ts@@ -740,6 +740,26 @@ describe('LlmHookReconciler', () => {})})+ it('hardens the hook pod: non-root, read-only root fs, dropped caps, no SA token (N8)', async () => {+ const a = makeHook({ name: 'a' })+ hooks.set('a', a)+ await reconciler.reconcile(a)++ const dep = (+ appsApi.createNamespacedDeployment.mock.calls.at(-1)![0] as { body: k8s.V1Deployment }+ ).body+ const podSpec = dep.spec!.template.spec!+ expect(podSpec.automountServiceAccountToken).toBe(false)+ const c = podSpec.containers[0]!+ expect(c.securityContext?.runAsNonRoot).toBe(true)+ expect(c.securityContext?.readOnlyRootFilesystem).toBe(true)+ expect(c.securityContext?.allowPrivilegeEscalation).toBe(false)+ expect(c.securityContext?.capabilities?.drop).toContain('ALL')+ // Writable /tmp scratch under the read-only root fs.+ expect(c.volumeMounts).toEqual([{ name: 'tmp', mountPath: '/tmp' }])+ expect(podSpec.volumes).toEqual([{ name: 'tmp', emptyDir: {} }])+ })+it('rejects an invalid (private-range) egress binding without exposing the workload', async () => {const a = makeHook({name: 'a',diff --git a/host-context-controller/src/llmHookReconciler.ts b/host-context-controller/src/llmHookReconciler.tsindex cff8f6a5c..3f55ca66b 100644--- a/host-context-controller/src/llmHookReconciler.ts+++ b/host-context-controller/src/llmHookReconciler.ts@@ -593,6 +593,9 @@ export class LlmHookReconciler {...(addCapabilities.length ? { add: addCapabilities } : {}),},seccompProfile: { type: 'RuntimeDefault' },+ // N8: the image filesystem is immutable to the running hook. Scratch space+ // is the ephemeral `/tmp` emptyDir mounted below — never the image layers.+ readOnlyRootFilesystem: true,}return {@@ -632,6 +635,8 @@ export class LlmHookReconciler {// envSecret injects the hook's OWN credentials (whole Secret)....(img.envSecret ? { envFrom: [{ secretRef: { name: img.envSecret } }] } : {}),securityContext: hardenedContainerSecurityContext,+ // Writable scratch under a read-only root fs (N8).+ volumeMounts: [{ name: 'tmp', mountPath: '/tmp' }],livenessProbe: {tcpSocket: { port: 'http' as unknown as IntOrString },initialDelaySeconds: 10,@@ -648,6 +653,7 @@ export class LlmHookReconciler {},},],+ volumes: [{ name: 'tmp', emptyDir: {} }],},},},