-
Notifications
You must be signed in to change notification settings - Fork 132
Add proxy-logs workload endpoint #2208
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
40af413
to
3958442
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2208 +/- ##
==========================================
- Coverage 53.54% 53.41% -0.13%
==========================================
Files 228 228
Lines 29313 29358 +45
==========================================
- Hits 15696 15683 -13
- Misses 12489 12552 +63
+ Partials 1128 1123 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@claude, could you review the PR with a security hat on? |
Claude finished @amirejaz's task —— View job Security ReviewI've completed a security-focused review of the proxy-logs endpoint implementation. Here are my findings: Critical Security Issue🔴 Missing Workload Name Validation The Location: The Problem: func (s *WorkloadRoutes) getProxyLogsForWorkload(w http.ResponseWriter, r *http.Request) {
name := chi.URLParam(r, "name") // ❌ No validation
// Directly constructs path with unvalidated input
logFilePath, err := xdg.DataFile(fmt.Sprintf("toolhive/logs/%s.log", name)) Why This is Critical:
Attack Example: # Could potentially read other log files
curl "http://localhost:8080/api/v1beta/workloads/../../../etc/passwd%00.log/proxy-logs"
# Or traverse to other workload logs
curl "http://localhost:8080/api/v1beta/workloads/../../other-workload/proxy-logs" Comparison with Other Endpoints:
The Fix: func (s *WorkloadRoutes) getProxyLogsForWorkload(w http.ResponseWriter, r *http.Request) {
name := chi.URLParam(r, "name")
// ✅ Add validation BEFORE constructing path
if err := wt.ValidateWorkloadName(name); err != nil {
http.Error(w, "Invalid workload name: "+err.Error(), http.StatusBadRequest)
return
}
// Now safe to proceed with validated name
logFilePath, err := xdg.DataFile(fmt.Sprintf("toolhive/logs/%s.log", name))
// ... rest of function
} The
Additional Security Observations🟡 Information Disclosure Issue: Returns entire log file contents without size limits (line 583: Risk:
Recommendation:
🟢 Authentication/Authorization Good: The endpoint inherits authentication middleware from the router setup (
Note: No explicit authorization checks per workload - any authenticated user can access any workload's logs. This may be acceptable depending on your threat model, but consider if workload-level access control is needed. 🟢 Error Handling The error handling is generally good:
Additional Recommendations
SummaryMust Fix Before Merge:
Should Consider:
The core security issue is straightforward to fix by adding one validation call at the beginning of the function, following the pattern used by all other workload endpoints in this file. Todo List:
Job run: https://github.com/stacklok/toolhive/actions/runs/${{ github.run_id }} |
I updated the PR title to match out commit conventions |
87fb582
to
18eb8b1
Compare
Summary
Based on a proposal stacklok/toolhive-studio#934 from @danbarr showing proxy logs on UI ( that is particularly useful for remote mcp) I created this PR, in order to expose the endpoint and let the UI show the logs.
Add new API endpoint to retrieve proxy logs for MCP workloads.
Changes
GET /api/v1beta/workloads/{name}/proxy-logs
.../toolhive/logs/{workload-name}.log
API Details
Endpoint
Responses
Usage
This endpoint allows the UI to display proxy logs for individual MCP servers, providing visibility into proxy process activity and debugging information.
Implementation
getProxyLogsForWorkload
handler functionTesting
The endpoint can be tested with: