Alice starts an agent run and receives a long random session ID. Bob later presents that exact ID with his own valid authentication. The server loads Alice's pending approval and tool state because the lookup uses only the handle. The identifier was impossible for Bob to guess; once leaked through a log or URL, possession became ownership.
A state handle answers where continuity is stored. It cannot establish who may resume it. Every request needs independent authentication, and every lookup needs a binding to the verified principal, tenant, client where relevant, and current authorization. A mismatch should fail without confirming that the state exists.
The current MCP protocol core is stateless, but application layers still introduce task IDs, run IDs, approval references, resumable streams, caches, and compatibility sessions. Each handle needs an explicit owner and lifecycle. Entropy protects discovery; principal binding protects use.
Key Takeaways
- Session identifiers and other opaque handles are untrusted request input. High entropy reduces guessing but does not provide ownership, tenant isolation, or authorization.
- Stateful MCP implementations must bind stored state to a stable principal tuple and compare that tuple on every request that resumes, reads, mutates, or terminates the state.
- The binding should use verified attributes such as issuer, subject, client identity, and tenant context; display names, email addresses, request headers, and session IDs are not substitutes.
- A 2026 Python SDK vulnerability affected authenticated stateful SSE and Streamable HTTP deployments under specific conditions; stateless and stdio configurations were outside that particular isolation bypass.
- The final MCP specification published on July 28, 2026 uses a stateless core, so new designs should avoid unnecessary protocol-level sessions while still protecting any application-level state they introduce.
- Negative tests need two valid principals and one state object: principal B must be unable to access principal A's state even when B presents A's valid handle.
A Locator Answers “Which State?”, Not “Whose State?”
Applications routinely use opaque identifiers to retrieve server-side objects. A session ID may point to a transport session. A run ID may point to an agent execution. A cursor may resume a stream. A conversation ID may retrieve message history. A task token may approve a pending tool action.
The identifier is useful because the server can find an object without exposing internal database keys. It can also be unpredictable, short-lived, and signed. None of those properties identifies the caller.
Identity comes from an authentication process: validating a token under a trusted issuer and audience, verifying a client certificate, checking a signed workload identity, or using another explicit mechanism. Ownership comes from a stored relationship between that verified principal and the object. Authorization evaluates whether the current principal may perform the requested action on that object.
These are separate inputs:
authenticated principal + presented handle + requested action
|
v
server-side authorization
|
v
allow only if principal owns or may access state
If the authorization step becomes state = lookup(handle); return state, the handle has silently become a bearer credential. Every place that records, forwards, previews, or exposes it then joins the authentication boundary, whether the team intended that or not.
The 2026 MCP SDK Isolation Failure
A 2026 maintainer advisory for the MCP Python SDK documented a high-severity cross-user session isolation issue, tracked as CVE-2026-52869. The affected range extended through version 1.27.1, and the fix was released in 1.27.2.
The vulnerable condition was specific. It concerned servers that were both authenticated and stateful while using SSE or stateful Streamable HTTP. The server selected an existing session from the supplied session identifier but did not verify that the authenticated principal on the new request matched the principal that created the session. A party that obtained another session's random identifier through some separate channel could interact with state it did not own.
That prerequisite matters. The issue did not mean session UUIDs were trivially guessable. The identifier first had to become known, perhaps through logging, monitoring, copied diagnostics, browser history, network visibility, an integration, or another disclosure path. It also did not describe this specific bypass for stdio, stateless Streamable HTTP, or deployments without authentication. Each deployment therefore required configuration-aware exposure analysis.
The fix recorded principal information with a session and compared it on subsequent access. The binding used OAuth client identity and, when available, issuer and subject information. A mismatch produced a not-found response, which also reduced information leakage about another principal's state. The advisory highlighted an important shared-client condition: if many end users authenticate through the same OAuth client, client ID alone does not distinguish them. The subject must be populated and stable.
We should not generalize this into a claim that every MCP session or every SDK was affected. We should generalize the security principle: state selected by a client-controlled handle must be authorized against the current verified principal after lookup and before use.
Current MCP Is Stateless, but Applications Still Hold State
The final MCP specification announced on July 28, 2026 removed protocol-level handshake and session requirements in favor of a stateless core. That change simplifies scaling, recovery, retries, and security reasoning. A conforming new design should not reintroduce transport sessions merely because an older implementation used them.
Stateless protocol behavior does not mean the surrounding application has no state. An MCP deployment may still maintain:
- Long-running agent jobs and their intermediate results.
- Human approval requests for sensitive tool actions.
- OAuth authorization records and consent grants.
- Tool-specific cursors, leases, locks, or resumable uploads.
- Conversation history stored by the host application.
- Tenant-scoped caches and resource indexes.
- Asynchronous notifications awaiting delivery.
- Sandboxed workspaces created for a user or workload.
- Audit records and incident evidence.
Every identifier that retrieves one of these objects creates the same ownership question. Calling it a run_id instead of session_id does not change the boundary. Current architecture should embrace stateless MCP messages while defining explicit authorization for application state at the layer that owns it.
Legacy and Compatibility Paths Remain Relevant
Real deployments do not migrate instantly. Stateful transports may remain behind compatibility adapters, older clients, internal gateways, or long-lived support branches. Inventory must identify the actual SDK version and transport mode in use, not infer them from a repository lock file alone. A service can bundle multiple workers with different images, or a gateway can terminate one transport and create state internally.
For legacy paths, the immediate requirement is correct principal binding. For new paths, the better question is whether the state needs a client-presented resumable handle at all.
Build a Stable Principal Tuple
“Bind the session to the user” sounds simple until identity crosses issuers, clients, service accounts, tenants, and delegated workflows. A robust binding uses attributes that are both verified and stable within a documented trust domain.
Candidate Principal Components
| Attribute | Security Purpose | Important Constraint |
|---|---|---|
| Issuer | Names the authority that authenticated the subject | Compare a canonical trusted issuer, not a request-supplied label |
| Subject | Distinguishes the end user or workload within the issuer | Must be verified; email is usually a poor substitute |
| OAuth client ID | Identifies the client application involved in the request | Insufficient for end-user isolation when many users share one client |
| Tenant or organization ID | Constrains state to an administrative boundary | Derive from verified membership, not an arbitrary header |
| Workload/service identity | Identifies a non-human caller | Preserve delegation context when acting for a user |
| Authentication assurance | Captures method or assurance needed for sensitive continuation | Do not silently downgrade on resumed work |
| Authorization policy version | Supports re-evaluation after role or policy changes | Binding must not freeze obsolete permissions indefinitely |
A typical owner key might be conceptually represented as:
owner = canonical(issuer, subject, client_id, tenant_id)
The exact tuple depends on the trust model. What matters is that every component comes from verified security context, is normalized consistently, and has documented lifecycle behavior.
Why Client ID Alone Often Fails
OAuth client identity tells the resource server which software client is involved. It does not always identify the human behind that client. An enterprise MCP host may use one registered client for thousands of employees. If state is bound only to that client ID, every employee appears to be the same owner.
When end-user isolation is required, use a verified subject and issuer. If the server cannot obtain a stable end-user subject, it cannot safely offer user-specific resumable state under a shared client without an additional authenticated binding mechanism.
Why Email Is a Fragile Subject
Email addresses can change, be reassigned, vary in case handling, or come from unverified token claims. A stable provider-issued subject is usually safer. If business policy also needs an email domain or account status, evaluate it as a separate authorization attribute rather than turning the email string into the primary object key.
Delegation Needs Two Identities
Agent systems frequently involve a service acting on behalf of a user. Flattening that into one identity loses accountability. Store both the executing workload/client and the delegating user when the trust model provides them. Authorization can then ask whether this client may act for this subject in this tenant and whether the requested tool action remains within the delegation.
The State-Access Invariant
For any stateful object S, current principal P, and action A, access should require more than a matching handle:
allow(P, A, S) =
authenticated(P)
AND constant_time_equal(owner_key(S), principal_key(P))
AND policy_allows(P, A, S)
AND state_is_valid(S)
The owner comparison proves isolation. The policy check covers legitimate sharing, administration, changed roles, and action-specific permission. The lifecycle check rejects expired, revoked, completed, or invalidated state.
The lookup should not reveal whether another principal's object exists. Returning the same not-found response for an unknown handle and a mismatched owner limits enumeration and reduces side channels. Internal logs can preserve a distinct reason code for defenders.
Bind on Creation, Check on Every Use
Record the principal tuple when the state is created. Recheck it for every operation that can:
- Read messages, prompts, outputs, or tool results.
- Add input or continue execution.
- Receive server notifications.
- Cancel or terminate a run.
- Approve or deny a tool action.
- Export artifacts.
- Change sharing or retention settings.
- Delete state.
Checking only on the first resume is insufficient if later endpoints accept the handle through a different route or transport.
Re-evaluate Authorization, Not Authentication History
Ownership is usually stable for the lifetime of the state, but permission can change. A user can be removed from a tenant, a role can be revoked, a client can lose consent, or an incident can invalidate sessions. Do not store an authorized=true flag and reuse it forever. Authenticate each request and evaluate current authorization for sensitive actions.
High Entropy Is Still Necessary, Just Not Sufficient
Binding does not make identifier quality irrelevant. Handles should remain unpredictable to reduce brute-force discovery and should carry enough entropy for their lifetime and request volume. They should be generated with a cryptographically secure random source and transmitted only over protected channels.
But entropy is one defense layer. It cannot compensate for:
- IDs written to application or proxy logs.
- URLs copied into tickets, chat, browser history, or analytics.
- Referrer leakage when identifiers appear in query strings.
- Monitoring systems with broad read access.
- Frontend script compromise.
- Cross-tenant cache key mistakes.
- Accidental disclosure in error messages or traces.
- A malicious or compromised MCP client.
Treat every handle as eventually discoverable. Correct authorization should keep disclosure from becoming cross-principal access.
Prefer Headers or Message Fields Over URLs
Sensitive resumable identifiers in URLs spread widely through access logs, browser history, screenshots, referrer headers, and observability systems. Use the transport's designated header or protocol field where applicable, enforce TLS, and configure logging redaction. This reduces exposure but does not remove the need for binding.
Session Lifecycle Is Part of Authorization
State needs a documented lifecycle:
created -> active -> idle -> expired
-> completed
-> revoked
-> terminated
Define absolute and idle expiration, whether reconnection extends either limit, and what happens when credentials expire before the state does. Sensitive approvals should have much shorter lifetimes than harmless progress cursors. Completed or revoked handles should not become valid again after a process restart or cache restoration.
Key lifecycle events include:
- Authentication logout or account disablement.
- Tenant removal or role change.
- OAuth grant revocation.
- Client credential rotation.
- Incident-driven global or scoped invalidation.
- Server restart and distributed cache recovery.
- Migration from stateful to stateless transport.
The object store and authorization system need a reliable invalidation path. If session state is distributed, revocation must propagate within a defined maximum window.
Test Cross-Principal Isolation Directly
Single-user functional tests cannot reveal horizontal isolation failures. A minimum security test uses at least two valid principals and two tenant contexts.
Core Test Matrix
| State Owner | Requesting Principal | Handle | Expected Result | What It Proves |
|---|---|---|---|---|
| User A | User A | A's valid handle | Allowed if current policy permits | Normal continuation works |
| User A | User B | A's valid handle | Not found or denied; no state side effect | User isolation is enforced |
| Tenant A user | Tenant B user | Tenant A handle | Not found or denied | Tenant isolation is enforced |
| User A via client 1 | User A via unauthorized client 2 | A's handle | Denied according to client-binding policy | Client context is enforced |
| User A | Logged-out or revoked A | A's handle | Denied | Handle does not outlive identity revocation |
| User A | User A with reduced role | A's handle | Sensitive action re-evaluated | Authorization is current, not cached forever |
| Unknown | Valid user | Random unknown handle | Same external shape as owner mismatch | Existence is not disclosed |
| User A | User A | Expired/completed handle | Denied | Lifecycle is enforced |
Run the matrix across every route and transport that accesses the state. Resume, send, receive, cancel, approval, export, and delete endpoints often use different code paths.
Shared OAuth Client Test
Create two users authenticated through the same OAuth client. If the server binds only to client_id, the test can falsely treat them as one principal. Confirm that subject and issuer distinguish them and that neither can use the other's state handle.
Multi-Instance and Race Tests
Distributed deployments introduce additional risk:
- Create state on instance one and resume through instance two.
- Revoke access while a long poll or stream reconnect is in progress.
- Rotate identity keys and retry an existing handle.
- Race termination against continuation.
- Restore a cache snapshot containing state whose owners are now disabled.
The authorization result must not depend on which worker happens to receive the request.
Verify No Side Effects
For a mismatched principal, assert more than an error response. The request must not append a message, advance an agent, call a tool, consume an approval, refresh expiration, or generate a notification. Instrument a synthetic state object and verify its version remains unchanged.
Observability Without Turning Logs Into a Leak
Session and run identifiers are attractive correlation keys, but raw values can become the disclosure channel that defeats their unpredictability. Logging guidance should balance investigation with containment.
Record:
- A keyed hash or separately generated internal correlation identifier.
- Authenticated issuer, subject pseudonym, client ID, and tenant identifier under access controls.
- State type and lifecycle transition.
- Requested action and policy decision.
- Distinct internal reason codes for unknown, owner mismatch, expired, revoked, and forbidden states.
- Transport, instance, version, and trace identifier.
Do not record:
- Raw bearer tokens or authorization codes.
- Full cookies or session IDs.
- Tool arguments and model context by default.
- Sensitive state contents merely to explain an authorization failure.
High-signal detections include repeated owner mismatches, one principal presenting handles associated with many owners, access after revocation, unusual state-resume geography, and sudden increases in unknown-handle requests. Rate limits can slow discovery attempts but should not replace authorization.
Incident Response for a State-Binding Failure
When an implementation is found to select state without principal comparison, upgrading is the first containment step, not the final investigation.
Determine the Actual Exposure
Confirm SDK versions, transport modes, authentication configuration, stateful settings, and every deployment instance. Identify whether identifiers could appear in URLs, logs, traces, support bundles, frontend storage, analytics, or third-party integrations. The probability of disclosure affects risk but does not remove the defect.
Establish State Sensitivity
Inventory what a session could expose or change: prompts, model outputs, connected resource metadata, tool results, file artifacts, pending approvals, OAuth state, or executable workflow progress. Different state types may require different notification and recovery decisions.
Search for Cross-Principal Access
Correlate authenticated principal events with state-owner records using protected internal identifiers. Look for owner mismatches, subsequent tool executions, exports, cancellations, or approval changes. Be cautious with absence of evidence if raw request ownership was not logged before the fix.
Invalidate and Re-establish State
If handles may have leaked or ownership cannot be reconstructed, invalidate affected state rather than only relying on the new comparison. Recreate active jobs or approvals under newly authenticated principals. Revoke downstream tokens or artifacts if exposed state could reveal or issue them.
Validate Every Access Path
Use two synthetic users through the real ingress and every supported transport. Confirm the patched system denies cross-principal use, returns non-enumerating responses, creates no side effects, and produces a controlled detection event.
Migrating Toward Stateless MCP
The current protocol direction gives teams an opportunity to remove unnecessary session risk rather than only harden old state.
- Inventory protocol-level state. Identify what the transport stores and why.
- Separate application objects. Convert legitimate long-running work into explicit resources with owners and action policies.
- Authenticate each request. Do not inherit identity from a previous connection or handle.
- Use idempotency where possible. Retries should not require a privileged session object.
- Minimize resumable secrets. Prefer opaque resource identifiers plus ordinary authorization over bearer-like resume tokens.
- Expire compatibility paths. Give older stateful transports a measured deprecation plan and monitor their use.
- Retest isolation. Stateless transport does not automatically fix application-level object authorization.
This migration improves scaling and recovery, but its security value comes from making state ownership explicit. Moving state into a database without adding principal checks simply relocates the same vulnerability.
A Design and Review Checklist
- [ ] Every request is authenticated independently of session, run, task, or conversation identifiers.
- [ ] Every state object records a verified owner tuple at creation.
- [ ] Owner comparison occurs before reads, writes, continuation, approval, cancellation, export, and deletion.
- [ ] Shared OAuth clients use a verified subject when end-user isolation is required.
- [ ] Tenant context is derived from verified membership rather than client input alone.
- [ ] Delegated workflows preserve both workload/client and end-user identity.
- [ ] Current authorization is re-evaluated for sensitive actions.
- [ ] Unknown handles and owner mismatches have indistinguishable external responses.
- [ ] Handles are unpredictable, short-lived, transmitted securely, and absent from routine logs and URLs.
- [ ] Logout, disablement, consent revocation, and incident response invalidate relevant state.
- [ ] Cross-principal tests cover every transport and state action.
- [ ] Denied requests are proven to cause no workflow or tool side effect.
- [ ] Distributed instances use the same canonical principal and authorization rules.
- [ ] New MCP designs follow the current stateless core and justify any application state explicitly.
FAQ
Is an unpredictable MCP session ID safe enough?
No. Unpredictability makes random guessing harder, but an ID can still leak through logs, URLs, browser history, monitoring, or another component. The server must authenticate the request and verify that the current principal owns or is authorized to access the referenced state.
Which deployments were affected by CVE-2026-52869?
The maintainer advisory described authenticated, stateful MCP Python SDK servers using SSE or stateful Streamable HTTP through version 1.27.1. Version 1.27.2 contained the fix. Stdio, stateless Streamable HTTP, and unauthenticated configurations were outside that particular isolation bypass, although they have their own security considerations.
What should an MCP state object be bound to?
Use a canonical tuple of verified identity attributes appropriate to the trust model, commonly issuer, subject, OAuth client or workload identity, and tenant. Client ID alone is not enough when many users share one client, and request-supplied email or tenant headers should not establish ownership.
Does the stateless MCP specification eliminate this risk?
It removes the need for protocol-level sessions in current MCP, which reduces one source of risk. Applications can still create run IDs, jobs, approvals, cursors, conversations, or workspace handles. Those application objects require the same principal-bound authorization.
Should a server return 403 or 404 for an owner mismatch?
Both can deny access, but a not-found response that matches the unknown-handle response often reveals less about another principal's state. Internally, preserve a distinct, access-controlled reason code so defenders can detect cross-principal attempts.
A Valid Handle Should Be Useless to the Wrong Principal
The stable design starts with a canonical principal derived from verified claims and an owner recorded when state is created. Resume, poll, cancel, approve, retry, and delete operations can then compare the caller with that owner while also considering current membership and capability. Where enumeration carries risk, the external response does not need to reveal whether the mismatch was absence or ownership.
In practice, a two-user and two-tenant test with one valid handle copied across identities and lifecycle states gives unusually clear evidence. Stateless MCP designs avoid part of this problem, but application state will still appear around tasks and approvals. When it does, its owner, expiry, revocation behavior, and authorization rule need to be as explicit as the identifier itself.
#MCPSecurity #AISecurity #IdentitySecurity #Authorization #SessionSecurity #TenantIsolation #AgentSecurity
Find issues like this in your own codebase
SecureHup runs this exact exploit chain — discovery, enumeration and cross-tenant validation — on every deployment, automatically.