stranger-test 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stranger_test-0.0.1/LICENSE +202 -0
- stranger_test-0.0.1/PKG-INFO +175 -0
- stranger_test-0.0.1/README.md +156 -0
- stranger_test-0.0.1/pyproject.toml +39 -0
- stranger_test-0.0.1/setup.cfg +4 -0
- stranger_test-0.0.1/stranger_test.egg-info/PKG-INFO +175 -0
- stranger_test-0.0.1/stranger_test.egg-info/SOURCES.txt +33 -0
- stranger_test-0.0.1/stranger_test.egg-info/dependency_links.txt +1 -0
- stranger_test-0.0.1/stranger_test.egg-info/entry_points.txt +2 -0
- stranger_test-0.0.1/stranger_test.egg-info/top_level.txt +1 -0
- stranger_test-0.0.1/strangertest/__init__.py +16 -0
- stranger_test-0.0.1/strangertest/__main__.py +3 -0
- stranger_test-0.0.1/strangertest/cli.py +184 -0
- stranger_test-0.0.1/strangertest/delegate.py +335 -0
- stranger_test-0.0.1/strangertest/demo.py +70 -0
- stranger_test-0.0.1/strangertest/guard.py +135 -0
- stranger_test-0.0.1/strangertest/mcp_client.py +304 -0
- stranger_test-0.0.1/strangertest/practice_delegation_http.py +262 -0
- stranger_test-0.0.1/strangertest/practice_http.py +274 -0
- stranger_test-0.0.1/strangertest/practice_server.py +113 -0
- stranger_test-0.0.1/strangertest/probe.py +211 -0
- stranger_test-0.0.1/strangertest/source_audit.py +674 -0
- stranger_test-0.0.1/strangertest/subscribe.py +168 -0
- stranger_test-0.0.1/strangertest/transports.py +535 -0
- stranger_test-0.0.1/tests/test_cli.py +69 -0
- stranger_test-0.0.1/tests/test_delegate.py +222 -0
- stranger_test-0.0.1/tests/test_delegate_http.py +116 -0
- stranger_test-0.0.1/tests/test_guard.py +93 -0
- stranger_test-0.0.1/tests/test_http.py +158 -0
- stranger_test-0.0.1/tests/test_mcp_client.py +148 -0
- stranger_test-0.0.1/tests/test_probe.py +170 -0
- stranger_test-0.0.1/tests/test_protocol.py +44 -0
- stranger_test-0.0.1/tests/test_source_audit.py +233 -0
- stranger_test-0.0.1/tests/test_subscribe.py +172 -0
- stranger_test-0.0.1/tests/test_subscribe_http.py +102 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Vedant Agarwal
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: stranger-test
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Tests MCP servers for cross-identity and delegated-authority (RFC 8693) authorization leaks.
|
|
5
|
+
Author: Vedant Agarwal
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Keywords: mcp,model-context-protocol,security,authorization,confused-deputy
|
|
8
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Topic :: Security
|
|
14
|
+
Classifier: Topic :: Software Development :: Testing
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# Stranger Test
|
|
21
|
+
|
|
22
|
+
Stranger Test is a free, standard-library-only Python tool and library for
|
|
23
|
+
testing **MCP (Model Context Protocol) servers** for cross-identity and
|
|
24
|
+
delegated-authority authorization leaks.
|
|
25
|
+
|
|
26
|
+
An MCP server is a trusted middleman that usually holds many users' credentials
|
|
27
|
+
and data. The question Stranger Test asks is simple: can one identity's data,
|
|
28
|
+
events, or authority reach another identity through the server? We organise
|
|
29
|
+
these failures into a taxonomy of 14 **XID** leak classes, and build detection
|
|
30
|
+
ahead of a class becoming common rather than after. Two of the earliest-built
|
|
31
|
+
detectors are:
|
|
32
|
+
|
|
33
|
+
- **XID-13** — cross-identity subscription/notification leak.
|
|
34
|
+
- **XID-10** — delegation dropped or forged: the on-behalf-of / token-exchange
|
|
35
|
+
confused-deputy problem.
|
|
36
|
+
|
|
37
|
+
## Try it
|
|
38
|
+
|
|
39
|
+
See a leak caught in under a minute, with no third-party dependencies. This
|
|
40
|
+
starts the bundled practice MCP subscription server on a loopback port and runs
|
|
41
|
+
the XID-13 subscription probe against it — first in `leaky` mode, then in `safe`
|
|
42
|
+
mode. From the repository root, with plain system Python:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
python3 -m strangertest.demo
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
In `leaky` mode, identity B hears identity A's resource update — a leak:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Subscription-leak probe (XID-13) against the bundled practice server.
|
|
52
|
+
B subscribes to A's resource; A changes it; did B hear about it?
|
|
53
|
+
|
|
54
|
+
[leaky] LEAK: identity 'B' received update notifications for 'note://alice/secret', a resource owned by identity 'A' — cross-identity subscription/notification leak.
|
|
55
|
+
[safe] OK: identity 'B' received no notifications for 'A''s resource 'note://alice/secret'.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The `leaky` line is the detection; the `safe` line is the same probe reporting a
|
|
59
|
+
correctly-scoped server clean.
|
|
60
|
+
|
|
61
|
+
## How it works
|
|
62
|
+
|
|
63
|
+
Every probe is an **A/B probe**: act as identity **A**, observe as identity
|
|
64
|
+
**B**, and check whether the line between them held.
|
|
65
|
+
|
|
66
|
+
- **Positive controls.** A probe first proves its observer actually works, so
|
|
67
|
+
that "no leak" cannot be a false negative caused by a broken observer.
|
|
68
|
+
- **An explicit `inconclusive` grade.** When the probe cannot observe what it
|
|
69
|
+
needs — an undecodable delegated token, a stream that will not open, a server
|
|
70
|
+
too old to carry the channel — it reports *inconclusive*, which is distinct
|
|
71
|
+
from *no leak*. It never reports a leak it could not actually see, and never
|
|
72
|
+
calls an unobservable server clean.
|
|
73
|
+
- **Authorized-first.** Every probe passes the target through an authorization
|
|
74
|
+
guard before any connection is made (see *Scope and safety* below).
|
|
75
|
+
|
|
76
|
+
The three probes:
|
|
77
|
+
|
|
78
|
+
1. **Read probe** (`strangertest.probe`) — A plants a uniquely-marked record;
|
|
79
|
+
B tries to read it back. If B sees A's marker, authority crossed identities.
|
|
80
|
+
2. **Subscription probe / XID-13** (`strangertest.subscribe`) — B opens a
|
|
81
|
+
subscription stream on a resource owned by A; A then changes it. If B
|
|
82
|
+
receives an update notification for A's resource, one identity's events
|
|
83
|
+
reached another. Detection is exact-URI, exact-method — not a substring
|
|
84
|
+
search — and the stream is opened and acknowledged *before* A acts, because
|
|
85
|
+
the channel does not replay.
|
|
86
|
+
3. **Delegation probe / XID-10** (`strangertest.delegate`) — the server acts
|
|
87
|
+
on behalf of a user against an upstream you control. The probe drives it as
|
|
88
|
+
A, then B, then A again (the second A call catches a deputy that cached or
|
|
89
|
+
bled B's token into A's request) and inspects what reached the upstream:
|
|
90
|
+
subject preserved, acting agent present, audience correct, scope narrowed,
|
|
91
|
+
a distinct token per principal, and no cross-identity bleed. Identity is
|
|
92
|
+
`(issuer, subject)`, so two users named the same from different providers
|
|
93
|
+
are not conflated.
|
|
94
|
+
|
|
95
|
+
**Transports** (`strangertest.transports`), standard library only: **stdio**
|
|
96
|
+
(subprocess, newline-delimited JSON-RPC) and **Streamable HTTP** (JSON or SSE),
|
|
97
|
+
including the 2026-07-28 "modern" per-request envelope.
|
|
98
|
+
|
|
99
|
+
## Install and run
|
|
100
|
+
|
|
101
|
+
Requires Python 3.9+. The core library and unit tests use the standard library
|
|
102
|
+
only — no third-party dependencies.
|
|
103
|
+
|
|
104
|
+
Unit tests, from the repository root:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
python3 -m unittest discover
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
(106 tests.)
|
|
111
|
+
|
|
112
|
+
## Integration gates
|
|
113
|
+
|
|
114
|
+
The integration "gates" in `integration/` exercise the probes end-to-end
|
|
115
|
+
against real servers. They need extra dependencies (`pyjwt[crypto]`, plus the
|
|
116
|
+
target server itself), are **not** run by `python3 -m unittest discover`, and
|
|
117
|
+
skip cleanly when their dependencies are absent.
|
|
118
|
+
|
|
119
|
+
- **XID-13 subscription gate** — drives the subscription probe against the
|
|
120
|
+
official MCP SDK subscriptions example server.
|
|
121
|
+
- **XID-10 thin-deputy gate** (`integration/xid10_thin_deputy_gate.py`) — runs
|
|
122
|
+
the delegation probe over a real RFC 8693 token exchange against a set of
|
|
123
|
+
deliberately-broken deputy fixtures: `static_credential`, `token_passthrough`,
|
|
124
|
+
`cached_token_reuse`, and a conflated-issuer case. Each is a known leak the
|
|
125
|
+
probe must flag, for the right reason.
|
|
126
|
+
- **XID-10 ContextForge gate** (`integration/xid10_contextforge_gate.py`) —
|
|
127
|
+
drives the delegation probe through a real IBM ContextForge gateway doing
|
|
128
|
+
RFC 8693 token exchange. Configured by `XID10_MODE`
|
|
129
|
+
(`delegation` | `impersonation` | `two_issuers`) and `XID10_TRIGGER`
|
|
130
|
+
(`tool` | `resource`).
|
|
131
|
+
- **XID-10 agentgateway gate** (`integration/xid10_agentgateway_gate.py`) —
|
|
132
|
+
drives the same delegation probe, same six checks and scenarios, through a
|
|
133
|
+
second, unrelated third-party gateway: **agentgateway v1.7.0** (the official
|
|
134
|
+
release binary, configured by its config file only). A second gateway so the
|
|
135
|
+
probe's behaviour is not tied to any one implementation.
|
|
136
|
+
|
|
137
|
+
The setup recipes are in
|
|
138
|
+
[`integration/CONTEXTFORGE_GATE.md`](integration/CONTEXTFORGE_GATE.md) and
|
|
139
|
+
[`integration/AGENTGATEWAY_GATE.md`](integration/AGENTGATEWAY_GATE.md).
|
|
140
|
+
Everything in the gates runs on localhost only.
|
|
141
|
+
|
|
142
|
+
## A sample result
|
|
143
|
+
|
|
144
|
+
Run against a real **IBM ContextForge 1.1.1** gateway (macOS, Python 3.13); the
|
|
145
|
+
same scenarios run against **agentgateway v1.7.0** with the same results:
|
|
146
|
+
|
|
147
|
+
- **Faithful delegation** grades clean — all checks pass.
|
|
148
|
+
- **Impersonation** (no actor token) is flagged, because the exchanged token
|
|
149
|
+
carries no acting-agent `act` claim, so the agent acting for the user is
|
|
150
|
+
invisible.
|
|
151
|
+
- **Two issuers** — two users both named `alice` from different providers are
|
|
152
|
+
kept distinct through the exchange (distinct tokens, no cross-identity reuse);
|
|
153
|
+
no conflation.
|
|
154
|
+
|
|
155
|
+
To be clear about what this does and does not show: **no vulnerability was found
|
|
156
|
+
in either gateway.** The probe's ability to *detect* leaks is demonstrated by the
|
|
157
|
+
deliberately-broken thin-deputy fixtures above, each of which the probe flags.
|
|
158
|
+
A comparison against the older **1.0.6** release (to check a since-fixed
|
|
159
|
+
historical behaviour) is noted as **future work** and has not yet been run.
|
|
160
|
+
|
|
161
|
+
## Scope and safety
|
|
162
|
+
|
|
163
|
+
Point Stranger Test only at **localhost, servers you run, or targets you are
|
|
164
|
+
explicitly authorized to test.** The authorization guard allows local
|
|
165
|
+
development hosts (loopback, `.localhost`, `.test`) automatically and refuses
|
|
166
|
+
every other target unless you pass explicit authorization recording who
|
|
167
|
+
permitted the test. There is deliberately no "scan everything" mode: one target,
|
|
168
|
+
one authorization.
|
|
169
|
+
|
|
170
|
+
Any real finding is for **private, responsible disclosure** to the server's
|
|
171
|
+
owner. Do not name-and-shame.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
Apache-2.0 (see `LICENSE`).
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Stranger Test
|
|
2
|
+
|
|
3
|
+
Stranger Test is a free, standard-library-only Python tool and library for
|
|
4
|
+
testing **MCP (Model Context Protocol) servers** for cross-identity and
|
|
5
|
+
delegated-authority authorization leaks.
|
|
6
|
+
|
|
7
|
+
An MCP server is a trusted middleman that usually holds many users' credentials
|
|
8
|
+
and data. The question Stranger Test asks is simple: can one identity's data,
|
|
9
|
+
events, or authority reach another identity through the server? We organise
|
|
10
|
+
these failures into a taxonomy of 14 **XID** leak classes, and build detection
|
|
11
|
+
ahead of a class becoming common rather than after. Two of the earliest-built
|
|
12
|
+
detectors are:
|
|
13
|
+
|
|
14
|
+
- **XID-13** — cross-identity subscription/notification leak.
|
|
15
|
+
- **XID-10** — delegation dropped or forged: the on-behalf-of / token-exchange
|
|
16
|
+
confused-deputy problem.
|
|
17
|
+
|
|
18
|
+
## Try it
|
|
19
|
+
|
|
20
|
+
See a leak caught in under a minute, with no third-party dependencies. This
|
|
21
|
+
starts the bundled practice MCP subscription server on a loopback port and runs
|
|
22
|
+
the XID-13 subscription probe against it — first in `leaky` mode, then in `safe`
|
|
23
|
+
mode. From the repository root, with plain system Python:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
python3 -m strangertest.demo
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
In `leaky` mode, identity B hears identity A's resource update — a leak:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
Subscription-leak probe (XID-13) against the bundled practice server.
|
|
33
|
+
B subscribes to A's resource; A changes it; did B hear about it?
|
|
34
|
+
|
|
35
|
+
[leaky] LEAK: identity 'B' received update notifications for 'note://alice/secret', a resource owned by identity 'A' — cross-identity subscription/notification leak.
|
|
36
|
+
[safe] OK: identity 'B' received no notifications for 'A''s resource 'note://alice/secret'.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The `leaky` line is the detection; the `safe` line is the same probe reporting a
|
|
40
|
+
correctly-scoped server clean.
|
|
41
|
+
|
|
42
|
+
## How it works
|
|
43
|
+
|
|
44
|
+
Every probe is an **A/B probe**: act as identity **A**, observe as identity
|
|
45
|
+
**B**, and check whether the line between them held.
|
|
46
|
+
|
|
47
|
+
- **Positive controls.** A probe first proves its observer actually works, so
|
|
48
|
+
that "no leak" cannot be a false negative caused by a broken observer.
|
|
49
|
+
- **An explicit `inconclusive` grade.** When the probe cannot observe what it
|
|
50
|
+
needs — an undecodable delegated token, a stream that will not open, a server
|
|
51
|
+
too old to carry the channel — it reports *inconclusive*, which is distinct
|
|
52
|
+
from *no leak*. It never reports a leak it could not actually see, and never
|
|
53
|
+
calls an unobservable server clean.
|
|
54
|
+
- **Authorized-first.** Every probe passes the target through an authorization
|
|
55
|
+
guard before any connection is made (see *Scope and safety* below).
|
|
56
|
+
|
|
57
|
+
The three probes:
|
|
58
|
+
|
|
59
|
+
1. **Read probe** (`strangertest.probe`) — A plants a uniquely-marked record;
|
|
60
|
+
B tries to read it back. If B sees A's marker, authority crossed identities.
|
|
61
|
+
2. **Subscription probe / XID-13** (`strangertest.subscribe`) — B opens a
|
|
62
|
+
subscription stream on a resource owned by A; A then changes it. If B
|
|
63
|
+
receives an update notification for A's resource, one identity's events
|
|
64
|
+
reached another. Detection is exact-URI, exact-method — not a substring
|
|
65
|
+
search — and the stream is opened and acknowledged *before* A acts, because
|
|
66
|
+
the channel does not replay.
|
|
67
|
+
3. **Delegation probe / XID-10** (`strangertest.delegate`) — the server acts
|
|
68
|
+
on behalf of a user against an upstream you control. The probe drives it as
|
|
69
|
+
A, then B, then A again (the second A call catches a deputy that cached or
|
|
70
|
+
bled B's token into A's request) and inspects what reached the upstream:
|
|
71
|
+
subject preserved, acting agent present, audience correct, scope narrowed,
|
|
72
|
+
a distinct token per principal, and no cross-identity bleed. Identity is
|
|
73
|
+
`(issuer, subject)`, so two users named the same from different providers
|
|
74
|
+
are not conflated.
|
|
75
|
+
|
|
76
|
+
**Transports** (`strangertest.transports`), standard library only: **stdio**
|
|
77
|
+
(subprocess, newline-delimited JSON-RPC) and **Streamable HTTP** (JSON or SSE),
|
|
78
|
+
including the 2026-07-28 "modern" per-request envelope.
|
|
79
|
+
|
|
80
|
+
## Install and run
|
|
81
|
+
|
|
82
|
+
Requires Python 3.9+. The core library and unit tests use the standard library
|
|
83
|
+
only — no third-party dependencies.
|
|
84
|
+
|
|
85
|
+
Unit tests, from the repository root:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
python3 -m unittest discover
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
(106 tests.)
|
|
92
|
+
|
|
93
|
+
## Integration gates
|
|
94
|
+
|
|
95
|
+
The integration "gates" in `integration/` exercise the probes end-to-end
|
|
96
|
+
against real servers. They need extra dependencies (`pyjwt[crypto]`, plus the
|
|
97
|
+
target server itself), are **not** run by `python3 -m unittest discover`, and
|
|
98
|
+
skip cleanly when their dependencies are absent.
|
|
99
|
+
|
|
100
|
+
- **XID-13 subscription gate** — drives the subscription probe against the
|
|
101
|
+
official MCP SDK subscriptions example server.
|
|
102
|
+
- **XID-10 thin-deputy gate** (`integration/xid10_thin_deputy_gate.py`) — runs
|
|
103
|
+
the delegation probe over a real RFC 8693 token exchange against a set of
|
|
104
|
+
deliberately-broken deputy fixtures: `static_credential`, `token_passthrough`,
|
|
105
|
+
`cached_token_reuse`, and a conflated-issuer case. Each is a known leak the
|
|
106
|
+
probe must flag, for the right reason.
|
|
107
|
+
- **XID-10 ContextForge gate** (`integration/xid10_contextforge_gate.py`) —
|
|
108
|
+
drives the delegation probe through a real IBM ContextForge gateway doing
|
|
109
|
+
RFC 8693 token exchange. Configured by `XID10_MODE`
|
|
110
|
+
(`delegation` | `impersonation` | `two_issuers`) and `XID10_TRIGGER`
|
|
111
|
+
(`tool` | `resource`).
|
|
112
|
+
- **XID-10 agentgateway gate** (`integration/xid10_agentgateway_gate.py`) —
|
|
113
|
+
drives the same delegation probe, same six checks and scenarios, through a
|
|
114
|
+
second, unrelated third-party gateway: **agentgateway v1.7.0** (the official
|
|
115
|
+
release binary, configured by its config file only). A second gateway so the
|
|
116
|
+
probe's behaviour is not tied to any one implementation.
|
|
117
|
+
|
|
118
|
+
The setup recipes are in
|
|
119
|
+
[`integration/CONTEXTFORGE_GATE.md`](integration/CONTEXTFORGE_GATE.md) and
|
|
120
|
+
[`integration/AGENTGATEWAY_GATE.md`](integration/AGENTGATEWAY_GATE.md).
|
|
121
|
+
Everything in the gates runs on localhost only.
|
|
122
|
+
|
|
123
|
+
## A sample result
|
|
124
|
+
|
|
125
|
+
Run against a real **IBM ContextForge 1.1.1** gateway (macOS, Python 3.13); the
|
|
126
|
+
same scenarios run against **agentgateway v1.7.0** with the same results:
|
|
127
|
+
|
|
128
|
+
- **Faithful delegation** grades clean — all checks pass.
|
|
129
|
+
- **Impersonation** (no actor token) is flagged, because the exchanged token
|
|
130
|
+
carries no acting-agent `act` claim, so the agent acting for the user is
|
|
131
|
+
invisible.
|
|
132
|
+
- **Two issuers** — two users both named `alice` from different providers are
|
|
133
|
+
kept distinct through the exchange (distinct tokens, no cross-identity reuse);
|
|
134
|
+
no conflation.
|
|
135
|
+
|
|
136
|
+
To be clear about what this does and does not show: **no vulnerability was found
|
|
137
|
+
in either gateway.** The probe's ability to *detect* leaks is demonstrated by the
|
|
138
|
+
deliberately-broken thin-deputy fixtures above, each of which the probe flags.
|
|
139
|
+
A comparison against the older **1.0.6** release (to check a since-fixed
|
|
140
|
+
historical behaviour) is noted as **future work** and has not yet been run.
|
|
141
|
+
|
|
142
|
+
## Scope and safety
|
|
143
|
+
|
|
144
|
+
Point Stranger Test only at **localhost, servers you run, or targets you are
|
|
145
|
+
explicitly authorized to test.** The authorization guard allows local
|
|
146
|
+
development hosts (loopback, `.localhost`, `.test`) automatically and refuses
|
|
147
|
+
every other target unless you pass explicit authorization recording who
|
|
148
|
+
permitted the test. There is deliberately no "scan everything" mode: one target,
|
|
149
|
+
one authorization.
|
|
150
|
+
|
|
151
|
+
Any real finding is for **private, responsible disclosure** to the server's
|
|
152
|
+
owner. Do not name-and-shame.
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
Apache-2.0 (see `LICENSE`).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "stranger-test"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Tests MCP servers for cross-identity and delegated-authority (RFC 8693) authorization leaks."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Vedant Agarwal" }]
|
|
14
|
+
keywords = [
|
|
15
|
+
"mcp",
|
|
16
|
+
"model-context-protocol",
|
|
17
|
+
"security",
|
|
18
|
+
"authorization",
|
|
19
|
+
"confused-deputy",
|
|
20
|
+
]
|
|
21
|
+
dependencies = []
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
24
|
+
"Environment :: Console",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3.9",
|
|
28
|
+
"Topic :: Security",
|
|
29
|
+
"Topic :: Software Development :: Testing",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
strangertest = "strangertest.cli:main"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools]
|
|
36
|
+
packages = ["strangertest"]
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.dynamic]
|
|
39
|
+
version = { attr = "strangertest.__version__" }
|