Skip to content

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

TypeScript

fix(control-api): pin remote oauth secret-ref pairing and immutability in the CRD (R3-H8)

Diego Zacariasa835d7130e36
diff --git a/charts/clerum-crds/crds/mcpserver.yaml b/charts/clerum-crds/crds/mcpserver.yaml
index 5990aa76c..c141f992c 100644
--- a/charts/clerum-crds/crds/mcpserver.yaml
+++ b/charts/clerum-crds/crds/mcpserver.yaml
@@ -727,6 +727,14 @@ spec:
# no secret); confidential = both refs. Mixed pairing is rejected.
- rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'generic' || (has(self.oauth.clientIdRef) == has(self.oauth.clientSecretRef))"
message: "generic spec.oauth must set clientIdRef and clientSecretRef together (confidential) or neither (public)"
+ # REMOTE-SECRET-PAIRING: remote secret refs are BOTH-OR-NEITHER. Unlike
+ # generic, remote must NOT tie refs to clientMode: the three valid remote
+ # shapes are public (no refs), DCR-confidential (no refs — the secret lives
+ # in the encrypted dynamic_clients store, DEC-8), and pre-registered-
+ # confidential (both refs). So confidential is legal WITH or WITHOUT refs;
+ # the only invalid shape is exactly-one-ref (a half-declared secret source).
+ - rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'remote' || (has(self.oauth.clientIdRef) == has(self.oauth.clientSecretRef))"
+ message: "remote spec.oauth must set clientIdRef and clientSecretRef together or neither"
# SOURCE-VALUE-IMM: IMM-5 pins source PRESENCE; this pins the VALUE so a
# generic⇄remote flip in place is rejected even though both keep source set.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.source) || !has(self.oauth.source) || oldSelf.oauth.source == self.oauth.source"
@@ -750,6 +758,18 @@ spec:
# presence-equality conjunct short-circuits before any absent deref).
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.source) || oldSelf.oauth.source != 'generic' || !has(self.oauth.source) || self.oauth.source != 'generic' || ((has(oldSelf.oauth.clientIdRef) == has(self.oauth.clientIdRef)) && (has(oldSelf.oauth.clientSecretRef) == has(self.oauth.clientSecretRef)) && (!has(oldSelf.oauth.clientIdRef) || (oldSelf.oauth.clientIdRef.name == self.oauth.clientIdRef.name && oldSelf.oauth.clientIdRef.key == self.oauth.clientIdRef.key)) && (!has(oldSelf.oauth.clientSecretRef) || (oldSelf.oauth.clientSecretRef.name == self.oauth.clientSecretRef.name && oldSelf.oauth.clientSecretRef.key == self.oauth.clientSecretRef.key)))"
message: "generic spec.oauth clientIdRef/clientSecretRef (secret posture) are immutable; delete and recreate to change them"
+ # REMOTE-SECRET-IMM: pin PRESENCE AND VALUE of both remote refs across
+ # UPDATE. IMM-6 pins clientMode/endpoints/quirks but NOT the refs, so
+ # without this an update-RBAC actor could add refs (public/DCR-confidential
+ # → pre-registered, moving the secret source from the encrypted store to a
+ # K8s Secret), drop them (pre-registered → store), or repoint them at another
+ # Secret — silently changing which credential the token exchange uses. The
+ # remote analogue of GENERIC-SECRET-IMM. Double-source-VALUE-guarded so it
+ # only dereferences remote refs when BOTH revisions are remote; each value
+ # read is presence-guarded (a matching presence-equality conjunct
+ # short-circuits before any absent deref).
+ - rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.source) || oldSelf.oauth.source != 'remote' || !has(self.oauth.source) || self.oauth.source != 'remote' || ((has(oldSelf.oauth.clientIdRef) == has(self.oauth.clientIdRef)) && (has(oldSelf.oauth.clientSecretRef) == has(self.oauth.clientSecretRef)) && (!has(oldSelf.oauth.clientIdRef) || (oldSelf.oauth.clientIdRef.name == self.oauth.clientIdRef.name && oldSelf.oauth.clientIdRef.key == self.oauth.clientIdRef.key)) && (!has(oldSelf.oauth.clientSecretRef) || (oldSelf.oauth.clientSecretRef.name == self.oauth.clientSecretRef.name && oldSelf.oauth.clientSecretRef.key == self.oauth.clientSecretRef.key)))"
+ message: "remote spec.oauth clientIdRef/clientSecretRef (secret posture) are immutable; delete and recreate to change them"
status:
type: object
properties:
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index d50228298..cf9d31a5d 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.661",
+ "version": "0.1.662",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.661",
+ "version": "0.1.662",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",
diff --git a/control-api/package.json b/control-api/package.json
index 579090ab4..91727b853 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.661",
+ "version": "0.1.662",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/crd.mcpServerOauth.test.ts b/control-api/test/crd.mcpServerOauth.test.ts
index 01fa307e3..b649a44c2 100644
--- a/control-api/test/crd.mcpServerOauth.test.ts
+++ b/control-api/test/crd.mcpServerOauth.test.ts
@@ -419,6 +419,49 @@ describe('McpServer CRD — OAuth surface (U1)', () => {
)
})
+ // R3-H8: the remote carril was missing BOTH the intra-revision ref pairing and the
+ // cross-UPDATE ref immutability that generic already had. These are PRESENCE
+ // assertions on the rule strings (same contract as the rest of this file — no CEL
+ // evaluator is vendored, that limitation is R3-S8), NOT behavioral checks. Semantic
+ // verification (half-ref rejected on create / ref repoint rejected on update) is
+ // `kubectl --dry-run=server` against a live cluster, not here.
+ it('pairs remote client_id/secret refs both-or-neither (REMOTE-SECRET-PAIRING)', () => {
+ const rule = specRules.find(
+ r =>
+ r.rule.includes("self.oauth.source != 'remote'") &&
+ r.rule.includes('has(self.oauth.clientIdRef) == has(self.oauth.clientSecretRef)') &&
+ // Unique to REMOTE-SECRET-PAIRING (generic says "together (confidential) or
+ // neither (public)"), so this also excludes the generic pairing rule.
+ Boolean(r.message?.includes('together or neither'))
+ )
+ expect(rule, 'REMOTE-SECRET-PAIRING rule present').toBeDefined()
+ // both-or-neither ⇒ the rule must NOT tie refs to clientMode; requiring refs for
+ // confidential would break DCR-confidential (secret in the encrypted store, DEC-8).
+ expect(rule?.rule).not.toContain('clientMode')
+ })
+
+ it('pins the remote secret posture (ref pair) as immutable across UPDATE (REMOTE-SECRET-IMM)', () => {
+ // Analogue of GENERIC-SECRET-IMM for the remote carril: presence + value of both
+ // refs pinned across UPDATE. Anchor on the unique message.
+ const rule = specRules.find(r =>
+ r.message?.includes('remote spec.oauth clientIdRef/clientSecretRef')
+ )
+ expect(rule, 'REMOTE-SECRET-IMM rule present').toBeDefined()
+ // double-source-value-guarded on remote (both revisions)
+ expect(rule?.rule).toContain("oldSelf.oauth.source != 'remote'")
+ expect(rule?.rule).toContain("self.oauth.source != 'remote'")
+ // presence-equality of both refs
+ expect(rule?.rule).toContain('has(oldSelf.oauth.clientIdRef) == has(self.oauth.clientIdRef)')
+ expect(rule?.rule).toContain(
+ 'has(oldSelf.oauth.clientSecretRef) == has(self.oauth.clientSecretRef)'
+ )
+ // value-equality of the ref targets, presence-guarded
+ expect(rule?.rule).toContain('oldSelf.oauth.clientIdRef.name == self.oauth.clientIdRef.name')
+ expect(rule?.rule).toContain(
+ 'oldSelf.oauth.clientSecretRef.key == self.oauth.clientSecretRef.key'
+ )
+ })
+
it('reuses authorizationEndpoint/tokenEndpoint/resource/supportsRefresh for REMOTE and GENERIC', () => {
const props = specSchema.properties.oauth.properties
for (const p of ['authorizationEndpoint', 'tokenEndpoint', 'resource', 'supportsRefresh']) {