Skip to content

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

TypeScript

fix(control-api): reject "." and ".." Secret keys, completing the key guard

Alfredo Lopeze9e60871208c
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 72203d2f3..b3f3e6369 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.394",
+ "version": "0.1.395",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.394",
+ "version": "0.1.395",
"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 f30245741..b422b1f3f 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.394",
+ "version": "0.1.395",
"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 723c22da4..72432c6c5 100644
--- a/control-api/src/routes/admin/secrets.ts
+++ b/control-api/src/routes/admin/secrets.ts
@@ -388,12 +388,13 @@ export function createAdminSecretsRouter(gateway: K8sGateway): Router {
return
}
for (const [key, val] of Object.entries(data)) {
- // A Kubernetes Secret data key must be [-._a-zA-Z0-9]+. Reject an
- // invalid key with a clear 400 up front instead of letting the apiserver
- // refuse the patch as an opaque 500 the operator can't act on.
- if (!/^[A-Za-z0-9_.-]+$/.test(key)) {
+ // A Kubernetes Secret data key must match [-._a-zA-Z0-9]+ AND is
+ // additionally rejected by the apiserver when it is "." / ".." or longer
+ // than 253 chars. Validate all three up front so an invalid key returns a
+ // clear 400 instead of the opaque apiserver 500 this guard exists to avoid.
+ if (!/^[A-Za-z0-9_.-]+$/.test(key) || key === '.' || key === '..' || key.length > 253) {
res.status(400).json({
- error: `data key "${key}" is not a valid Secret key (only letters, digits, '-', '_', '.')`,
+ error: `data key "${key}" is not a valid Secret key (only [-._a-zA-Z0-9], not "." or "..", max 253 chars)`,
})
return
}
diff --git a/control-api/test/routes.mcpSecrets.test.ts b/control-api/test/routes.mcpSecrets.test.ts
index 9d6d311b3..243c975eb 100644
--- a/control-api/test/routes.mcpSecrets.test.ts
+++ b/control-api/test/routes.mcpSecrets.test.ts
@@ -616,6 +616,23 @@ describe('PUT /admin/mcp-secrets/:name (credential rotation, issue #223)', () =>
expect(gateway.mergeSecret).not.toHaveBeenCalled()
})
+ it('rejects the reserved keys "." and ".." with a 400 (charset-valid but apiserver-rejected)', async () => {
+ const gateway = createGateway()
+ const app = makeApp(gateway)
+
+ // "." and ".." pass the [-._a-zA-Z0-9]+ charset but Kubernetes rejects them
+ // as Secret data keys — without the explicit exclusion they'd reach the
+ // apiserver and come back as the opaque 500 this guard exists to prevent.
+ for (const badKey of ['.', '..']) {
+ const res = await request(app)
+ .put('/admin/mcp-secrets/linear-credentials')
+ .send({ data: { [badKey]: 'value' } })
+ .expect(400)
+ expect(res.body.error).toContain('not a valid Secret key')
+ }
+ expect(gateway.mergeSecret).not.toHaveBeenCalled()
+ })
+
// ── Gateway failure ──────────────────────────────────────────────────────
it('still returns 200 when listing connectors fails AFTER a successful merge (M1)', async () => {