You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tools/list is not filtered on the SSE transport #6926
With an HTTP PDP, tools/list is not filtered on the SSE transport. The PDP receives no tools/list requests, and every tool is listed. tools/call is still denied correctly.
Steps to reproduce
Run thv run osv --transport sse --authz-config <config>, where the HTTP PDP allows mcp:tool:call only for query_vulnerability.
Send tools/list over the SSE connection.
Expected behavior
Only query_vulnerability is listed.
Actual behavior
All three tools are listed: get_vulnerability, query_vulnerabilities_batch, and query_vulnerability.
Environment
OS/version: Windows 11 with WSL2 (Ubuntu 24.04)
ToolHive version: v0.55.2
Additional context
Also reproduced on main, so this predates #6903. Streamable HTTP lists only the allowed tool, so the gap is specific to SSE.
I found this while reviewing #6903. I'd like to work on it if a maintainer agrees it's worth doing. Could you assign it to me once you've had a look? Thanks.
Thanks for the report, @rkb32, and for checking it on main as well. This matches how the SSE transport works today: the tools/list result comes back over the event stream rather than in the POST response, so the authz response filter never gets to see it. Calls are still denied, so the gap is in what gets listed.
It isn't on our roadmap right now, but we'd welcome a fix, and since you offered, I've assigned it to you. Before you go deep, you can either sketch the approach here in a few lines (where the filtering would hook into the SSE stream, and how it stays consistent with streamable HTTP), or open a draft PR directly and we'll look at the design there. Please link the PR with Fixes #6926 in the description.
Thanks for the review @aponcedeleonch I Reproduced on main (7970d58). The test is TestSSEToolsListIsFilteredByAuthz in pkg/transport/proxy/httpsse/tool_list_authz_test.go. It's a unit test over the legacy SSE proxy with an authz middleware, and it fails the same way on main.
What happens: the caller can read only weather. The tools/list answer on the GET /sse stream still contains secret. The POST returns 202, and the authz middleware only filters the POST response, so the list on the stream is never checked.
Approach:
Where it hooks in: the authz middleware sees the GET /sse request. When the response is text/event-stream, it wraps the response writer, buffers each complete SSE event, and filters any message whose result.tools is an array, then emits the event.
Consistency with streamable HTTP: it uses the same tool:read check and the same filter helper as the POST path. The difference is granularity: streamable HTTP filters one response per request, while SSE filters each message on the stream. The identity comes from the stream's own request, which is the session owner's.
Thanks @rkb32, this is a solid write-up. The diagnosis matches what I see on main, and hooking into the authz middleware on the GET /sse response is the right place for it.
There's already a precedent for this that I'd like you to reuse. The --tools filter (NewListToolsMappingMiddleware in pkg/mcp/tool_filter.go) already wraps the GET /sse stream. It buffers complete events and rewrites any data: frame carrying result.tools. Its toolFilterWriter already handles the streaming details: holding back partial events until they're complete, the final drain when the handler returns, and refusing to pass a list through when it can't be filtered. I'd model the new writer on it rather than starting from scratch. The existing ResponseFilteringWriter won't work as-is, because it buffers until the handler returns, and on GET /sse that only happens when the client disconnects.
That precedent only matches tools, but I don't think prompts, resources, resource templates, and skills should be out of scope. They leak on SSE exactly the same way. pkg/authz/response_filter.go already has a filter for each of them. So the stream writer can look at which member the result carries (tools, prompts, resources, resourceTemplates, skills) and hand it to the matching filter. Please also reuse the fail-closed handling in filterSSEEventData, so frames that try to sneak a result past the filter get rejected on the stream the same way they are on the POST path. Since the stream path picks the filter by result shape instead of the request method, please call that out in the PR as a deliberate difference from the POST path.
On stdio, I'd also bring it into scope. The httpsse proxy wraps GET /sse in the same middleware chain as the transparent proxy, so the fix covers it with no extra work. Your test actually runs against httpsse, which is the stdio path. The original report (--transport sse with osv) goes through the transparent proxy in pkg/transport/proxy/transparent. Could you add a test there as well, so both are covered?
One smaller note: I don't think you need to wait on #6903. If the stream path calls the same filterToolsResponse as the POST path, it'll check tool:call today and switch to tool:read automatically once #6903 merges.
Happy to look at a draft PR whenever you're ready.
Activity
aponcedeleonch commentedon Oct 23, 2026
Thanks for the report, @rkb32, and for checking it on main as well. This matches how the SSE transport works today: the tools/list result comes back over the event stream rather than in the POST response, so the authz response filter never gets to see it. Calls are still denied, so the gap is in what gets listed.
It isn't on our roadmap right now, but we'd welcome a fix, and since you offered, I've assigned it to you. Before you go deep, you can either sketch the approach here in a few lines (where the filtering would hook into the SSE stream, and how it stays consistent with streamable HTTP), or open a draft PR directly and we'll look at the design there. Please link the PR with
Fixes #6926in the description.Thanks again for the clear write-up.
rkb32 commentedon Oct 23, 2026
Thanks for the review @aponcedeleonch I Reproduced on
main(7970d58). The test isTestSSEToolsListIsFilteredByAuthzinpkg/transport/proxy/httpsse/tool_list_authz_test.go. It's a unit test over the legacy SSE proxy with an authz middleware, and it fails the same way onmain.What happens: the caller can read only
weather. Thetools/listanswer on theGET /ssestream still containssecret. The POST returns 202, and the authz middleware only filters the POST response, so the list on the stream is never checked.Approach:
GET /sserequest. When the response istext/event-stream, it wraps the response writer, buffers each complete SSE event, and filters any message whoseresult.toolsis an array, then emits the event.tool:readcheck and the same filter helper as the POST path. The difference is granularity: streamable HTTP filters one response per request, while SSE filters each message on the stream. The identity comes from the stream's own request, which is the session owner's.tool:readdecorator), which is still open. I'd rebase on it or merge it first.httpssepath and prompts, resources, and skills lists.I'll open a draft PR with
Fixes #6926once the approach is agreed.aponcedeleonch commentedon Oct 27, 2026
Thanks @rkb32, this is a solid write-up. The diagnosis matches what I see on main, and hooking into the authz middleware on the
GET /sseresponse is the right place for it.There's already a precedent for this that I'd like you to reuse. The
--toolsfilter (NewListToolsMappingMiddlewareinpkg/mcp/tool_filter.go) already wraps theGET /ssestream. It buffers complete events and rewrites anydata:frame carryingresult.tools. ItstoolFilterWriteralready handles the streaming details: holding back partial events until they're complete, the final drain when the handler returns, and refusing to pass a list through when it can't be filtered. I'd model the new writer on it rather than starting from scratch. The existingResponseFilteringWriterwon't work as-is, because it buffers until the handler returns, and onGET /ssethat only happens when the client disconnects.That precedent only matches tools, but I don't think prompts, resources, resource templates, and skills should be out of scope. They leak on SSE exactly the same way.
pkg/authz/response_filter.goalready has a filter for each of them. So the stream writer can look at which member the result carries (tools,prompts,resources,resourceTemplates,skills) and hand it to the matching filter. Please also reuse the fail-closed handling infilterSSEEventData, so frames that try to sneak a result past the filter get rejected on the stream the same way they are on the POST path. Since the stream path picks the filter by result shape instead of the request method, please call that out in the PR as a deliberate difference from the POST path.On stdio, I'd also bring it into scope. The
httpsseproxy wrapsGET /ssein the same middleware chain as the transparent proxy, so the fix covers it with no extra work. Your test actually runs againsthttpsse, which is the stdio path. The original report (--transport ssewith osv) goes through the transparent proxy inpkg/transport/proxy/transparent. Could you add a test there as well, so both are covered?One smaller note: I don't think you need to wait on #6903. If the stream path calls the same
filterToolsResponseas the POST path, it'll checktool:calltoday and switch totool:readautomatically once #6903 merges.Happy to look at a draft PR whenever you're ready.