fix(introspector): bound discover_server awaits with timeouts, fix mcp-server lock DoS#127
Merged
Merged
Conversation
bug-ops
enabled auto-merge (squash)
July 9, 2026 14:57
…p-server lock DoS Introspector::discover_server connected to downstream MCP servers and awaited list_all_tools with no timeout, so a hung or malicious server blocked the call forever. In mcp-execution-server this was serialized behind a single global Arc<Mutex<Introspector>>, letting one bad server block introspect_server for every session indefinitely. Add connect_timeout/discover_timeout to ServerConfig (30s defaults) and wrap both awaits in tokio::time::timeout, mapping expiry to the existing Error::Timeout variant. Replace the global mutex in GeneratorService with a per-server-id keyed lock, evicting each entry once discover_server completes so unrelated server ids never contend and the map stays bounded. Closes #120
bug-ops
force-pushed
the
fix/120-introspector-timeout
branch
from
July 9, 2026 15:00
84bf57e to
2821718
Compare
This was referenced Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Introspector::discover_serverconnected to downstream MCP servers and awaitedlist_all_toolswith no timeout, so a hung or malicious server blocked the call forever.mcp-execution-server, this was made worse by a single globalArc<Mutex<Introspector>>: one hung server blockedintrospect_serverfor every session, not just the caller who triggered it.connect_timeout/discover_timeoutfields toServerConfig(30s defaults) and wraps both awaits intokio::time::timeout, mapping expiry to the existingError::Timeoutvariant.GeneratorServicewith a per-server-id keyed lock (introspector_for), evicting each entry oncediscover_servercompletes (success or error) so unrelated server ids never contend and the map stays bounded against caller-supplied ids.Test plan
cargo +nightly fmt --checkcargo +stable clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --all-features --workspace --no-fail-fastcargo test --doc --all-features --workspaceRUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspaceCloses #120