Skip to content

Resolve SSL transport data loss on full network BIO - #244

Merged
bettercallsaulj merged 14 commits into
mainfrom
fix_linux_crash
Jul 8, 2026
Merged

Resolve SSL transport data loss on full network BIO#244
bettercallsaulj merged 14 commits into
mainfrom
fix_linux_crash

Conversation

@bettercallsaulj

@bettercallsaulj bettercallsaulj commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

This PR must be merged after #243

Issue:
Skip TLS peer metadata when verification is disabled (#251)
Avoid retaining streamed HTTP client bodies (#260)
Guard oversized HTTP body callbacks (#255)
Defer HTTP parser callback errors (#256)
Post HTTP parser error callbacks (#252)
Defer active connection destruction on close (#257)
Bind llhttp symbols inside shared library (#259)
Honor preferred HTTP transport (#253)

@gophergogo

gophergogo commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

@bettercallsaulj thanks for the work, but once again, please log a ticket to explain the origin of this work. Or the PR can't be merged, unless the community is on the same page.

And please change the title to reflect the work properly.

@dIvYaNshhh dIvYaNshhh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Automated review — 3 blockers (2 UAFs + an empty-body regression) plus mediums/low. Inline comments below.

Comment thread src/filter/http_codec_filter.cc
Comment thread src/filter/http_codec_filter.cc Outdated
Comment thread src/filter/http_codec_filter.cc
Comment thread src/mcp_connection_manager.cc Outdated
Comment thread src/mcp_connection_manager.cc Outdated
Comment thread src/mcp_connection_manager.cc Outdated
Comment thread CMakeLists.txt Outdated
Comment thread src/transport/ssl_transport_socket.cc Outdated
@bettercallsaulj
bettercallsaulj force-pushed the feature_token_protect branch from caa3a75 to 3901ef2 Compare July 6, 2026 17:12
@bettercallsaulj
bettercallsaulj force-pushed the fix_linux_crash branch 2 times, most recently from 44c9613 to 3d4b49e Compare July 6, 2026 18:21
@bettercallsaulj

Copy link
Copy Markdown
Collaborator Author

@bettercallsaulj thanks for the work, but once again, please log a ticket to explain the origin of this work. Or the PR can't be merged, unless the community is on the same page.

And please change the title to reflect the work properly.

Done

@gophergogo

Copy link
Copy Markdown
Collaborator

@bettercallsaulj why do you so many blocker and medium level issue to address? Don't you need good design before coding? Where is the design?

@bettercallsaulj

Copy link
Copy Markdown
Collaborator Author

@bettercallsaulj why do you so many blocker and medium level issue to address? Don't you need good design before coding? Where is the design?

This whole issue is about crashing on Linux.
The commits are the attempts to resolve it.
They are not new features, and no design in advance.

@bettercallsaulj
bettercallsaulj force-pushed the feature_token_protect branch from 3901ef2 to 2f40053 Compare July 7, 2026 04:20
@gophergogo gophergogo changed the title Fix linux crash issue Resolve SSL transport data loss on full network BIO Jul 7, 2026

@dIvYaNshhh dIvYaNshhh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the empty-body, handleParserError use-after-free, and close() callback issues from the earlier round are all addressed here, and the total body-size cap is a nice add. Two smaller notes below. One bigger point for the description: this PR fixes the data loss on the read side only; the write side (moveFromBio(), from #242) still drops encrypted bytes on a full socket, so the data-loss goal isn't fully met yet — see the comment on #242.

Comment thread cmake/gopher-mcp-llhttp-local.map Outdated
Comment thread src/client/mcp_client.cc Outdated
dIvYaNshhh
dIvYaNshhh previously approved these changes Jul 7, 2026

@dIvYaNshhh dIvYaNshhh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM ✅ — all previously raised findings are addressed. Thanks for the thorough fixes.

@bettercallsaulj
bettercallsaulj force-pushed the feature_token_protect branch from d088a49 to 0f850c1 Compare July 8, 2026 09:14
RahulHere added 14 commits July 8, 2026 17:16
Summary:

- Add default HTTP header storage to MCP client and connection configuration so SDK-created clients can send runtime Authorization headers.

- Add per-request HTTP header overloads for sendRequest, listTools, and callTool so gateway callers can pass the client bearer token through to backend MCP servers.

- Propagate configured and per-request headers into HTTP/SSE and streamable HTTP request formatting, with per-request headers overriding static defaults.

- Preserve generated transport headers such as Host, Content-Type, Content-Length, Accept, Connection, User-Agent, and Cache-Control.
Summary:
- Avoid reading peer certificate metadata for client transports that intentionally disable peer verification.
- Prevent the Linux HTTP/SSE native client from crashing in SSL_get_peer_certificate during MCP tool discovery.
Summary:
- Stream client HTTP response body chunks downstream without accumulating them in the codec stream state.
- Avoid duplicate forwarding and unbounded retention for long-lived HTTP/SSE responses during MCP initialization.
Summary:
- Reject null or oversized HTTP body callback chunks before allocating response strings.
- Convert body allocation failures into parser errors so the event thread does not terminate.
Summary:
- Store parser callback failures and report them after llhttp execution unwinds.
- Avoid synchronous MCP disconnect and transport destruction from inside body callbacks.
Summary:
- Report parser errors through the dispatcher instead of directly from the read callback stack.
- Avoid MCP disconnect and HTTP/SSE transport destruction while filters are still unwinding.
Summary:
- Keep active MCP connections alive after close() schedules dispatcher-owned shutdown.
- Let the existing close event path move the connection into deferred deletion instead of resetting it immediately.
Summary:
- Link the Linux gopher-mcp shared library with -Bsymbolic-functions.
- Prevent Node.js llhttp symbol interposition from corrupting HTTP parser callback arguments.
Respect the configured preferred transport for HTTP and HTTPS MCP URLs when auto negotiation is enabled. This lets callers explicitly choose Streamable HTTP or HTTP+SSE instead of always falling back to URI path heuristics.
Summary: Fetch llhttp sources without configuring upstream shared targets, build the SDK parser dependency as a private static target with hidden visibility, and narrow the Linux version script to the llhttp entry points used by the SDK.
Summary: Clear the MCP connection manager callback pointer synchronously during client shutdown before posting close work or requesting dispatcher exit, and destroy dispatcher-owned resources before deleting the dispatcher. Add a regression test that verifies callback clearing does not depend on queued dispatcher work.
Summary: Apply formatting cleanup to the MCP client memory and connection manager tests after the header and shutdown fixes.
@bettercallsaulj
bettercallsaulj changed the base branch from feature_token_protect to main July 8, 2026 09:19
@bettercallsaulj
bettercallsaulj dismissed dIvYaNshhh’s stale review July 8, 2026 09:19

The base branch was changed.

@bettercallsaulj
bettercallsaulj merged commit 63e5611 into main Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants