-
Notifications
You must be signed in to change notification settings - Fork 122
Design proposal: Token exchange to acquire tokens for external auth #2063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@claude please review this with extra focus on security. Do the review in English. Please provide some jokes in Czech at the end of the review. |
Claude finished @JAORMX's task —— View job Security Review of Token Exchange Design ProposalI've completed a thorough security analysis of the token exchange middleware design. Here's my comprehensive review: Todo List:
Security Analysis🛡️ Strengths
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2063 +/- ##
==========================================
+ Coverage 48.20% 48.28% +0.08%
==========================================
Files 233 236 +3
Lines 29229 29690 +461
==========================================
+ Hits 14089 14337 +248
- Misses 14106 14277 +171
- Partials 1034 1076 +42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Thank you for the thorough security review! We've updated the proposal to address all concerns raised. Responses inline below: Security Concerns & Recommendations
Addressed: The proposal already mentioned using
Addressed: Updated the proposal to document secure secret handling (lines 71-114):
The Kubernetes operator already uses
Addressed: Added comprehensive "Security Considerations" section (lines 116-153) documenting ToolHive's existing security infrastructure:
Addressed: Added explicit statement at line 63:
The architecture already ensures this through middleware ordering - auth middleware validates tokens before token exchange middleware runs.
Addressed: Security Considerations section documents:
Standard TLS validation is sufficient for this use case.
Addressed: Added error handling documentation with example (lines 134-148):
Addressed: Added section at lines 150-152 explaining RFC 8693/OAuth2 standard protections:
No additional replay protection needed beyond RFC 8693 standard mechanisms. Additional Security Recommendations
These are valuable production-hardening features. The initial implementation focuses on core RFC 8693 compliance. These enhancements can be added in future iterations based on operational experience. ToolHive has an existing audit event system in SummaryThe proposal now includes:
Most security concerns were already addressed through ToolHive's existing infrastructure (HTTPS enforcement, TLS 1.2+, certificate validation, |
clientSecretRef: | ||
name: token-exchange-creds | ||
key: client-secret | ||
audience: backend-service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if at this point we should have a dedicated CRD for the authentication pieces. I know that's out of scope of this PR, but I think we should think about it sooner rather than later. I can see folks wanting to share these configurations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the CRD is getting quite big. So the MCPServer CRD would have a reference to some MCPServerAuthConfig
CRD that would be shared across servers?
We'd have to template the client names though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually wonder if this /should/ be a pre-requisite though. Once we add something to our CRDs it;s hard to back off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JAORMX Structurally I can see how the authentication and authorization pieces are complex enough to warrant their own controller (i.e. auth CRD reconciler). Especially in light of incoming requirements around SPIFFE and SPIRE where token lifetimes and privilege will be scoped as narrowly as possible and expire/be rotated quite regularly. If we consider security more broadly there's also certificate expiry, rotation, and management that is likely to be encountered in the future as well with use of something like cert-manager. I think there's quite a bit here with respect to the responsibilities of such an independent security manager/controller.
@jhrozek While I don't think it's a pre-requisite by definition, it would make life easier in a number of ways to do it now rather than later. In light of the sizing constraints already having been hit with the current CRD that's also a good technical reason to do it now outside of the organization and maintenance involved of separating it later.
The counterpoint here would be if the authentication/authorization information is not to be utilized in the operator but only passed through to either the proxy and/or MCP server operands that the operator launches and operates. In which case is there a need for the operator to serve as middleman? I don't think that's the case (see the first paragraph above) but worth putting the question out there for consideration.
Adds a design for #2041