Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-api): reserve the platform Secret name on the merge path too

Jose Ramirez50b7f1a2e4ea
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index a8d653d2c..01e116cbc 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.411",
+ "version": "0.1.412",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.411",
+ "version": "0.1.412",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-api/package.json b/control-api/package.json
index b614221db..49ce6b05a 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.411",
+ "version": "0.1.412",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/routes/admin/secrets.ts b/control-api/src/routes/admin/secrets.ts
index cf9529bd5..0ec553766 100644
--- a/control-api/src/routes/admin/secrets.ts
+++ b/control-api/src/routes/admin/secrets.ts
@@ -411,6 +411,16 @@ export function createAdminSecretsRouter(gateway: K8sGateway): Router {
})
return
}
+ // The reserved name is guarded on POST and DELETE below; without it here the merge
+ // path was the way through. The recipe-secret label check further down does NOT cover
+ // it — the platform Secret carries `clerum.io/managed-by`, not the recipe label, so it
+ // passes that gate — and `mergeSecret` replaces any key it is given, including
+ // `.dockerconfigjson`. That is every private image pull in this namespace, broken by
+ // a route whose whole job is to refuse this name.
+ if (isPlatformManagedSecretName(name)) {
+ res.status(400).json({ error: PLATFORM_MANAGED_SECRET_ERROR })
+ return
+ }
if (!data || typeof data !== 'object' || Object.keys(data).length === 0) {
res
.status(400)
diff --git a/control-api/test/routes.secrets.platformPullSecretName.test.ts b/control-api/test/routes.secrets.platformPullSecretName.test.ts
index b26c1c23c..f296ace9f 100644
--- a/control-api/test/routes.secrets.platformPullSecretName.test.ts
+++ b/control-api/test/routes.secrets.platformPullSecretName.test.ts
@@ -81,6 +81,54 @@ describe('platform-managed Secret name is reserved', () => {
expect(gateway.deleteSecret).not.toHaveBeenCalled()
})
+ // The gap this file's own header missed. POST and DELETE were reserved; the MERGE path
+ // was not, and it is the one that can quietly replace `.dockerconfigjson` with anything —
+ // every private image pull in `mcp-server`, broken through a route whose stated job is to
+ // refuse this name. The recipe-secret label check inside the handler does NOT cover it:
+ // the platform Secret carries `clerum.io/managed-by`, not the recipe label, so it passes.
+ it('PUT /admin/mcp-secrets/:name refuses the reserved name and merges nothing', async () => {
+ const gateway = createGateway()
+ // Shaped like the real platform Secret: present, and NOT a recipe secret — the exact
+ // state in which every other guard in the handler waves it through.
+ gateway.getSecret = vi.fn(async () => ({
+ metadata: {
+ name: EVENFIRE_REGISTRY_PULL_SECRET_NAME,
+ namespace: 'mcp-server',
+ labels: { 'clerum.io/managed-by': 'control-api' },
+ },
+ type: 'kubernetes.io/dockerconfigjson',
+ data: { '.dockerconfigjson': 'e30=' },
+ })) as never
+ const mergeSecret = vi.fn(async (body: unknown) => body)
+ ;(gateway as unknown as { mergeSecret: unknown }).mergeSecret = mergeSecret
+
+ const res = await request(makeApp(gateway))
+ .put(`/admin/mcp-secrets/${EVENFIRE_REGISTRY_PULL_SECRET_NAME}`)
+ .send({ data: { '.dockerconfigjson': 'bm90LWEtY3JlZGVudGlhbA==' } })
+ .expect(400)
+
+ expect(res.body.error).toMatch(/platform-managed/)
+ expect(mergeSecret).not.toHaveBeenCalled()
+ })
+
+ it('still merges into an ordinary connector Secret whose name merely resembles it', async () => {
+ const gateway = createGateway()
+ gateway.getSecret = vi.fn(async () => ({
+ metadata: { name: `${EVENFIRE_REGISTRY_PULL_SECRET_NAME}-backup`, namespace: 'mcp-server' },
+ type: 'Opaque',
+ data: {},
+ })) as never
+ const mergeSecret = vi.fn(async (body: unknown) => body)
+ ;(gateway as unknown as { mergeSecret: unknown }).mergeSecret = mergeSecret
+
+ await request(makeApp(gateway))
+ .put(`/admin/mcp-secrets/${EVENFIRE_REGISTRY_PULL_SECRET_NAME}-backup`)
+ .send({ data: { token: 'fine' } })
+ .expect(200)
+
+ expect(mergeSecret).toHaveBeenCalled()
+ })
+
it('still deletes an ordinary connector Secret whose name merely resembles it', async () => {
const gateway = createGateway()