Run unauthenticated-exposure probes over a fresh anonymous session - #3
Merged
Merged
Conversation
REAP's "unauthenticated exposure" probes re-used the session created with --auth-header and merely suppressed the per-request Authorization header via WithNoAuth(). That does not undo transport state established out-of-band: WebSocket auth is bound to the upgrade handshake, streamable HTTP retains a captured Mcp-Session-Id, and legacy SSE keeps an authenticated long-lived stream. On WebSocket especially, WithNoAuth() is ignored entirely, so an authenticated tool list could be reported as anonymous exposure (issue #1). - Add AnonymousSession() to Session, SSESession and WSSession: a fresh, credential-free connection reusing the shared httpx.Client. Add Close() to SSESession (cancels the stream goroutine) and WSSession (closes the socket) so probes can tear down the extra connection. - checks.go: route mcp-unauth-tools-list, mcp-resources-prompts-exposure, the OAuth Bearer-challenge check, and mcp-auth-posture through a separate anonymous session instead of WithNoAuth() on the authenticated one. - Finding-emitting probes run a full anonymous initialize first (anonymousInitializedSession): spec-compliant streamable-HTTP/SSE servers gate enumeration behind initialize + Mcp-Session-Id, so a fresh session that skipped it would under-report a genuinely open server (false negative). - authPostureProbe swaps to a fresh anonymous session while preserving its init-agnostic open/gated/unreached semantics; a refused anonymous connection now reads as gated rather than a false "open". Tests: authenticated-WebSocket false-positive guard, initialize-gated open streamable false-negative guard, and SSESession.Close. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
REAP's "unauthenticated exposure" probes re-used the session created with
--auth-header and merely suppressed the per-request Authorization header via
WithNoAuth(). That does not undo transport state established out-of-band:
WebSocket auth is bound to the upgrade handshake, streamable HTTP retains a
captured Mcp-Session-Id, and legacy SSE keeps an authenticated long-lived
stream. On WebSocket especially, WithNoAuth() is ignored entirely, so an
authenticated tool list could be reported as anonymous exposure (issue #1).
credential-free connection reusing the shared httpx.Client. Add Close() to
SSESession (cancels the stream goroutine) and WSSession (closes the socket)
so probes can tear down the extra connection.
OAuth Bearer-challenge check, and mcp-auth-posture through a separate
anonymous session instead of WithNoAuth() on the authenticated one.
(anonymousInitializedSession): spec-compliant streamable-HTTP/SSE servers
gate enumeration behind initialize + Mcp-Session-Id, so a fresh session that
skipped it would under-report a genuinely open server (false negative).
init-agnostic open/gated/unreached semantics; a refused anonymous connection
now reads as gated rather than a false "open".
Tests: authenticated-WebSocket false-positive guard, initialize-gated open
streamable false-negative guard, and SSESession.Close.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com