mcp-calchas 0.1.0__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.
- mcp_calchas-0.1.0/LICENSE +202 -0
- mcp_calchas-0.1.0/PKG-INFO +185 -0
- mcp_calchas-0.1.0/README.md +151 -0
- mcp_calchas-0.1.0/calchas/__about__.py +19 -0
- mcp_calchas-0.1.0/calchas/__init__.py +0 -0
- mcp_calchas-0.1.0/calchas/catalog.py +208 -0
- mcp_calchas-0.1.0/calchas/cli/__init__.py +5 -0
- mcp_calchas-0.1.0/calchas/cli/console.py +341 -0
- mcp_calchas-0.1.0/calchas/cli/events.py +113 -0
- mcp_calchas-0.1.0/calchas/cli/main.py +477 -0
- mcp_calchas-0.1.0/calchas/config.py +108 -0
- mcp_calchas-0.1.0/calchas/driver.py +195 -0
- mcp_calchas-0.1.0/calchas/gateway.py +133 -0
- mcp_calchas-0.1.0/calchas/llm_config.py +132 -0
- mcp_calchas-0.1.0/calchas/llm_failover.py +160 -0
- mcp_calchas-0.1.0/calchas/llmclient.py +15 -0
- mcp_calchas-0.1.0/calchas/oracle/__init__.py +7 -0
- mcp_calchas-0.1.0/calchas/oracle/core.py +66 -0
- mcp_calchas-0.1.0/calchas/oracle/fingerprint.py +79 -0
- mcp_calchas-0.1.0/calchas/oracle/oob.py +52 -0
- mcp_calchas-0.1.0/calchas/oracle/probe.py +47 -0
- mcp_calchas-0.1.0/calchas/oracle/reflection.py +27 -0
- mcp_calchas-0.1.0/calchas/oracle/verdict.py +33 -0
- mcp_calchas-0.1.0/calchas/orchestrator/__init__.py +7 -0
- mcp_calchas-0.1.0/calchas/orchestrator/agent.py +317 -0
- mcp_calchas-0.1.0/calchas/orchestrator/core.py +368 -0
- mcp_calchas-0.1.0/calchas/orchestrator/executor.py +698 -0
- mcp_calchas-0.1.0/calchas/orchestrator/extract.py +64 -0
- mcp_calchas-0.1.0/calchas/orchestrator/planner.py +129 -0
- mcp_calchas-0.1.0/calchas/orchestrator/types.py +45 -0
- mcp_calchas-0.1.0/calchas/payload/__init__.py +6 -0
- mcp_calchas-0.1.0/calchas/payload/batteries.py +327 -0
- mcp_calchas-0.1.0/calchas/payload/core.py +117 -0
- mcp_calchas-0.1.0/calchas/payload/types.py +32 -0
- mcp_calchas-0.1.0/calchas/report.py +142 -0
- mcp_calchas-0.1.0/calchas/run.py +268 -0
- mcp_calchas-0.1.0/calchas/selftest.py +34 -0
- mcp_calchas-0.1.0/calchas/sink/__init__.py +7 -0
- mcp_calchas-0.1.0/calchas/sink/core.py +117 -0
- mcp_calchas-0.1.0/calchas/sink/llm.py +133 -0
- mcp_calchas-0.1.0/calchas/sink/rules.py +47 -0
- mcp_calchas-0.1.0/calchas/sink/types.py +77 -0
- mcp_calchas-0.1.0/calchas/targetcfg.py +14 -0
- mcp_calchas-0.1.0/calchas/valuegen.py +221 -0
- mcp_calchas-0.1.0/mcp_calchas.egg-info/PKG-INFO +185 -0
- mcp_calchas-0.1.0/mcp_calchas.egg-info/SOURCES.txt +50 -0
- mcp_calchas-0.1.0/mcp_calchas.egg-info/dependency_links.txt +1 -0
- mcp_calchas-0.1.0/mcp_calchas.egg-info/entry_points.txt +2 -0
- mcp_calchas-0.1.0/mcp_calchas.egg-info/requires.txt +7 -0
- mcp_calchas-0.1.0/mcp_calchas.egg-info/top_level.txt +1 -0
- mcp_calchas-0.1.0/pyproject.toml +57 -0
- mcp_calchas-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-calchas
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Black-box injection vulnerability detection for MCP (Model Context Protocol) servers
|
|
5
|
+
Author: liutongzhao
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/liutongzhao/mcpfuzz
|
|
8
|
+
Project-URL: Repository, https://github.com/liutongzhao/mcpfuzz
|
|
9
|
+
Project-URL: Issues, https://github.com/liutongzhao/mcpfuzz/issues
|
|
10
|
+
Keywords: mcp,model-context-protocol,security,vulnerability,injection,black-box,scanner,ssrf,command-injection,path-traversal
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Topic :: Software Development :: Testing
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: mcp<2,>=1.30
|
|
27
|
+
Requires-Dist: httpx<1,>=0.27
|
|
28
|
+
Requires-Dist: rich<16,>=13
|
|
29
|
+
Requires-Dist: langgraph<2,>=1.2
|
|
30
|
+
Requires-Dist: langchain-core<2,>=1.0
|
|
31
|
+
Requires-Dist: langchain-openai<2,>=1.0
|
|
32
|
+
Requires-Dist: langchain-mcp-adapters<0.4,>=0.3
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# Calchas
|
|
36
|
+
|
|
37
|
+
**Black-box injection vulnerability detection for MCP (Model Context Protocol) servers.**
|
|
38
|
+
|
|
39
|
+
Calchas connects to an MCP server over Streamable HTTP, reads its `tools/list`, and tests every tool
|
|
40
|
+
parameter for server-side injection flaws — without source code, instrumentation, or knowledge of the
|
|
41
|
+
server's implementation language. A finding is only *confirmed* when the server's response (or an
|
|
42
|
+
out-of-band callback) shows that the injected payload was actually executed.
|
|
43
|
+
|
|
44
|
+
Supported vulnerability classes:
|
|
45
|
+
|
|
46
|
+
| Class | Example sink |
|
|
47
|
+
|---|---|
|
|
48
|
+
| Command injection | `subprocess(..., shell=True)` |
|
|
49
|
+
| Argument injection | user value reaching an argv option (`git --upload-pack=...`) |
|
|
50
|
+
| Path traversal | file read/write outside the intended root |
|
|
51
|
+
| SSRF | server-side fetch of an attacker-chosen URL |
|
|
52
|
+
| Code injection | `eval` / template / expression evaluation |
|
|
53
|
+
|
|
54
|
+
> **Authorized use only.** `calchas scan` sends real attack payloads (command, path, SSRF and code
|
|
55
|
+
> payloads, file writes, out-of-band callbacks). Run it only against servers you own or are explicitly
|
|
56
|
+
> permitted to test.
|
|
57
|
+
|
|
58
|
+
## How it works
|
|
59
|
+
|
|
60
|
+
1. **Semantic parameter classification** — each parameter's name, description and JSON Schema are
|
|
61
|
+
classified (rules + LLM) into the injection classes it may reach.
|
|
62
|
+
2. **Execution-guided sequence construction** — tools that cannot be called standalone are brought into a
|
|
63
|
+
callable state by an agent that builds the prerequisite call sequence from benign values.
|
|
64
|
+
3. **Execution-confirmation oracle** — payloads are paired with benign controls and judged through
|
|
65
|
+
in-band reflection, timing, cross-tool read-back and (optionally) out-of-band callbacks; only the
|
|
66
|
+
*difference* between attack and control counts as evidence.
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
Requires Python ≥ 3.11. `curl` must be on `PATH` when LLM features are used.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pipx install mcp-calchas # recommended for a CLI tool (isolated environment)
|
|
74
|
+
# or
|
|
75
|
+
pip install mcp-calchas
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The distribution is called `mcp-calchas`; the command and the Python package are `calchas`.
|
|
79
|
+
|
|
80
|
+
## Quick start
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# 1. Preview the attack surface only (no payloads sent)
|
|
84
|
+
calchas recon http://localhost:8080/mcp --no-llm-sink --no-agent --no-llm-plan
|
|
85
|
+
|
|
86
|
+
# 2. Full scan with an OpenAI-compatible LLM
|
|
87
|
+
export CALCHAS_LLM_API_KEY=sk-...
|
|
88
|
+
calchas scan http://localhost:8080/mcp \
|
|
89
|
+
--llm-base-url https://api.openai.com/v1 --llm-model gpt-4o
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Results are written to `./runs/<timestamp>__<server>/` in the current directory (`runs/latest` points to
|
|
93
|
+
the most recent run). Change the location with `-o DIR`.
|
|
94
|
+
|
|
95
|
+
| File | Content |
|
|
96
|
+
|---|---|
|
|
97
|
+
| `report.md` | human-readable report |
|
|
98
|
+
| `findings.json` | machine-readable findings |
|
|
99
|
+
| `catalog.json` | tools and parameters returned by `tools/list` |
|
|
100
|
+
| `sinks.json` | per-parameter injection-class classification |
|
|
101
|
+
| `events.jsonl` | full event log of the run |
|
|
102
|
+
|
|
103
|
+
Re-render a report later with `calchas report runs/latest/findings.json runs/latest/catalog.json`.
|
|
104
|
+
|
|
105
|
+
## Configuring the LLM
|
|
106
|
+
|
|
107
|
+
No model is bundled. LLM features (parameter classification, sequence agent, planning) need an
|
|
108
|
+
OpenAI-compatible chat-completions endpoint, configured in one of three ways:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# command line (the key may also come from $CALCHAS_LLM_API_KEY)
|
|
112
|
+
calchas scan <url> --llm-base-url https://api.example.com/v1 --llm-api-key sk-... --llm-model my-model
|
|
113
|
+
|
|
114
|
+
# provider file, with automatic failover in listed order
|
|
115
|
+
calchas scan <url> --llm-config providers.json
|
|
116
|
+
|
|
117
|
+
# no LLM at all (rule-based classification, single-call plans)
|
|
118
|
+
calchas scan <url> --no-llm-sink --no-agent --no-llm-plan
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`--llm-base-url` accepts either `.../v1` or the full `.../v1/chat/completions` URL.
|
|
122
|
+
|
|
123
|
+
`providers.json`:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"providers": [
|
|
128
|
+
{"name": "primary", "base_url": "https://api.example.com/v1", "api_key": "env:MY_KEY", "model": "model-a"},
|
|
129
|
+
{"name": "backup", "base_url": "https://api.other.com/v1", "api_key": "sk-...", "model": "model-b"}
|
|
130
|
+
],
|
|
131
|
+
"agent_provider": "primary"
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`"api_key": "env:VAR"` reads the key from environment variable `VAR`. An optional `"extra_body"` object is
|
|
136
|
+
merged into every request to that provider, for provider-specific switches — for example
|
|
137
|
+
`"extra_body": {"enable_thinking": false}` turns off the default reasoning mode of Qwen3-series models.
|
|
138
|
+
|
|
139
|
+
## Out-of-band (OOB) channel
|
|
140
|
+
|
|
141
|
+
Blind SSRF and blind command execution are confirmed by an out-of-band callback. The OOB channel is
|
|
142
|
+
**off by default**; enable it by pointing Calchas at a collector the target can reach:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
calchas scan <url> --oob-callback http://<collector-ip>:9100
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The collector must record any request to `/<token>` and report hits as JSON at `/__hits`
|
|
149
|
+
(override with `--oob-query`). A standard-library reference implementation is in the repository at
|
|
150
|
+
`deploy/infra/oob/collector.py`. Without OOB, Calchas still detects and confirms through in-band
|
|
151
|
+
reflection, timing and read-back channels.
|
|
152
|
+
|
|
153
|
+
## Common options
|
|
154
|
+
|
|
155
|
+
| Option | Purpose |
|
|
156
|
+
|---|---|
|
|
157
|
+
| `--header 'Authorization: Bearer ...'` | add HTTP headers (repeatable) |
|
|
158
|
+
| `--tool NAME` / `--exclude-tool NAME` | limit which tools are tested |
|
|
159
|
+
| `--sink command_injection` | limit which vulnerability classes are tested |
|
|
160
|
+
| `--batch FILE --batch-name NAME` | scan many targets; writes `batch_summary.md` |
|
|
161
|
+
| `--yes` | skip the interactive confirmation (needed for batch/CI) |
|
|
162
|
+
| `--format json` | machine-readable console output |
|
|
163
|
+
|
|
164
|
+
Run `calchas scan --help` for the full list.
|
|
165
|
+
|
|
166
|
+
## Repository layout
|
|
167
|
+
|
|
168
|
+
| Path | Content |
|
|
169
|
+
|---|---|
|
|
170
|
+
| `calchas/` | the tool (the only code shipped in the PyPI package) |
|
|
171
|
+
| `dev/` | developer debugging scripts |
|
|
172
|
+
| `deploy/` | experiment infrastructure: batch-scan docker-compose cells, OOB collector, frozen batch records |
|
|
173
|
+
| `dataset/` | vulnerability-dataset pipeline (CVE/GHSA/OSV collection and labeling) |
|
|
174
|
+
| `docs/`, `research_notes/` | design notes and related-work surveys |
|
|
175
|
+
|
|
176
|
+
## Development
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
python3 -m venv .venv && .venv/bin/pip install -e .
|
|
180
|
+
.venv/bin/calchas selftest
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
Apache-2.0
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Calchas
|
|
2
|
+
|
|
3
|
+
**Black-box injection vulnerability detection for MCP (Model Context Protocol) servers.**
|
|
4
|
+
|
|
5
|
+
Calchas connects to an MCP server over Streamable HTTP, reads its `tools/list`, and tests every tool
|
|
6
|
+
parameter for server-side injection flaws — without source code, instrumentation, or knowledge of the
|
|
7
|
+
server's implementation language. A finding is only *confirmed* when the server's response (or an
|
|
8
|
+
out-of-band callback) shows that the injected payload was actually executed.
|
|
9
|
+
|
|
10
|
+
Supported vulnerability classes:
|
|
11
|
+
|
|
12
|
+
| Class | Example sink |
|
|
13
|
+
|---|---|
|
|
14
|
+
| Command injection | `subprocess(..., shell=True)` |
|
|
15
|
+
| Argument injection | user value reaching an argv option (`git --upload-pack=...`) |
|
|
16
|
+
| Path traversal | file read/write outside the intended root |
|
|
17
|
+
| SSRF | server-side fetch of an attacker-chosen URL |
|
|
18
|
+
| Code injection | `eval` / template / expression evaluation |
|
|
19
|
+
|
|
20
|
+
> **Authorized use only.** `calchas scan` sends real attack payloads (command, path, SSRF and code
|
|
21
|
+
> payloads, file writes, out-of-band callbacks). Run it only against servers you own or are explicitly
|
|
22
|
+
> permitted to test.
|
|
23
|
+
|
|
24
|
+
## How it works
|
|
25
|
+
|
|
26
|
+
1. **Semantic parameter classification** — each parameter's name, description and JSON Schema are
|
|
27
|
+
classified (rules + LLM) into the injection classes it may reach.
|
|
28
|
+
2. **Execution-guided sequence construction** — tools that cannot be called standalone are brought into a
|
|
29
|
+
callable state by an agent that builds the prerequisite call sequence from benign values.
|
|
30
|
+
3. **Execution-confirmation oracle** — payloads are paired with benign controls and judged through
|
|
31
|
+
in-band reflection, timing, cross-tool read-back and (optionally) out-of-band callbacks; only the
|
|
32
|
+
*difference* between attack and control counts as evidence.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
Requires Python ≥ 3.11. `curl` must be on `PATH` when LLM features are used.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pipx install mcp-calchas # recommended for a CLI tool (isolated environment)
|
|
40
|
+
# or
|
|
41
|
+
pip install mcp-calchas
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The distribution is called `mcp-calchas`; the command and the Python package are `calchas`.
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# 1. Preview the attack surface only (no payloads sent)
|
|
50
|
+
calchas recon http://localhost:8080/mcp --no-llm-sink --no-agent --no-llm-plan
|
|
51
|
+
|
|
52
|
+
# 2. Full scan with an OpenAI-compatible LLM
|
|
53
|
+
export CALCHAS_LLM_API_KEY=sk-...
|
|
54
|
+
calchas scan http://localhost:8080/mcp \
|
|
55
|
+
--llm-base-url https://api.openai.com/v1 --llm-model gpt-4o
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Results are written to `./runs/<timestamp>__<server>/` in the current directory (`runs/latest` points to
|
|
59
|
+
the most recent run). Change the location with `-o DIR`.
|
|
60
|
+
|
|
61
|
+
| File | Content |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `report.md` | human-readable report |
|
|
64
|
+
| `findings.json` | machine-readable findings |
|
|
65
|
+
| `catalog.json` | tools and parameters returned by `tools/list` |
|
|
66
|
+
| `sinks.json` | per-parameter injection-class classification |
|
|
67
|
+
| `events.jsonl` | full event log of the run |
|
|
68
|
+
|
|
69
|
+
Re-render a report later with `calchas report runs/latest/findings.json runs/latest/catalog.json`.
|
|
70
|
+
|
|
71
|
+
## Configuring the LLM
|
|
72
|
+
|
|
73
|
+
No model is bundled. LLM features (parameter classification, sequence agent, planning) need an
|
|
74
|
+
OpenAI-compatible chat-completions endpoint, configured in one of three ways:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# command line (the key may also come from $CALCHAS_LLM_API_KEY)
|
|
78
|
+
calchas scan <url> --llm-base-url https://api.example.com/v1 --llm-api-key sk-... --llm-model my-model
|
|
79
|
+
|
|
80
|
+
# provider file, with automatic failover in listed order
|
|
81
|
+
calchas scan <url> --llm-config providers.json
|
|
82
|
+
|
|
83
|
+
# no LLM at all (rule-based classification, single-call plans)
|
|
84
|
+
calchas scan <url> --no-llm-sink --no-agent --no-llm-plan
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`--llm-base-url` accepts either `.../v1` or the full `.../v1/chat/completions` URL.
|
|
88
|
+
|
|
89
|
+
`providers.json`:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"providers": [
|
|
94
|
+
{"name": "primary", "base_url": "https://api.example.com/v1", "api_key": "env:MY_KEY", "model": "model-a"},
|
|
95
|
+
{"name": "backup", "base_url": "https://api.other.com/v1", "api_key": "sk-...", "model": "model-b"}
|
|
96
|
+
],
|
|
97
|
+
"agent_provider": "primary"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`"api_key": "env:VAR"` reads the key from environment variable `VAR`. An optional `"extra_body"` object is
|
|
102
|
+
merged into every request to that provider, for provider-specific switches — for example
|
|
103
|
+
`"extra_body": {"enable_thinking": false}` turns off the default reasoning mode of Qwen3-series models.
|
|
104
|
+
|
|
105
|
+
## Out-of-band (OOB) channel
|
|
106
|
+
|
|
107
|
+
Blind SSRF and blind command execution are confirmed by an out-of-band callback. The OOB channel is
|
|
108
|
+
**off by default**; enable it by pointing Calchas at a collector the target can reach:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
calchas scan <url> --oob-callback http://<collector-ip>:9100
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The collector must record any request to `/<token>` and report hits as JSON at `/__hits`
|
|
115
|
+
(override with `--oob-query`). A standard-library reference implementation is in the repository at
|
|
116
|
+
`deploy/infra/oob/collector.py`. Without OOB, Calchas still detects and confirms through in-band
|
|
117
|
+
reflection, timing and read-back channels.
|
|
118
|
+
|
|
119
|
+
## Common options
|
|
120
|
+
|
|
121
|
+
| Option | Purpose |
|
|
122
|
+
|---|---|
|
|
123
|
+
| `--header 'Authorization: Bearer ...'` | add HTTP headers (repeatable) |
|
|
124
|
+
| `--tool NAME` / `--exclude-tool NAME` | limit which tools are tested |
|
|
125
|
+
| `--sink command_injection` | limit which vulnerability classes are tested |
|
|
126
|
+
| `--batch FILE --batch-name NAME` | scan many targets; writes `batch_summary.md` |
|
|
127
|
+
| `--yes` | skip the interactive confirmation (needed for batch/CI) |
|
|
128
|
+
| `--format json` | machine-readable console output |
|
|
129
|
+
|
|
130
|
+
Run `calchas scan --help` for the full list.
|
|
131
|
+
|
|
132
|
+
## Repository layout
|
|
133
|
+
|
|
134
|
+
| Path | Content |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `calchas/` | the tool (the only code shipped in the PyPI package) |
|
|
137
|
+
| `dev/` | developer debugging scripts |
|
|
138
|
+
| `deploy/` | experiment infrastructure: batch-scan docker-compose cells, OOB collector, frozen batch records |
|
|
139
|
+
| `dataset/` | vulnerability-dataset pipeline (CVE/GHSA/OSV collection and labeling) |
|
|
140
|
+
| `docs/`, `research_notes/` | design notes and related-work surveys |
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python3 -m venv .venv && .venv/bin/pip install -e .
|
|
146
|
+
.venv/bin/calchas selftest
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
Apache-2.0
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Single source of truth for the tool's identity.
|
|
2
|
+
|
|
3
|
+
Change the brand/command name here only; every display site imports from this module.
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
# Release version (read by pyproject via setuptools dynamic metadata; bump before each upload).
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
# Human-facing brand name, shown in report titles and console banners.
|
|
10
|
+
APP_NAME = "Calchas"
|
|
11
|
+
# Command-line program name (argparse prog) and the console-script entry point.
|
|
12
|
+
CLI_NAME = "calchas"
|
|
13
|
+
# Internal marker token embedded in generated benign values / placeholder keys
|
|
14
|
+
# (temp-file prefixes, key-position injection fillers). Not user-facing branding;
|
|
15
|
+
# kept centralized so a rebrand stays a one-line change.
|
|
16
|
+
MARKER = "calchas"
|
|
17
|
+
# Prefix for the random canary token minted per probe (embedded in payloads and
|
|
18
|
+
# matched in responses/logs). Any unique, URL/shell-safe string works.
|
|
19
|
+
TOKEN_PREFIX = "clx"
|
|
File without changes
|