slaunt 0.1.0

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.
Files changed (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +152 -0
  3. package/dist/audit/risk-engine.d.ts +4 -0
  4. package/dist/audit/risk-engine.d.ts.map +1 -0
  5. package/dist/audit/risk-engine.js +173 -0
  6. package/dist/audit/risk-engine.js.map +1 -0
  7. package/dist/audit/run.d.ts +13 -0
  8. package/dist/audit/run.d.ts.map +1 -0
  9. package/dist/audit/run.js +55 -0
  10. package/dist/audit/run.js.map +1 -0
  11. package/dist/classification/builtin-catalog.d.ts +3 -0
  12. package/dist/classification/builtin-catalog.d.ts.map +1 -0
  13. package/dist/classification/builtin-catalog.js +283 -0
  14. package/dist/classification/builtin-catalog.js.map +1 -0
  15. package/dist/classification/catalog.d.ts +10 -0
  16. package/dist/classification/catalog.d.ts.map +1 -0
  17. package/dist/classification/catalog.js +139 -0
  18. package/dist/classification/catalog.js.map +1 -0
  19. package/dist/classification/classifier.d.ts +3 -0
  20. package/dist/classification/classifier.d.ts.map +1 -0
  21. package/dist/classification/classifier.js +64 -0
  22. package/dist/classification/classifier.js.map +1 -0
  23. package/dist/cli.d.ts +3 -0
  24. package/dist/cli.d.ts.map +1 -0
  25. package/dist/cli.js +187 -0
  26. package/dist/cli.js.map +1 -0
  27. package/dist/config/discover.d.ts +8 -0
  28. package/dist/config/discover.d.ts.map +1 -0
  29. package/dist/config/discover.js +123 -0
  30. package/dist/config/discover.js.map +1 -0
  31. package/dist/config/install.d.ts +10 -0
  32. package/dist/config/install.d.ts.map +1 -0
  33. package/dist/config/install.js +143 -0
  34. package/dist/config/install.js.map +1 -0
  35. package/dist/config/paths.d.ts +17 -0
  36. package/dist/config/paths.d.ts.map +1 -0
  37. package/dist/config/paths.js +84 -0
  38. package/dist/config/paths.js.map +1 -0
  39. package/dist/demo.d.ts +4 -0
  40. package/dist/demo.d.ts.map +1 -0
  41. package/dist/demo.js +99 -0
  42. package/dist/demo.js.map +1 -0
  43. package/dist/mcp/introspect.d.ts +9 -0
  44. package/dist/mcp/introspect.d.ts.map +1 -0
  45. package/dist/mcp/introspect.js +153 -0
  46. package/dist/mcp/introspect.js.map +1 -0
  47. package/dist/report/html.d.ts +4 -0
  48. package/dist/report/html.d.ts.map +1 -0
  49. package/dist/report/html.js +96 -0
  50. package/dist/report/html.js.map +1 -0
  51. package/dist/tui/render.d.ts +4 -0
  52. package/dist/tui/render.d.ts.map +1 -0
  53. package/dist/tui/render.js +132 -0
  54. package/dist/tui/render.js.map +1 -0
  55. package/dist/types.d.ts +119 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/dist/types.js +2 -0
  58. package/dist/types.js.map +1 -0
  59. package/package.json +56 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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 [yyyy] [name of copyright owner]
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.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # Slaunt Agent Access Audit
2
+
3
+ `npx slaunt audit` maps the MCP capabilities exposed to Claude Code, Claude Desktop, Codex CLI, and the Codex/ChatGPT desktop host. It retrieves declared tool definitions, classifies them locally, correlates risky capability chains, and writes a standalone local HTML report.
4
+
5
+ ```text
6
+ $ npx slaunt audit
7
+
8
+ Slaunt Agent Access Audit
9
+ Inspecting MCP configurations locally. No audit payload uploaded.
10
+
11
+ ✓ Found 2 agent clients
12
+ ✓ Found 5 MCP servers
13
+ ✓ Retrieved 43 tool definitions
14
+ ✓ Classified 38 tools
15
+ ! 5 tools require review
16
+ ```
17
+
18
+ The audit-only release does **not** implement `slaunt connect`.
19
+
20
+ ## Privacy promise
21
+
22
+ The default architecture is intentionally local-first:
23
+
24
+ - Tool names, descriptions, input schemas, config values, findings, and the HTML report remain on the machine.
25
+ - If Supabase is configured, the CLI downloads approved classification rules and performs matching locally. It does not upload an audit payload or call a classification RPC.
26
+ - MCP tools are never called. The auditor only performs the MCP initialization handshake and `tools/list`.
27
+ - Starting configured stdio servers requires interactive consent, or the explicit `--allow-server-starts` flag.
28
+ - Editing client configuration requires interactive consent, or the explicit `--install-slaunt` flag. Existing files are backed up first.
29
+ - JSON output is redacted. Environment and header values are never included.
30
+
31
+ ## Run
32
+
33
+ Node.js 20.17 or newer is required.
34
+
35
+ ```sh
36
+ npx slaunt audit
37
+ ```
38
+
39
+ Useful modes:
40
+
41
+ ```sh
42
+ # Configuration-only inventory; never starts a local MCP process
43
+ npx slaunt audit --no-server-starts
44
+
45
+ # Non-interactive audit with explicit consent to safe defaults
46
+ npx slaunt audit --yes --no-open
47
+
48
+ # Redacted machine-readable output
49
+ npx slaunt audit --json --no-report --no-install-slaunt --no-server-starts
50
+
51
+ # Deterministic product demonstration
52
+ npx slaunt audit --demo --no-open --no-install-slaunt
53
+ ```
54
+
55
+ Run `npx slaunt audit --help` for every option.
56
+
57
+ ## What it discovers
58
+
59
+ | Client | User configuration | Project configuration |
60
+ |---|---|---|
61
+ | Claude Code | `~/.claude.json` | `.mcp.json` |
62
+ | Claude Desktop | OS-specific `claude_desktop_config.json` | — |
63
+ | Codex CLI/Desktop/IDE | `~/.codex/config.toml` | `.codex/config.toml` |
64
+
65
+ Claude uses JSON for MCP configuration; Codex uses TOML. Codex CLI, the IDE extension, and its desktop host share the same Codex configuration. The paths and schemas follow the current [Claude MCP documentation](https://docs.anthropic.com/en/docs/claude-code/mcp) and [Codex MCP documentation](https://developers.openai.com/codex/mcp).
66
+
67
+ The scanner supports stdio, Streamable HTTP, and legacy SSE server declarations. Project configs are discovered from the working directory upward to the user home directory. Disabled Codex servers are ignored.
68
+
69
+ ## Secure Slaunt MCP installation
70
+
71
+ The interactive audit can add Slaunt MCP to each detected client. Installation is:
72
+
73
+ - consented and optional;
74
+ - idempotent by the reserved server name `slaunt`;
75
+ - atomic, using a same-directory temporary file and rename;
76
+ - backed up with a timestamp before any existing file changes;
77
+ - permission-preserving, with new config files created as user-readable only;
78
+ - symlink-safe (the installer refuses to replace a symlink);
79
+ - HTTPS-only, except explicit localhost development endpoints.
80
+
81
+ Override the endpoint only when intentionally testing another trusted Slaunt deployment:
82
+
83
+ ```sh
84
+ SLAUNT_MCP_URL=https://your-reviewed-endpoint.example/mcp npx slaunt audit --install-slaunt
85
+ ```
86
+
87
+ ## Risk model
88
+
89
+ Classification is per declared tool. Correlation then evaluates what a client can do across servers. Examples include:
90
+
91
+ - direct production deployment authority;
92
+ - shell execution chained with credential access;
93
+ - broad GitHub edit and merge permissions shared by multiple clients;
94
+ - cleartext non-local MCP endpoints;
95
+ - plaintext credential-like config values;
96
+ - unpinned dynamic package launchers;
97
+ - unknown tools whose names imply administrative or execution behavior.
98
+
99
+ Unknown does not mean malicious. It means the tool has not matched an approved rule, so the report treats it as potentially sensitive until reviewed.
100
+
101
+ ## Supabase catalog
102
+
103
+ The database is a distribution channel for approved rules, not an audit telemetry sink.
104
+
105
+ 1. Apply [`supabase/migrations/20260731202505_create_tool_classification_catalog.sql`](supabase/migrations/20260731202505_create_tool_classification_catalog.sql) to the target project.
106
+ 2. Confirm the table is exposed through the Data API for the project. Supabase changed new-table exposure defaults in 2026, so explicit Data API exposure may be required.
107
+ 3. Configure the public read-only client values:
108
+
109
+ ```sh
110
+ export SLAUNT_SUPABASE_URL=https://your-project.supabase.co
111
+ export SLAUNT_SUPABASE_PUBLISHABLE_KEY=sb_publishable_...
112
+ npx slaunt audit
113
+ ```
114
+
115
+ The migration enables and forces RLS, removes mutation privileges from public roles, grants column-scoped `SELECT`, and exposes only rows that are both active and approved. It contains no public write policy and no `SECURITY DEFINER` function. Never place a Supabase secret key or legacy `service_role` key in the CLI environment.
116
+
117
+ Catalog refresh failures fall back to a seven-day local cache and then to the bundled catalog. Use `--offline` to skip refresh entirely.
118
+
119
+ ## Classification contribution workflow
120
+
121
+ Classification changes should arrive through reviewed pull requests:
122
+
123
+ 1. Add or update the bounded glob rule in `src/classification/builtin-catalog.ts`.
124
+ 2. Add a regression fixture proving the intended match and non-match behavior.
125
+ 3. Add the reviewed equivalent to a new Supabase migration.
126
+ 4. Keep the database row inactive or in review until a maintainer approves it.
127
+ 5. Run `npm run check && npm test`.
128
+
129
+ Database patterns are treated as bounded globs, never executable regular expressions. This avoids turning a public catalog into a regular-expression denial-of-service input.
130
+
131
+ ## Terminal experience and conversion ethics
132
+
133
+ The terminal flow uses immediate progress feedback, a completed security map, concrete remediations, and an optional next step. It deliberately avoids variable rewards, deceptive urgency, hidden defaults, shame, or an unsupported claim that a UI can medically “optimize dopamine.”
134
+
135
+ The design is informed by evidence that progress feedback can improve follow-through, autonomy-supportive framing is associated with more self-directed motivation, and risk messages work better when paired with an effective action. See the PubMed-indexed reviews on [progress feedback](https://pubmed.ncbi.nlm.nih.gov/33721605/), [autonomy support](https://pubmed.ncbi.nlm.nih.gov/30237648/), and [fear appeals with efficacy](https://pubmed.ncbi.nlm.nih.gov/26501228/). These findings come from other domains, so their application to developer security tooling is a product hypothesis, not a medical claim.
136
+
137
+ ## Local development
138
+
139
+ ```sh
140
+ npm ci
141
+ npm run check
142
+ npm test
143
+ npm run audit:demo
144
+ ```
145
+
146
+ `npm test` builds first, then runs deterministic tests for config parsing, idempotent backups, local classification, cross-client correlation, secret redaction, report CSP, and the built CLI.
147
+
148
+ ## Scope limitations
149
+
150
+ This is a declared-access audit. It does not inspect prompts, file contents, credentials, non-MCP agents, client approval policy, OAuth scopes that are not reflected in tool declarations, or whether a tool has been used. A failed or skipped server probe means its tool inventory is unavailable—not that the server is safe.
151
+
152
+ See [SECURITY.md](SECURITY.md) for the security boundary and reporting process.
@@ -0,0 +1,4 @@
1
+ import type { AuditSummary, ClassifiedTool, Finding, ServerConfig } from '../types.js';
2
+ export declare function analyzeRisks(servers: ServerConfig[], tools: ClassifiedTool[]): Finding[];
3
+ export declare function summarizeAudit(clientCount: number, serverCount: number, tools: ClassifiedTool[], findings: Finding[]): AuditSummary;
4
+ //# sourceMappingURL=risk-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"risk-engine.d.ts","sourceRoot":"","sources":["../../src/audit/risk-engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEZ,cAAc,EACd,OAAO,EACP,YAAY,EAEb,MAAM,aAAa,CAAC;AA8BrB,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,EAAE,CA8IxF;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,YAAY,CAanI"}
@@ -0,0 +1,173 @@
1
+ import { basename } from 'node:path';
2
+ const SEVERITY_ORDER = { critical: 5, high: 4, medium: 3, low: 2, info: 1 };
3
+ const SECRET_NAME = /(token|secret|password|private[_-]?key|credential|api[_-]?key)/i;
4
+ function unique(items) {
5
+ return [...new Set(items)];
6
+ }
7
+ function toolCapabilities(tools) {
8
+ return new Set(tools.flatMap((tool) => tool.classification.capabilities));
9
+ }
10
+ function finding(partial) {
11
+ const id = `${partial.severity}:${partial.title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')}`;
12
+ return { id, ...partial };
13
+ }
14
+ function isLocalHost(hostname) {
15
+ return ['localhost', '127.0.0.1', '::1'].includes(hostname);
16
+ }
17
+ function packageIsPinned(argument) {
18
+ const packagePart = argument.startsWith('@') ? argument.slice(argument.indexOf('/') + 1) : argument;
19
+ const at = packagePart.lastIndexOf('@');
20
+ if (at < 0)
21
+ return false;
22
+ const version = packagePart.slice(at + 1);
23
+ return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/u.test(version);
24
+ }
25
+ export function analyzeRisks(servers, tools) {
26
+ const findings = [];
27
+ for (const tool of tools.filter((item) => item.classification.capabilities.includes('deploy-production'))) {
28
+ findings.push(finding({
29
+ severity: 'critical',
30
+ title: `${tool.clientLabel} can deploy without an external approval boundary`,
31
+ serverNames: [tool.serverName],
32
+ toolNames: [tool.name],
33
+ access: ['Trigger production deployments'],
34
+ why: 'A production-changing capability is directly exposed to the agent.',
35
+ recommendation: 'Require a human approval policy and restrict deployment scope by environment.',
36
+ clients: [tool.client],
37
+ }));
38
+ }
39
+ for (const client of unique(tools.map((tool) => tool.client))) {
40
+ const clientTools = tools.filter((tool) => tool.client === client);
41
+ const capabilities = toolCapabilities(clientTools);
42
+ if (capabilities.has('execute-shell') && capabilities.has('read-secrets')) {
43
+ const label = clientTools[0]?.clientLabel || client;
44
+ findings.push(finding({
45
+ severity: 'high',
46
+ title: `${label} can execute shell commands and access secrets`,
47
+ serverNames: unique(clientTools
48
+ .filter((tool) => tool.classification.capabilities.some((capability) => ['execute-shell', 'read-secrets'].includes(capability)))
49
+ .map((tool) => tool.serverName)),
50
+ toolNames: unique(clientTools
51
+ .filter((tool) => tool.classification.capabilities.some((capability) => ['execute-shell', 'read-secrets'].includes(capability)))
52
+ .map((tool) => tool.name)),
53
+ access: ['Read credentials', 'Execute commands'],
54
+ why: 'These capabilities can be chained to disclose or misuse credentials.',
55
+ recommendation: 'Separate secret access from command execution and require approval for either boundary.',
56
+ clients: [client],
57
+ }));
58
+ }
59
+ }
60
+ const githubByClient = new Map();
61
+ for (const tool of tools.filter((item) => /github/i.test(item.serverName))) {
62
+ const list = githubByClient.get(tool.client) || [];
63
+ list.push(tool);
64
+ githubByClient.set(tool.client, list);
65
+ }
66
+ const broadGithubClients = [...githubByClient.entries()].filter(([, clientTools]) => {
67
+ const capabilities = toolCapabilities(clientTools);
68
+ return capabilities.has('edit-code') && capabilities.has('merge-pull-request');
69
+ });
70
+ if (broadGithubClients.length >= 2) {
71
+ findings.push(finding({
72
+ severity: 'high',
73
+ title: 'Detected clients share broad GitHub permissions',
74
+ serverNames: unique(broadGithubClients.flatMap(([, clientTools]) => clientTools.map((tool) => tool.serverName))),
75
+ toolNames: unique(broadGithubClients.flatMap(([, clientTools]) => clientTools.map((tool) => tool.name))),
76
+ access: ['Edit code', 'Create pull requests', 'Merge pull requests', 'Delete branches or files'],
77
+ why: 'Shared credentials erase role separation between agents.',
78
+ recommendation: 'Assign repository permissions and credentials by agent role.',
79
+ clients: broadGithubClients.map(([client]) => client),
80
+ }));
81
+ }
82
+ for (const server of servers) {
83
+ if (server.url) {
84
+ try {
85
+ const url = new URL(server.url);
86
+ if (url.protocol === 'http:' && !isLocalHost(url.hostname)) {
87
+ findings.push(finding({
88
+ severity: 'critical',
89
+ title: `${server.clientLabel} sends MCP traffic over cleartext HTTP`,
90
+ serverNames: [server.name],
91
+ toolNames: [],
92
+ access: ['MCP requests and responses can cross the network unencrypted'],
93
+ why: 'A network observer could read or alter agent traffic.',
94
+ recommendation: 'Use HTTPS with certificate verification before enabling this server.',
95
+ clients: [server.client],
96
+ }));
97
+ }
98
+ }
99
+ catch {
100
+ findings.push(finding({
101
+ severity: 'high',
102
+ title: `${server.clientLabel} has an invalid MCP server URL`,
103
+ serverNames: [server.name],
104
+ toolNames: [],
105
+ access: [],
106
+ why: 'The configured endpoint cannot be safely interpreted.',
107
+ recommendation: 'Replace the endpoint with a reviewed HTTPS URL.',
108
+ clients: [server.client],
109
+ }));
110
+ }
111
+ }
112
+ const inlineSecretKeys = server.envKeys.filter((key) => SECRET_NAME.test(key) && !/^\$\{.+\}$/u.test(server.env[key] || ''));
113
+ const hasSecretArgument = server.args.some((arg, index) => SECRET_NAME.test(arg) && (/[=:]/u.test(arg) || Boolean(server.args[index + 1] && !server.args[index + 1].startsWith('-'))));
114
+ if (inlineSecretKeys.length > 0 || hasSecretArgument) {
115
+ findings.push(finding({
116
+ severity: 'high',
117
+ title: `${server.clientLabel} stores credential material in an MCP configuration`,
118
+ serverNames: [server.name],
119
+ toolNames: [],
120
+ access: [...inlineSecretKeys.map((key) => `Environment key: ${key}`), ...(hasSecretArgument ? ['Credential-like command argument'] : [])],
121
+ why: 'Plaintext configuration values are exposed to local file readers and backups.',
122
+ recommendation: 'Reference a protected environment variable or operating-system credential store.',
123
+ clients: [server.client],
124
+ }));
125
+ }
126
+ const command = server.command ? basename(server.command).toLowerCase() : '';
127
+ if (['npx', 'pnpx', 'bunx'].includes(command)) {
128
+ const packageArg = server.args.find((arg) => !arg.startsWith('-'));
129
+ if (packageArg && !packageIsPinned(packageArg)) {
130
+ findings.push(finding({
131
+ severity: 'medium',
132
+ title: `${server.name} can resolve an unpinned package at startup`,
133
+ serverNames: [server.name],
134
+ toolNames: [],
135
+ access: ['Execute package registry code'],
136
+ why: 'The code executed by this server can change without a configuration change.',
137
+ recommendation: 'Pin the package to an exact reviewed version and preserve the package-manager lock or integrity data.',
138
+ clients: [server.client],
139
+ }));
140
+ }
141
+ }
142
+ }
143
+ const suspiciousUnknowns = tools.filter((item) => item.classification.source === 'unknown' && /admin|execute|trigger|workflow|sync/i.test(item.name));
144
+ if (suspiciousUnknowns.length > 0) {
145
+ findings.push(finding({
146
+ severity: 'medium',
147
+ title: `${suspiciousUnknowns.length} unclassified tools appear state-changing`,
148
+ serverNames: unique(suspiciousUnknowns.map((tool) => tool.serverName)),
149
+ toolNames: unique(suspiciousUnknowns.map((tool) => tool.name)),
150
+ access: ['Potential administrative or execution capability'],
151
+ why: 'No trusted rule explains tools whose names suggest privileged behavior.',
152
+ recommendation: 'Review and classify these tools before leaving them exposed to an agent.',
153
+ clients: unique(suspiciousUnknowns.map((tool) => tool.client)),
154
+ }));
155
+ }
156
+ const deduplicated = [...new Map(findings.map((item) => [`${item.id}:${item.clients.join(',')}:${item.serverNames.join(',')}`, item])).values()];
157
+ return deduplicated.sort((a, b) => SEVERITY_ORDER[b.severity] - SEVERITY_ORDER[a.severity] || a.title.localeCompare(b.title));
158
+ }
159
+ export function summarizeAudit(clientCount, serverCount, tools, findings) {
160
+ const highRiskFindings = findings.filter((item) => item.severity === 'critical' || item.severity === 'high').length;
161
+ const penalty = findings.reduce((total, item) => total + ({ critical: 22, high: 12, medium: 5, low: 2, info: 0 }[item.severity]), 0);
162
+ return {
163
+ clientsDetected: clientCount,
164
+ servers: serverCount,
165
+ tools: tools.length,
166
+ classified: tools.filter((tool) => tool.classification.source !== 'unknown').length,
167
+ sensitiveCapabilities: tools.filter((tool) => tool.classification.sensitive).length,
168
+ highRiskFindings,
169
+ unclassified: tools.filter((tool) => tool.classification.source === 'unknown').length,
170
+ postureScore: Math.max(0, 100 - penalty),
171
+ };
172
+ }
173
+ //# sourceMappingURL=risk-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"risk-engine.js","sourceRoot":"","sources":["../../src/audit/risk-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAUrC,MAAM,cAAc,GAA6B,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACtG,MAAM,WAAW,GAAG,iEAAiE,CAAC;AAEtF,SAAS,MAAM,CAAI,KAAU;IAC3B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAuB;IAC/C,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,OAAO,CAAC,OAA4B;IAC3C,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;IAClH,OAAO,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB;IACnC,O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,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC;KACzC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { AuditResult, DiscoveredConfiguration } from '../types.js';
2
+ export type AuditStage = 'discover' | 'catalog' | 'probe' | 'classify' | 'analyze';
3
+ export interface RunAuditOptions {
4
+ customPaths?: string[];
5
+ allowServerStarts: boolean;
6
+ offline?: boolean;
7
+ timeoutMs?: number;
8
+ demo?: boolean;
9
+ discovery?: DiscoveredConfiguration;
10
+ onStage?: (stage: AuditStage, detail: string) => void;
11
+ }
12
+ export declare function runAudit(options: RunAuditOptions): Promise<AuditResult>;
13
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/audit/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAgB,MAAM,aAAa,CAAC;AAQtF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAEnF,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACvD;AAUD,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CA4C7E"}
@@ -0,0 +1,55 @@
1
+ import { classifyTools } from '../classification/classifier.js';
2
+ import { loadCatalog } from '../classification/catalog.js';
3
+ import { discoverConfigurations } from '../config/discover.js';
4
+ import { demoDiscovery, demoProbes } from '../demo.js';
5
+ import { probeServers } from '../mcp/introspect.js';
6
+ import { analyzeRisks, summarizeAudit } from './risk-engine.js';
7
+ function sanitizeServer(server) {
8
+ return {
9
+ ...server,
10
+ env: Object.fromEntries(server.envKeys.map((key) => [key, '[redacted]'])),
11
+ headers: Object.fromEntries(server.headerKeys.map((key) => [key, '[redacted]'])),
12
+ };
13
+ }
14
+ export async function runAudit(options) {
15
+ options.onStage?.('discover', 'Reading known Claude and Codex configuration locations');
16
+ const discovery = options.demo
17
+ ? demoDiscovery()
18
+ : options.discovery || await discoverConfigurations({ ...(options.customPaths ? { customPaths: options.customPaths } : {}) });
19
+ options.onStage?.('catalog', 'Loading signed-down classification rules; local tool data stays local');
20
+ const catalog = await loadCatalog({ ...(options.offline || options.demo ? { offline: true } : {}) });
21
+ if (catalog.warning)
22
+ discovery.warnings.push(`Classification catalog: ${catalog.warning}`);
23
+ options.onStage?.('probe', 'Retrieving declared MCP tool definitions without calling any tools');
24
+ const probes = options.demo
25
+ ? demoProbes()
26
+ : await probeServers(discovery.servers, {
27
+ allowServerStarts: options.allowServerStarts,
28
+ ...(options.timeoutMs ? { timeoutMs: options.timeoutMs } : {}),
29
+ });
30
+ options.onStage?.('classify', 'Matching declared capabilities against the trusted catalog');
31
+ const tools = classifyTools(probes.flatMap((probe) => probe.tools), catalog.rules);
32
+ options.onStage?.('analyze', 'Correlating capabilities across clients and servers');
33
+ const findings = analyzeRisks(discovery.servers, tools);
34
+ const clientCount = discovery.clients.filter((client) => client.detected).length;
35
+ const serverCount = new Set(discovery.servers.map((server) => server.name.toLowerCase())).size;
36
+ const summary = summarizeAudit(clientCount, serverCount, tools, findings);
37
+ return {
38
+ schemaVersion: 1,
39
+ generatedAt: new Date().toISOString(),
40
+ privacy: {
41
+ uploadedAuditData: false,
42
+ catalogSource: catalog.source,
43
+ startedConfiguredServers: options.allowServerStarts && discovery.servers.some((server) => server.transport === 'stdio'),
44
+ },
45
+ discovery: {
46
+ ...discovery,
47
+ servers: discovery.servers.map(sanitizeServer),
48
+ },
49
+ probes,
50
+ tools,
51
+ findings,
52
+ summary,
53
+ };
54
+ }
55
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/audit/run.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAchE,SAAS,cAAc,CAAC,MAAoB;IAC1C,OAAO;QACL,GAAG,MAAM;QACT,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;QACzE,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;KACjF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAwB;IACrD,OAAO,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE,wDAAwD,CAAC,CAAC;IACxF,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI;QAC5B,CAAC,CAAC,aAAa,EAAE;QACjB,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,MAAM,sBAAsB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,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C;IACxD,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IACjF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/F,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAE1E,OAAO;QACL,aAAa,EAAE,CAAC;QAChB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACrC,OAAO,EAAE;YACP,iBAAiB,EAAE,KAAK;YACxB,aAAa,EAAE,OAAO,CAAC,MAAM;YAC7B,wBAAwB,EAAE,OAAO,CAAC,iBAAiB,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,KAAK,OAAO,CAAC;SACxH;QACD,SAAS,EAAE;YACT,GAAG,SAAS;YACZ,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;SAC/C;QACD,MAAM;QACN,KAAK;QACL,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ClassificationRule } from '../types.js';
2
+ export declare const BUILTIN_CATALOG: ClassificationRule[];
3
+ //# sourceMappingURL=builtin-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin-catalog.d.ts","sourceRoot":"","sources":["../../src/classification/builtin-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,eAAe,EAAE,kBAAkB,EAyR/C,CAAC"}