Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix: resolve SSE endpoint references per RFC 3986 in SseClientTransport #1100
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
Uh oh!
There was an error while loading. Please reload this page.
fix: resolve SSE endpoint references per RFC 3986 in SseClientTransport #1100
Changes from all commits
c09faf70906a5b4c0f33cb1c33dd06eacf6File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
Problem: a network-path reference (
//host/path, RFC 3986 §4.2) also starts with/, so it takes this branch and is pasted after the authority as a path instead of replacing it. It therefore never reaches the origin check, even though it carries its own authority.Failure scenario: a server behind a TLS-terminating proxy announces
endpoint: //api.example.com/messages?sessionId=x; the client POSTs tohttps://api.example.com//api.example.com/messages?sessionId=xand gets the #1080 404. I confirmed the double-slash path goes out on the wire and misses the route. No origin leak — the POST stays on the SSE origin — but it never reaches the announced endpoint, and a//evil.example.com/...reference is silently rewritten instead of rejected.Suggested fix: add a
reference.startsWith("//")branch ahead of this one that builds"$protocol:$reference"and sends it through the samehasSameOrigincheck as the full-URL branch above.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.
Problem: the merged path is used as-is, so dot segments in the reference are never removed.
remove_dot_segmentsis the other half of RFC 3986 §5.2.2 that the KDoc above cites; it was added in 4c0f33c after Copilot's comment and dropped again (with its tests) in the last refactor.Failure scenario: a server with the SSE URL
/api/mcp/sseannouncesendpoint: ../messages?sessionId=x; the client POSTs to/api/mcp/../messages?sessionId=x. I checked this on the wire with the CIO engine — the un-normalized path is sent verbatim and a Ktor server does not match it to the registered route — soconnect()fails with the same 404 as #1080 for any endpoint reference containing a dot segment. Same for an absolute-path reference such as/api/../messages.Suggested fix: run
remove_dot_segmentsover the path part ofpathAndQuerybefore appending it toprotocolWithAuthority, so it covers the absolute-path and relative-path branches alike.Uh oh!
There was an error while loading. Please reload this page.