Repository navigation
Add CEL validation rule for RemoteMCPServer with CA Cert and AllowedNamespaces - #1988
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes cross-namespace RemoteMCPServer usage by (1) deleting spec.allowedNamespaces from the RemoteMCPServer API/CRD and (2) making the reconciler reject any cross-namespace RemoteMCPServer reference, to prevent incorrect/dangling TLS CA Secret mounts due to Secrets being namespace-scoped at pod volume resolution time.
Changes:
- Removed
RemoteMCPServerSpec.AllowedNamespacesfrom the Go API types and regenerated generated code/CRDs. - Updated agent reconcile-time validation to deny all cross-namespace
RemoteMCPServerreferences with a clear error. - Updated/added tests, including a translator-level characterization test documenting the dangling Secret mount behavior in cross-namespace scenarios.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| helm/kagent-crds/templates/kagent.dev_remotemcpservers.yaml | Removes spec.allowedNamespaces from the Helm-packaged RemoteMCPServer CRD schema. |
| go/core/internal/controller/translator/agent/remotemcpserver_tls_test.go | Adds a translator characterization test showing why cross-namespace RMS TLS CA mounts are unsafe. |
| go/core/internal/controller/reconciler/reconciler.go | Makes validateMcpServerReference reject cross-namespace RemoteMCPServer references unconditionally. |
| go/core/internal/controller/reconciler/reconciler_test.go | Updates cross-namespace RMS validation tests to expect denial. |
| go/api/v1alpha2/zz_generated.deepcopy.go | Regenerates deepcopy code to reflect removal of AllowedNamespaces from RemoteMCPServerSpec. |
| go/api/v1alpha2/remotemcpserver_types.go | Removes RemoteMCPServerSpec.AllowedNamespaces from the public API type. |
| go/api/config/crd/bases/kagent.dev_remotemcpservers.yaml | Removes spec.allowedNamespaces from the generated RemoteMCPServer CRD schema. |
Files not reviewed (1)
- go/api/v1alpha2/zz_generated.deepcopy.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
EItanya
left a comment
There was a problem hiding this comment.
We can't do this, it's a breaking API change
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
ed3c5f1 to
53213d4
Compare
Makes sense. I have reworked this to be a CEL validation rule instead so you cannot create a RemoteMCPServer with both |
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
…ross-ns-remotemcpserver Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Changed approach to no longer break the API. I am instead adding CEL rules to reject when spec.allowedNamespaces and spec.tls.caCertSecretRef are both set.
kagent 0.9.8 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre><!-- Release notes generated using configuration in .github/release.yml at v0.9.8 --> ## What's Changed ### Features * feat(bedrock): add prompt caching via CachePoint markers by @skashmeri in kagent-dev/kagent#1940 ### Bug Fixes * fix(bedrock): stream events incrementally instead of buffering by @mesutoezdil in kagent-dev/kagent#1989 * fix: remove optional label from agent description field by @tuguldur-dev in kagent-dev/kagent#2013 * fix(adk): write materialized secret files with 0600 permissions by @mesutoezdil in kagent-dev/kagent#2011 * fix: enable vertical scroll in onboarding wizard by @tuguldur-dev in kagent-dev/kagent#2020 * fix: render ModelConfig TLS in Helm chart by @andreivince in kagent-dev/kagent#1999 * fix(translator): apply temperature/maxTokens/topP for AzureOpenAI by @mesutoezdil in kagent-dev/kagent#1972 ### Other Changes * Add CEL validation rule for RemoteMCPServer with CA Cert and AllowedNamespaces by @iplay88keys in kagent-dev/kagent#1988 * Corrected spelling error in MemorySection.tsx by @krumware in kagent-dev/kagent#2008 * fix the issue where sandbox agents couldn't be added as tools by @peterj in kagent-dev/kagent#2000 * [BUG] 0.9.7 UI: new chat hangs on "Thinking…" by @peterj in kagent-dev/kagent#2010 * chore(deps): bump the npm-minor-patch group across 1 directory with 35 updates by @dependabot[bot] in kagent-dev/kagent#2016 * replace the outdated diagram with a gif from the website by @peterj in kagent-dev/kagent#2022 * chore(deps): bump the go-minor-patch group across 1 directory with 29 updates by @dependabot[bot] in kagent-dev/kagent#2015 ## New Contributors * @skashmeri made their first contribution in kagent-dev/kagent#1940 * @krumware made their first contribution in kagent-dev/kagent#2008 * @tuguldur-dev made their first contribution in kagent-dev/kagent#2013 **Full Changelog**: https://github.com/kagent-dev/kagent/compare/v0.9.7...v0.9.8</pre> <p>View the full release notes at <a href="https://github.com/kagent-dev/kagent/releases/tag/v0.9.8">https://github.com/kagent-dev/kagent/releases/tag/v0.9.8</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!11701
Description
Adds a CEL admission rule on
RemoteMCPServerthat rejects setting bothspec.allowedNamespacesandspec.tls.caCertSecretRef. ARemoteMCPServerthat pins a CA Secret must be same-namespace-only; one that allows cross-namespace references must not pin a CA Secret.This closes a silent footgun in the cross-namespace + TLS combination without changing any working behavior: the
AllowedNamespacesfield stays, the reconciler is unchanged, and non-CA cross-namespace sharing keeps working exactly as before.Why
When an agent consumes a
RemoteMCPServerthat pins a CA bundle, the translator mounts that Secret onto the agent's pod by bare name (addTLSConfiguration). ASecretVolumeSourcehas no namespace field — Kubernetes always resolves it in the pod's own namespace, not theRemoteMCPServer's. So if the RMS is referenced cross-namespace, the CA mount either:Meanwhile the controller validates and hashes the Secret in the
RemoteMCPServer's namespace, so it reportsAccepted=truewhile the pod mount looks elsewhere. The cert reference itself is structurally same-namespace (caCertSecretRefis a bare name with no namespace field, resolved in the owner's namespace by design); the only thing that broke co-location was opening the RMS object up cross-namespace viaallowedNamespaces. Making the two mutually exclusive removes the unsound combination at admission time rather than letting it surface as a runtime mount failure on the consuming agent.Validation rule
Spec-level
XValidationonRemoteMCPServerSpec:The rule only rejects the genuinely-hazardous case — a CA Secret combined with an
allowedNamespacesthat actually permits other namespaces (from: Allorfrom: Selector).from: Same(or omitted/empty, which defaults to same-namespace) is always allowed alongside a CA Secret, since it carries no cross-namespace mount hazard.Regenerated
kagent.dev_remotemcpservers.yamland synced the helm CRD copy underhelm/kagent-crds/templates/.Tests
Added cases to the existing envtest CEL suite (
tlsconfig_cel_test.go), exercised against a real kube-apiserver:allowedNamespacesfrom: All+caCertSecretRef→ rejected.allowedNamespacesfrom: Selector+caCertSecretRef→ rejected.allowedNamespacesfrom: Same+caCertSecretRef→ accepted (same-namespace, no hazard).allowedNamespacesfrom: All, no TLS → accepted (cross-namespace sharing still works).caCertSecretRef, noallowedNamespaces→ accepted (same-namespace CA pinning still works).Compatibility
Not a breaking API change — no field is removed and no working configuration changes behavior. The only new effect is at admission: a manifest that combines a CA Secret with a cross-namespace-permitting
allowedNamespaces(from: All/from: Selector) is now rejected on create/update. That combination was already non-functional (dangling or wrong-CA mount), so this turns a silent runtime failure into an explicit, actionable admission error. Same-namespace configurations (from: Sameor omitted) are unaffected, and objects already stored are not re-validated until their next write.