Skip to main content

Stranger Test

Can user B read user A's data in your AI app? A two-user test that finds out.

PyPI Python License selftest

Tenant isolation testing for LangGraph agent servers, MCP servers and gateways, and LLM semantic caches. It is the two-account access check that a penetration tester does by hand (IDOR / BOLA, cross-tenant access), made repeatable: sign in as two test users and see whether one can read the other's threads, memory, tool state or cached answers.

See it catch a leak, with nothing to set up. This starts two small practice servers on your own machine, one leaky and one safe:

pip install stranger-test
stranger-test confirm agent-memory --demo
-- against a KNOWN-LEAKY server (the test must catch it):
LEAK: another identity reached identity A's memory on 15 of 17 paths: ...
  LEAK           thread_get: B reads A's thread by id (B got HTTP 200)
  LEAK           store_get: B reads A's memory item by namespace and key (B got HTTP 200)
  LEAK           agent_recall: B asks the agent for A's memory (B got HTTP 200)
  ...
-- against a SAFE server (must come back clean):
OK: identity B could not read identity A's memory on any of the 23 exercised paths.
  OK             thread_get: B reads A's thread by id (B got HTTP 404)
  OK             store_get: B reads A's memory item by namespace and key (B got HTTP 403)
  ...
VERDICT: the test WORKS (leaky -> LEAK, safe -> OK, ...)

(Output shortened; ... marks lines left out.) Then point it at a LangGraph server you run, with two test users' tokens:

stranger-test confirm agent-memory http://127.0.0.1:2024 --token-a <A's token> --token-b <B's token>

No sign-in on your dev server yet? Then there are no tokens to give. The guide has a short snippet that adds two test users for local testing: docs/AGENT-MEMORY.md, step 3.

Free, Apache-2.0, standard-library-only Python (3.9+). Test only systems you run or are authorized to test.

How it decides

An AI application keeps many users' data behind one endpoint: in an agent's memory, in an MCP server or gateway, in a cache of model answers. Stranger Test signs in as two test users. User A stores a unique marker, and the test tries each way user B might get it. Each path is graded LEAK, OK or INCONCLUSIVE, and a path is only OK if A could read her own data back first, so a broken test never passes for a safe system.

Two more labels can appear on a path, and neither counts as OK. NOT_RUN means the path needs an input you did not give; the line says which flag adds it. Not exercised means the test's own check for that path did not hold (for example, A could not read her own data that way), so the path was not graded.

What it tests:

  • LangGraph agent memory: threads and the long-term Store, over the LangGraph Server API (confirm agent-memory). Guide: docs/AGENT-MEMORY.md. Results on each new LangGraph server release: docs/LANGGRAPH-RELEASE-CHECKS.md.
  • MCP servers and gateways: a quick single-user scan, and two-user confirm tests for state handles, tasks and elicitation.
  • LLM semantic caches and gateways: exact and similar-question lookups in a response cache (confirm semantic-cache). Shared caches have leaked between customers in production; two public incidents.

Each confirm run can write an evidence page (--evidence): what was tested, by whom, when, each path's result, what was not tested, and how to repeat it. --evidence-summary writes a short summary of the same run, under half the length, to hand to someone who will not read four pages. It supplements an independent penetration test; it does not replace one. See docs/EVIDENCE.md.

Who it is for

  • Security and platform engineers who run a multi-tenant AI product: a tenant isolation check you can run on every release (there is a GitHub Action). "Tenant" here means whatever your system keeps apart: customers, users, teams, API keys, or agents acting for different users. Each is an identity, and the test checks the boundary between two of them.
  • Teams asked to show customer data segregation, by an auditor or in a customer's security review: the evidence file records one dated test run in plain language. Whether it counts toward a control is the auditor's judgement; see what it does and does not prove.
  • Penetration testers who already check this by hand with two accounts: a repeatable version of that test, with a baseline check so that a refusal to the second account means something.

For an MCP server, the quickest start is the read-only scan:

# scan any MCP server you run, in ~30s — no third-party dependencies:
pip install stranger-test
stranger-test scan http://localhost:4600/mcp
# (or, zero-install with pipx: pipx run stranger-test scan http://localhost:4600/mcp)

Why it's different

Most MCP security tools are static: they read config or source and flag risk signals. That's useful — Stranger Test does it too (scan) — but a signal is a thing to look at, not a proven leak. And a single-identity scanner structurally cannot tell you whether identity B can actually reach identity A's data, because it only ever connects as one identity.

Stranger Test adds a dynamic, two-identity confirmation lab (confirm). It connects as A and B, makes the real calls, and grades the result LEAK / OK / INCONCLUSIVE — with a built-in positive control so "no leak" can never be a silently broken test.

Static scanners / guardrails Stranger Test
Flags config/source risk signals ✓ ✓ (scan)
Connects as two identities — ✓
Confirms a cross-user leak dynamically — ✓ (confirm)
Positive control (catches a broken test) — ✓
Explicit INCONCLUSIVE (never a false "clean") — ✓

Guardrails and prompt-firewalls sit in one user's session, so cross-user authority is a permanent blind spot for them. That blind spot is the whole point of this tool.


Scan an MCP server: one user, read-only

pipx run stranger-test scan http://localhost:4600/mcp          # or: pip install stranger-test
stranger-test scan http://localhost:4600/mcp --bearer "$TOKEN" # scan as an authenticated caller
stranger-test scan http://localhost:4600/mcp --sarif > out.sarif

A single read-only pass. It fingerprints the server — transport, protocol version, auth posture, session handling, cache scope, advertised delegation — and flags authorization risk signals by severity. Tokens are fingerprinted (sha256), never printed. It never writes to the target.

  • --json → a {profile, findings} document · --sarif → SARIF 2.1.0 for CI code-scanning.
  • Exit codes drop straight into a CI gate: 0 no signal · 1 ≥1 signal · 2 unreachable.
  • Safe by default: refuses any non-loopback target unless you pass --allow-nonloopback for a server you're authorized to test.

A finding whose class has a confirmer prints the exact confirm command to run next.

Confirm with two users

scan flags a signal; confirm runs a two-identity lab test that proves it LEAK, clears it OK, or returns INCONCLUSIVE. Every test ships a bundled leaky + safe practice server, so --demo proves the test works with no target:

stranger-test confirm --list
stranger-test confirm state-handle --demo          # leaky -> LEAK, safe -> OK
stranger-test confirm state-handle http://127.0.0.1:4600/mcp --token-a <A> --token-b <B>

The seven dynamic cross-user tests (two identities, loopback, fingerprints only):

Test What it proves
state-handle B replays A's server-minted state handle and reaches A's state (the 2026-07-28 stateless core: a handle MUST NOT be treated as authentication)
confused-deputy the server forwards the caller's token to a wrong-audience upstream, or acts with its own authority on an under-scoped request (RFC 8693)
tasks-idor B reads / updates / cancels A's task by id, and whether task ids are enumerable (tasks extension, SEP-2663)
elicitation A starts an elicitation, B completes the authorization — does the grant bind to A? (account takeover); plus secrets requested in form mode
subscriptions B's subscriptions/listen stream receives notifications scoped to A
agent-memory B reads what A saved in an agent server's memory — threads, long-term Store, or by asking the agent. Speaks the LangGraph Server API; give the server's base URL. With prefix-sibling ids it also catches the store namespace-boundary bugs (CVE-2026-71433 / -115883).
semantic-cache B gets the answer a response cache stored for A — by the same question, a reworded one, or from a prefix-sibling id. For a cache with store/query calls, or an LLM gateway that caches chat completions (--cache-mode chat); give the base URL.

agent-memory needs only a running LangGraph server and two test users' tokens; nothing about your agent:

stranger-test confirm agent-memory http://127.0.0.1:2024 --token-a <A> --token-b <B>

Guide, with a copy-paste test-user auth snippet: docs/AGENT-MEMORY.md. Background and results on affected and fixed store versions: docs/LANGGRAPH-MEMORY-ISOLATION.md. Results on each new LangGraph server release: docs/LANGGRAPH-RELEASE-CHECKS.md.

semantic-cache needs a running cache or gateway and two test users' ids or keys:

stranger-test confirm semantic-cache http://127.0.0.1:4000 --cache-mode chat --token-a <A> --token-b <B> --model <model>

Guide, for both kinds of cache: docs/CACHE.md.

Every confirm grade requires provably distinct principals before it will call anything a LEAK — on a server that collapses both callers to one identity it reports OBSERVATION, not a false positive.


Run it on every release (CI)

A leak between users usually arrives with a change: a new handler, a dependency upgrade, a refactor of the auth code. So the check is most useful as a build step. Your job starts the server on the runner's loopback with two test accounts, and the step fails on LEAK.

For a LangGraph server, with the GitHub Action:

- uses: strangertest-labs/stranger-test@v0.4
  with:
    mode: confirm
    test: agent-memory
    url: http://127.0.0.1:2024
    token-a: ${{ secrets.AGENT_TEST_TOKEN_A }}
    token-b: ${{ secrets.AGENT_TEST_TOKEN_B }}
    namespace-a: alice.notes      # a Store namespace user A may write to

Or in any CI system, as a plain command:

pip install stranger-test
stranger-test confirm agent-memory http://127.0.0.1:2024 \
  --token-a "$A" --token-b "$B" --namespace-a alice.notes --write-paths

Exit codes: 0 OK, 1 leak, 2 inconclusive, 3 usage error or refused target. --write-paths adds the update, delete and owner-field paths; it writes throwaway objects, so use a test server. The same pattern works for an MCP server (state-handle, tasks-idor, elicitation) and a response cache (semantic-cache): see docs/CI.md.

The same check is run against each new LangGraph server release with a sample app; the results are in docs/LANGGRAPH-RELEASE-CHECKS.md.

How it works

Every probe is an A/B probe: act as identity A, observe as identity B, and check whether the line between them held.

  • Positive controls. A probe first proves its observer actually works, so that "no leak" cannot be a false negative caused by a broken observer.
  • An explicit inconclusive grade. When the probe cannot observe what it needs — an undecodable delegated token, a stream that will not open, a server too old to carry the channel — it reports inconclusive, distinct from no leak. It never reports a leak it could not actually see, and never calls an unobservable server clean.
  • Authorized-first. Every probe passes the target through an authorization guard before any connection is made (see Scope and safety).
  • Fingerprints only. Tokens and session ids are recorded as sha256 fingerprints, never in the clear.

Transports (strangertest.transports), standard library only: stdio (subprocess, newline-delimited JSON-RPC) and Streamable HTTP (JSON or SSE), including the 2026-07-28 "modern" per-request envelope.

Identity is (issuer, subject), so two users named the same from different providers are never conflated.

Tests against real servers

The scripts in integration/ run the same checks end-to-end against real servers on localhost: a LangGraph server, the official MCP SDK example server, and three gateways (agentgateway, LiteLLM, IBM ContextForge). They need extra dependencies, are not part of python3 -m unittest discover, and skip cleanly when those are absent. The delegation script needs THIN_PORT_BASE=N (it uses ports N to N+3 on 127.0.0.1) and refuses to start without it. Setup guides are in integration/*_GATE.md. Results: docs/RESULTS-SUMMARY.md and integration/RESULTS.md.

Findings

No advisories are published yet; they will be listed here when they are. A passing check on a product covers only that check on that version and is not a verdict on the product.

Scope and safety

Point Stranger Test only at localhost, servers you run, or targets you are explicitly authorized to test. The authorization guard allows local development hosts (loopback, .localhost, .test) automatically and refuses every other target unless you pass explicit authorization recording who permitted the test. There is deliberately no "scan everything" mode: one target, one authorization. Any real finding is for private, responsible disclosure to the server's owner. Do not name-and-shame.

What's new

Version 0.4, maintained by one person. Changes by release are in CHANGELOG.md.

License

Apache-2.0 (see LICENSE).

Metadata

Release files for stranger-test 0.4.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stranger-test 0.4.10
File Size Uploaded Provenance Actions
stranger_test-0.4.10.tar.gz 328.1 kB Without provenance Details for stranger_test-0.4.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stranger-test 0.4.10
File Interpreter ABI Platform Actions
stranger_test-0.4.10-py3-none-any.whl Python 3 none any Details for stranger_test-0.4.10-py3-none-any.whl

Total release size: 590.2 kB

Release files / stranger_test-0.4.10.tar.gz

Download URL stranger_test-0.4.10.tar.gz
Size 328.1 kB
Tags Source
SHA-256 checksum
How to use checksums
faca0c5cd90d3e6790732757ea9b237ad067bc855ee8346486d9684e49bafa75
BLAKE2b-256 checksum
How to use checksums
368c78c5a54034168ea12c298ee529a59a7b279ddd5e63b5f0fffd88442f2c20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / stranger_test-0.4.10-py3-none-any.whl

Download URL stranger_test-0.4.10-py3-none-any.whl
Size 262.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c49b3960f85a3e3e6375906ffae1c63d54293c11830c8bb9aac0159c1c48de4
BLAKE2b-256 checksum
How to use checksums
acce36f446e1cd0efe2b0b64277d31bddfbf42c018ee488083906f1322f1f070
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for stranger-test 0.4.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page