Skip to content

Fix vMCP validator for canonical grants, pin key rotation - #7048

Merged
jhrozek merged 4 commits into
mainfrom
delegate-client-extracts
Nov 4, 2026
Merged

jhrozek merged 4 commits into
mainfrom
delegate-client-extracts

Conversation

@jhrozek

@jhrozek jhrozek commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

A vMCP config that declares its delegate clients, or its JWT bearer issuer policies, only under inbound_grants was rejected with "requires at least one upstream". The CRD admits that shape and the runtime serves it, but the vMCP validator counted only the deprecated top-level delegate_clients list and read the trusted issuers before the canonical JWT bearer policy had been applied to them. The operator hit it too: its checks accept inboundGrants with no upstream providers, then the reconciler ran this validator and marked the VirtualMCPServer Failed.

The other commits are small follow-ups from the delegate client key rotation work. A broker that rotates its private_key_jwt key needs a window where the server accepts both the old and the new key. The runtime already supports that, but nothing pinned it and nothing said how to do it.

  • Run NormalizeInboundGrants once in the vMCP validator and judge the same effective view the runtime uses. Four rows go into the existing TestValidateAuthServerIntegration table: canonical delegate client accepted, canonical JWT bearer policy accepted, token exchange with no clients still rejected, legacy plus canonical delegate clients rejected.
  • Name the one-line fix in the trust-mode error for a private_key_jwt delegate without a token_exchange block, for users upgrading from earlier releases.
  • Correct the keySigningAlgorithm doc comment. An RSA key without alg does not imply RS256; RS256 is only the default.
  • Extend the existing key rotation test to walk old key, then old plus new, then new, and document the three-step procedure in the token exchange architecture doc.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test): ran the full suite on the final commits. Everything passes except three Docker-dependent tests in pkg/container/docker: TestEgressSquidIPv6ConfigValidatesAgainstRealSquid, and TestEnvoyBootstrap_ValidatesAgainstRealEnvoy with its two subtests. They start real squid and envoy containers and fail here with "Cannot connect to the Docker daemon" because no daemon was running on my machine. This PR does not touch that package. I also ran go test -race on the three packages it changes (pkg/vmcp/config, pkg/authserver, pkg/authserver/server/registration), and they pass.
  • E2E tests (task test-e2e): not run.
  • Linting (task lint-fix): 0 issues, and it left the tree unchanged. go vet on the three changed packages is also clean.
  • Manual testing: none.

Checks on the new tests:

  • The two accepting rows fail against main's validator. I restored main's version of validator.go, saw exactly those two rows fail, then put the change back. The two rejecting rows were added after that check and I did not run them against main's validator.
  • The rotation test fails if the old key's expectation in the overlap stage is flipped.

Changes

File Change
pkg/vmcp/config/validator.go Judge delegate clients and JWT bearer from the normalized inbound grants
pkg/vmcp/config/validator_test.go Four rows in TestValidateAuthServerIntegration
pkg/authserver/config.go Trust-mode error names the one-line fix
pkg/authserver/server/registration/configured_client.go Doc comment only
pkg/authserver/configured_client_runner_integration_test.go Rotation test now covers the overlap stage
docs/arch/17-token-exchange-delegation.md Key rotation procedure

Does this introduce a user-facing change?

Yes.

  • vMCP with only canonical inbound grants. Before: a VirtualMCPServer, or a RunConfig passed to the vMCP validator, with no upstream providers and delegate clients or a JWT bearer policy only under inbound_grants failed with "auth server requires at least one upstream unless delegate clients or a trusted issuer with JWT bearer grant is configured". The VirtualMCPServer went to Failed with AuthServerConfigValidated=False. After: it is accepted.
  • Conflicting grants with no upstreams. Before: a RunConfig with the deprecated delegate_clients and inbound_grants.token_exchange together passed the vMCP validator when it had no upstreams, and failed later at runtime. After: it fails in the validator with "auth server inbound grants are invalid", wrapping the normalization error. On the operator path the conflict was already caught while building the RunConfig.
  • Trust-mode error text. The error for a private_key_jwt delegate client without a token_exchange block now ends with the change that keeps the old behavior: set token_exchange.self_issued_subject_tokens to any. The existing message is still a prefix of the new one.

Special notes for reviewers

  • The four commits are unrelated, so they could be reviewed or merged separately. The validator commit is the only one that changes behavior users can see. I can split it out if you prefer.
  • These come out of the two delegate client CRD PRs ("Expose delegate client JWKS and token-exchange policy in the CRD" and "Expose exchange refresh token issuance in the CRD"), now drafts. They are the parts that do not depend on a new CRD field.
  • The validator only runs normalization when there are no upstreams, so configs that have upstreams behave as before. Their conflicts are still caught later by RunConfig.Validate and, on the operator path, by ValidateInboundGrants.
  • A config whose only grant is inbound_grants.spiffe_client_auth with no upstreams is still rejected here, as before. The CRD accepts it, so the layers disagree. I left that alone.
  • The rotation test uses ES256 keys for both keys. The doc says the keys must imply the same signing algorithm, which the test does not exercise.

jhrozek and others added 4 commits November 3, 2026 21:44
A vMCP config that declares its delegate clients, or its JWT bearer
issuer policies, only under inbound_grants was rejected with "requires
at least one upstream". The check counted the deprecated top-level
delegate_clients list and read the trusted issuers before the canonical
JWT bearer policy had been applied to them. The operator hit it too: its
checks accept inboundGrants with no upstream providers, then the
reconciler ran this validator and marked the VirtualMCPServer Failed.

Judge the same normalized view the runtime uses, by running
NormalizeInboundGrants once and checking its delegate clients and
trusted issuers. Such a config is now accepted. A config with no
upstreams and conflicting legacy and canonical grants now fails here
with the normalization error instead of at runtime.

Co-authored-by: Mecatl <[email protected]>
A private_key_jwt delegate without a token_exchange block is refused
since the trust-mode rule landed. Users upgrading from an earlier release
may have such a client that relied on the implicit any behaviour, so the
error now names the one-line change that restores it.

Co-authored-by: Mecatl <[email protected]>
The comment said a key implies its signing algorithm. An RSA key without
alg does not imply RS256; RS256 is only the default when the keys do not
say, because RS and PS are both possible. Say what the function returns.

Co-authored-by: Mecatl <[email protected]>
A broker that rotates its private_key_jwt key needs a window where the
server accepts both the old and the new key. The runtime supports that
through a multi-key JWKS with unique kids, but the only rotation test
replaced one key with another, so the overlap was never exercised.

Extend that test to walk old, then old plus new, then new, so it
accepts both keys while the file holds both and refuses the old one
once it is removed. Document the three-step procedure, why the order
matters, and that memory storage drops what the server held across a
restart.

Co-authored-by: Mecatl <[email protected]>
@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label Nov 3, 2026
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.52%. Comparing base (f87c47a) to head (65ec0f0).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7048      +/-   ##
==========================================
- Coverage   80.53%   80.52%   -0.02%     
==========================================
  Files         853      856       +3     
  Lines       87221    87378     +157     
==========================================
+ Hits        70243    70360     +117     
- Misses      16973    17013      +40     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The validator now normalizes the same way RunConfig.Validate does at runtime, so the only configs it newly rejects (normalization conflicts, duplicate issuers, bad issuer_refs) already failed at startup. The trust-mode error keeps the old text as a prefix. No breaking changes found.

@jhrozek
jhrozek merged commit 0bdf582 into main Nov 4, 2026
47 checks passed
@jhrozek
jhrozek deleted the delegate-client-extracts branch November 4, 2026 13:22
@github-actions github-actions Bot mentioned this pull request Nov 4, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants