@aiclude/security-mcp 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.
- package/LICENSE +201 -0
- package/README.md +77 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +874 -0
- package/package.json +73 -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,77 @@
|
|
|
1
|
+
# @aiclude/security-mcp
|
|
2
|
+
|
|
3
|
+
AIclude Security Vulnerability Scanner - MCP Server for scanning MCP servers and Claude Code Skills for security vulnerabilities.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **security_scan**: Search existing scan results by name, or trigger a new scan automatically
|
|
8
|
+
- **scan_mcp_server**: Scan local MCP server source code for vulnerabilities
|
|
9
|
+
- **scan_skill**: Scan local Claude Code Skill for vulnerabilities
|
|
10
|
+
- **get_report** / **list_reports**: Retrieve and browse security scan reports
|
|
11
|
+
- 7 parallel scan engines: SAST, SCA, Tool Analyzer, DAST, Permission Checker, Behavior Monitor, Malware Detector
|
|
12
|
+
|
|
13
|
+
## Quick Install
|
|
14
|
+
|
|
15
|
+
### Claude Desktop
|
|
16
|
+
|
|
17
|
+
Add to `claude_desktop_config.json`:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"aiclude-security": {
|
|
23
|
+
"command": "npx",
|
|
24
|
+
"args": ["-y", "@aiclude/security-mcp"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Cursor
|
|
31
|
+
|
|
32
|
+
Add to `.cursor/mcp.json`:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"mcpServers": {
|
|
37
|
+
"aiclude-security": {
|
|
38
|
+
"command": "npx",
|
|
39
|
+
"args": ["-y", "@aiclude/security-mcp"]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
Once installed, ask your AI agent:
|
|
48
|
+
|
|
49
|
+
- "Check the security of @modelcontextprotocol/server-fetch"
|
|
50
|
+
- "mcp-server-github 의 보안 취약점을 확인해줘"
|
|
51
|
+
- "Scan ./my-mcp-server for security vulnerabilities"
|
|
52
|
+
|
|
53
|
+
## Tools
|
|
54
|
+
|
|
55
|
+
| Tool | Description |
|
|
56
|
+
|------|-------------|
|
|
57
|
+
| `security_scan` | Search existing scan results by package name. Returns full report if found, or triggers new scan. |
|
|
58
|
+
| `scan_mcp_server` | Scan local MCP server directory for vulnerabilities |
|
|
59
|
+
| `scan_skill` | Scan local Claude Code Skill directory for vulnerabilities |
|
|
60
|
+
| `get_report` | Retrieve a specific scan report by ID |
|
|
61
|
+
| `list_reports` | List available scan reports with severity filtering |
|
|
62
|
+
| `configure_scan` | View or update scan configuration |
|
|
63
|
+
|
|
64
|
+
## Environment Variables
|
|
65
|
+
|
|
66
|
+
| Variable | Description | Default |
|
|
67
|
+
|----------|-------------|---------|
|
|
68
|
+
| `ASVS_API_URL` | AIclude API server URL | `https://vs-api.aiclude.com` |
|
|
69
|
+
| `ASVS_SIGNING_SECRET` | HMAC signing secret for API authentication | Built-in default |
|
|
70
|
+
|
|
71
|
+
## Web Dashboard
|
|
72
|
+
|
|
73
|
+
View all scan results at: https://vs.aiclude.com
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT - AICLUDE Inc.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MCP Server Implementation for ASVS
|
|
6
|
+
*
|
|
7
|
+
* Provides security scanning tools via the Model Context Protocol using
|
|
8
|
+
* the @modelcontextprotocol/sdk McpServer high-level API.
|
|
9
|
+
*
|
|
10
|
+
* Tools:
|
|
11
|
+
* - scan_mcp_server: Scan an MCP server for security vulnerabilities
|
|
12
|
+
* - scan_skill: Scan a Claude Code skill for security vulnerabilities
|
|
13
|
+
* - get_report: Retrieve a stored scan report by ID
|
|
14
|
+
* - list_reports: List available scan reports
|
|
15
|
+
* - configure_scan: View or update global scan configuration
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create and configure the ASVS MCP server with all tools registered.
|
|
20
|
+
* Returns the McpServer instance ready to be connected to a transport.
|
|
21
|
+
*/
|
|
22
|
+
declare function createServer(): McpServer;
|
|
23
|
+
|
|
24
|
+
export { createServer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
|
|
6
|
+
// src/server.ts
|
|
7
|
+
import {
|
|
8
|
+
existsSync,
|
|
9
|
+
mkdirSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
readdirSync,
|
|
12
|
+
writeFileSync
|
|
13
|
+
} from "fs";
|
|
14
|
+
import { join } from "path";
|
|
15
|
+
import { createHmac } from "crypto";
|
|
16
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
import {
|
|
19
|
+
Scanner,
|
|
20
|
+
SastEngine,
|
|
21
|
+
ScaEngine,
|
|
22
|
+
ToolAnalyzerEngine,
|
|
23
|
+
MalwareDetectorEngine,
|
|
24
|
+
PermissionCheckerEngine,
|
|
25
|
+
DastEngine,
|
|
26
|
+
BehaviorMonitorEngine,
|
|
27
|
+
loadGlobalConfig,
|
|
28
|
+
saveGlobalConfig,
|
|
29
|
+
initDataDir,
|
|
30
|
+
RiskLevel,
|
|
31
|
+
validateScanPath
|
|
32
|
+
} from "@asvs/core";
|
|
33
|
+
import { ReportGenerator } from "@asvs/reporter";
|
|
34
|
+
function getReportsDir(config) {
|
|
35
|
+
return join(config.dataDir, "reports");
|
|
36
|
+
}
|
|
37
|
+
function ensureReportsDirSync(config) {
|
|
38
|
+
const dir = getReportsDir(config);
|
|
39
|
+
if (!existsSync(dir)) {
|
|
40
|
+
mkdirSync(dir, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function saveReport(config, report) {
|
|
44
|
+
ensureReportsDirSync(config);
|
|
45
|
+
const filePath = join(getReportsDir(config), `${report.id}.json`);
|
|
46
|
+
writeFileSync(filePath, JSON.stringify(report, null, 2), "utf-8");
|
|
47
|
+
}
|
|
48
|
+
function loadReport(config, reportId) {
|
|
49
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(reportId)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const filePath = join(getReportsDir(config), `${reportId}.json`);
|
|
53
|
+
if (!existsSync(filePath)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
57
|
+
return JSON.parse(raw);
|
|
58
|
+
}
|
|
59
|
+
function listReportSummaries(config, options) {
|
|
60
|
+
ensureReportsDirSync(config);
|
|
61
|
+
const dir = getReportsDir(config);
|
|
62
|
+
const files = readdirSync(dir).filter((f) => f.endsWith(".json"));
|
|
63
|
+
const summaries = [];
|
|
64
|
+
const severityOrder = ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"];
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
try {
|
|
67
|
+
const raw = readFileSync(join(dir, file), "utf-8");
|
|
68
|
+
const report = JSON.parse(raw);
|
|
69
|
+
const overallRiskLevel = report.scanResult.summary.overallRiskLevel;
|
|
70
|
+
if (options?.severityFilter) {
|
|
71
|
+
const filterIdx = severityOrder.indexOf(options.severityFilter);
|
|
72
|
+
const reportIdx = severityOrder.indexOf(overallRiskLevel);
|
|
73
|
+
if (reportIdx > filterIdx) continue;
|
|
74
|
+
}
|
|
75
|
+
summaries.push({
|
|
76
|
+
id: report.id,
|
|
77
|
+
title: report.title,
|
|
78
|
+
targetName: report.scanResult.target.name,
|
|
79
|
+
targetType: report.scanResult.target.type,
|
|
80
|
+
overallRiskLevel,
|
|
81
|
+
totalVulnerabilities: report.scanResult.summary.totalVulnerabilities,
|
|
82
|
+
generatedAt: report.generatedAt
|
|
83
|
+
});
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
summaries.sort(
|
|
88
|
+
(a, b) => new Date(b.generatedAt).getTime() - new Date(a.generatedAt).getTime()
|
|
89
|
+
);
|
|
90
|
+
const limit = options?.limit ?? 20;
|
|
91
|
+
return summaries.slice(0, limit);
|
|
92
|
+
}
|
|
93
|
+
function riskLevelLabel(level) {
|
|
94
|
+
switch (level) {
|
|
95
|
+
case "CRITICAL":
|
|
96
|
+
return "[CRITICAL]";
|
|
97
|
+
case "HIGH":
|
|
98
|
+
return "[HIGH]";
|
|
99
|
+
case "MEDIUM":
|
|
100
|
+
return "[MEDIUM]";
|
|
101
|
+
case "LOW":
|
|
102
|
+
return "[LOW]";
|
|
103
|
+
case "INFO":
|
|
104
|
+
return "[INFO]";
|
|
105
|
+
default:
|
|
106
|
+
return `[${level}]`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function formatReportAsMarkdown(report) {
|
|
110
|
+
const { scanResult } = report;
|
|
111
|
+
const { summary, target } = scanResult;
|
|
112
|
+
const allVulns = scanResult.engineResults.flatMap((r) => r.vulnerabilities);
|
|
113
|
+
const lines = [];
|
|
114
|
+
lines.push(`# ${report.title}`);
|
|
115
|
+
lines.push("");
|
|
116
|
+
lines.push(`**Target**: ${target.name} (${target.type})`);
|
|
117
|
+
lines.push(`**Path**: ${target.path}`);
|
|
118
|
+
lines.push(`**Scan Date**: ${report.generatedAt}`);
|
|
119
|
+
lines.push(
|
|
120
|
+
`**Overall Risk**: ${riskLevelLabel(summary.overallRiskLevel)} (Score: ${summary.overallScore}/100)`
|
|
121
|
+
);
|
|
122
|
+
lines.push(`**Total Findings**: ${summary.totalVulnerabilities}`);
|
|
123
|
+
lines.push("");
|
|
124
|
+
lines.push("## Severity Breakdown");
|
|
125
|
+
lines.push("");
|
|
126
|
+
lines.push("| Severity | Count |");
|
|
127
|
+
lines.push("|----------|-------|");
|
|
128
|
+
for (const level of [
|
|
129
|
+
RiskLevel.CRITICAL,
|
|
130
|
+
RiskLevel.HIGH,
|
|
131
|
+
RiskLevel.MEDIUM,
|
|
132
|
+
RiskLevel.LOW,
|
|
133
|
+
RiskLevel.INFO
|
|
134
|
+
]) {
|
|
135
|
+
const count = summary.bySeverity[level];
|
|
136
|
+
if (count > 0) {
|
|
137
|
+
lines.push(`| ${riskLevelLabel(level)} | ${count} |`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
lines.push("");
|
|
141
|
+
if (allVulns.length > 0) {
|
|
142
|
+
lines.push("## Findings");
|
|
143
|
+
lines.push("");
|
|
144
|
+
for (const level of [
|
|
145
|
+
RiskLevel.CRITICAL,
|
|
146
|
+
RiskLevel.HIGH,
|
|
147
|
+
RiskLevel.MEDIUM,
|
|
148
|
+
RiskLevel.LOW,
|
|
149
|
+
RiskLevel.INFO
|
|
150
|
+
]) {
|
|
151
|
+
const levelVulns = allVulns.filter((v) => v.severity === level);
|
|
152
|
+
if (levelVulns.length === 0) continue;
|
|
153
|
+
lines.push(
|
|
154
|
+
`### ${riskLevelLabel(level)} ${level} (${levelVulns.length})`
|
|
155
|
+
);
|
|
156
|
+
lines.push("");
|
|
157
|
+
for (const vuln of levelVulns) {
|
|
158
|
+
lines.push(`#### ${vuln.title}`);
|
|
159
|
+
lines.push("");
|
|
160
|
+
lines.push(`- **Category**: ${vuln.category}`);
|
|
161
|
+
lines.push(
|
|
162
|
+
`- **Confidence**: ${(vuln.confidence * 100).toFixed(0)}%`
|
|
163
|
+
);
|
|
164
|
+
if (vuln.location) {
|
|
165
|
+
lines.push(
|
|
166
|
+
`- **Location**: \`${vuln.location.file}\` (line ${vuln.location.line})`
|
|
167
|
+
);
|
|
168
|
+
if (vuln.location.snippet) {
|
|
169
|
+
lines.push(
|
|
170
|
+
`- **Snippet**: \`${vuln.location.snippet.trim()}\``
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (vuln.cvssScore !== void 0) {
|
|
175
|
+
lines.push(`- **CVSS**: ${vuln.cvssScore}`);
|
|
176
|
+
}
|
|
177
|
+
if (vuln.cweIds && vuln.cweIds.length > 0) {
|
|
178
|
+
lines.push(`- **CWE**: ${vuln.cweIds.join(", ")}`);
|
|
179
|
+
}
|
|
180
|
+
lines.push(`- **Description**: ${vuln.description}`);
|
|
181
|
+
lines.push(`- **Remediation**: ${vuln.remediation}`);
|
|
182
|
+
lines.push("");
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (report.risks.length > 0) {
|
|
187
|
+
lines.push("## Risk Assessment");
|
|
188
|
+
lines.push("");
|
|
189
|
+
for (const risk of report.risks) {
|
|
190
|
+
lines.push(
|
|
191
|
+
`- ${riskLevelLabel(risk.level)} **${risk.area}**: ${risk.description}`
|
|
192
|
+
);
|
|
193
|
+
lines.push(` - Impact: ${risk.impact}`);
|
|
194
|
+
lines.push(` - Likelihood: ${risk.likelihood}`);
|
|
195
|
+
lines.push(` - Remediation: ${risk.remediation}`);
|
|
196
|
+
}
|
|
197
|
+
lines.push("");
|
|
198
|
+
}
|
|
199
|
+
if (report.precautions.length > 0) {
|
|
200
|
+
lines.push("## Precautions & Recommendations");
|
|
201
|
+
lines.push("");
|
|
202
|
+
for (const precaution of report.precautions) {
|
|
203
|
+
lines.push(`- ${precaution}`);
|
|
204
|
+
}
|
|
205
|
+
lines.push("");
|
|
206
|
+
}
|
|
207
|
+
lines.push("## Engine Details");
|
|
208
|
+
lines.push("");
|
|
209
|
+
for (const engineResult of scanResult.engineResults) {
|
|
210
|
+
const errors = engineResult.metadata.errors ?? [];
|
|
211
|
+
lines.push(
|
|
212
|
+
`- **${engineResult.engineId}**: ${engineResult.vulnerabilities.length} findings, ${engineResult.metadata.duration}ms` + (errors.length > 0 ? ` (${errors.length} error(s))` : "")
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
lines.push("");
|
|
216
|
+
lines.push("---");
|
|
217
|
+
lines.push(`*Report ID: ${report.id}*`);
|
|
218
|
+
return lines.join("\n");
|
|
219
|
+
}
|
|
220
|
+
function formatReportAsHtml(report) {
|
|
221
|
+
const md = formatReportAsMarkdown(report);
|
|
222
|
+
const escapedBody = md.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
223
|
+
return `<!DOCTYPE html>
|
|
224
|
+
<html lang="en">
|
|
225
|
+
<head>
|
|
226
|
+
<meta charset="UTF-8">
|
|
227
|
+
<title>${report.title.replace(/</g, "<").replace(/>/g, ">")}</title>
|
|
228
|
+
<style>
|
|
229
|
+
body { font-family: system-ui, -apple-system, sans-serif; max-width: 900px; margin: 2rem auto; padding: 0 1rem; line-height: 1.6; color: #1a1a1a; }
|
|
230
|
+
pre { background: #f5f5f5; padding: 1rem; border-radius: 4px; overflow-x: auto; white-space: pre-wrap; font-size: 0.9em; }
|
|
231
|
+
table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
|
|
232
|
+
th, td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; }
|
|
233
|
+
th { background: #f0f0f0; }
|
|
234
|
+
</style>
|
|
235
|
+
</head>
|
|
236
|
+
<body>
|
|
237
|
+
<pre>${escapedBody}</pre>
|
|
238
|
+
</body>
|
|
239
|
+
</html>`;
|
|
240
|
+
}
|
|
241
|
+
function createConfiguredScanner() {
|
|
242
|
+
const scanner = new Scanner();
|
|
243
|
+
scanner.registerEngine(new SastEngine());
|
|
244
|
+
scanner.registerEngine(new ScaEngine());
|
|
245
|
+
scanner.registerEngine(new ToolAnalyzerEngine());
|
|
246
|
+
scanner.registerEngine(new MalwareDetectorEngine());
|
|
247
|
+
scanner.registerEngine(new PermissionCheckerEngine());
|
|
248
|
+
scanner.registerEngine(new DastEngine());
|
|
249
|
+
scanner.registerEngine(new BehaviorMonitorEngine());
|
|
250
|
+
return scanner;
|
|
251
|
+
}
|
|
252
|
+
function buildScanConfig(globalConfig, overrides) {
|
|
253
|
+
const base = globalConfig.defaultScanConfig;
|
|
254
|
+
const allEngines = [
|
|
255
|
+
"sast",
|
|
256
|
+
"sca",
|
|
257
|
+
"tool-analyzer",
|
|
258
|
+
"malware-detector",
|
|
259
|
+
"permission-checker",
|
|
260
|
+
"dast",
|
|
261
|
+
"behavior-monitor"
|
|
262
|
+
];
|
|
263
|
+
return {
|
|
264
|
+
...base,
|
|
265
|
+
engines: allEngines,
|
|
266
|
+
sandboxProfile: overrides?.sandboxProfile ?? base.sandboxProfile
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
270
|
+
function getNestedValue(obj, path) {
|
|
271
|
+
const parts = path.split(".");
|
|
272
|
+
if (parts.some((p) => DANGEROUS_KEYS.has(p))) {
|
|
273
|
+
return void 0;
|
|
274
|
+
}
|
|
275
|
+
let current = obj;
|
|
276
|
+
for (const part of parts) {
|
|
277
|
+
if (current === null || current === void 0 || typeof current !== "object") {
|
|
278
|
+
return void 0;
|
|
279
|
+
}
|
|
280
|
+
current = current[part];
|
|
281
|
+
}
|
|
282
|
+
return current;
|
|
283
|
+
}
|
|
284
|
+
function setNestedValue(obj, path, value) {
|
|
285
|
+
const parts = path.split(".");
|
|
286
|
+
if (parts.some((p) => DANGEROUS_KEYS.has(p))) {
|
|
287
|
+
throw new Error(`Invalid configuration key: path contains forbidden segment`);
|
|
288
|
+
}
|
|
289
|
+
let current = obj;
|
|
290
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
291
|
+
const part = parts[i];
|
|
292
|
+
if (current[part] === void 0 || current[part] === null || typeof current[part] !== "object") {
|
|
293
|
+
current[part] = {};
|
|
294
|
+
}
|
|
295
|
+
current = current[part];
|
|
296
|
+
}
|
|
297
|
+
const lastPart = parts[parts.length - 1];
|
|
298
|
+
current[lastPart] = value;
|
|
299
|
+
}
|
|
300
|
+
function parseConfigValue(raw) {
|
|
301
|
+
try {
|
|
302
|
+
return JSON.parse(raw);
|
|
303
|
+
} catch {
|
|
304
|
+
return raw;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function getSigningSecret() {
|
|
308
|
+
return process.env["ASVS_SIGNING_SECRET"] ?? "asvs-default-signing-key-2026";
|
|
309
|
+
}
|
|
310
|
+
function createAuthHeaders(source, name) {
|
|
311
|
+
const timestamp = String(Date.now());
|
|
312
|
+
const payload = `${source}:${name}:${timestamp}`;
|
|
313
|
+
const signature = createHmac("sha256", getSigningSecret()).update(payload).digest("hex");
|
|
314
|
+
return {
|
|
315
|
+
"Content-Type": "application/json",
|
|
316
|
+
"X-ASVS-Source": source,
|
|
317
|
+
"X-ASVS-Timestamp": timestamp,
|
|
318
|
+
"X-ASVS-Signature": signature
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function formatApiReportAsMarkdown(report, target) {
|
|
322
|
+
const lines = [];
|
|
323
|
+
const scanResult = report["scanResult"];
|
|
324
|
+
const summary = scanResult?.["summary"];
|
|
325
|
+
const engineResults = scanResult?.["engineResults"] ?? [];
|
|
326
|
+
const risks = report["risks"] ?? [];
|
|
327
|
+
const precautions = report["precautions"] ?? [];
|
|
328
|
+
const riskLevel = summary?.["overallRiskLevel"] ?? target["riskLevel"] ?? "UNKNOWN";
|
|
329
|
+
const score = summary?.["overallScore"] ?? target["lastScore"] ?? 0;
|
|
330
|
+
const totalVulns = summary?.["totalVulnerabilities"] ?? 0;
|
|
331
|
+
const bySeverity = summary?.["bySeverity"] ?? {};
|
|
332
|
+
const targetName = target["canonicalName"] ?? target["displayName"] ?? "Unknown";
|
|
333
|
+
const targetType = target["type"] ?? "mcp-server";
|
|
334
|
+
lines.push(`# Security Scan Report: ${targetName}`);
|
|
335
|
+
lines.push("");
|
|
336
|
+
lines.push(`**Target**: ${targetName} (${targetType})`);
|
|
337
|
+
lines.push(`**Overall Risk**: ${riskLevelLabel(riskLevel)} (Score: ${score}/100)`);
|
|
338
|
+
lines.push(`**Total Findings**: ${totalVulns}`);
|
|
339
|
+
lines.push(`**Scan Date**: ${report["generatedAt"] ?? (/* @__PURE__ */ new Date()).toISOString()}`);
|
|
340
|
+
lines.push("");
|
|
341
|
+
lines.push("## Severity Breakdown");
|
|
342
|
+
lines.push("");
|
|
343
|
+
lines.push("| Severity | Count |");
|
|
344
|
+
lines.push("|----------|-------|");
|
|
345
|
+
for (const level of ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]) {
|
|
346
|
+
const count = bySeverity[level] ?? 0;
|
|
347
|
+
if (count > 0) {
|
|
348
|
+
lines.push(`| ${riskLevelLabel(level)} | ${count} |`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
lines.push("");
|
|
352
|
+
const allVulns = engineResults.flatMap(
|
|
353
|
+
(r) => r["vulnerabilities"] ?? []
|
|
354
|
+
);
|
|
355
|
+
if (allVulns.length > 0) {
|
|
356
|
+
lines.push("## Findings");
|
|
357
|
+
lines.push("");
|
|
358
|
+
for (const level of ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]) {
|
|
359
|
+
const levelVulns = allVulns.filter((v) => v["severity"] === level);
|
|
360
|
+
if (levelVulns.length === 0) continue;
|
|
361
|
+
lines.push(`### ${riskLevelLabel(level)} ${level} (${levelVulns.length})`);
|
|
362
|
+
lines.push("");
|
|
363
|
+
for (const vuln of levelVulns.slice(0, 10)) {
|
|
364
|
+
lines.push(`#### ${vuln["title"]}`);
|
|
365
|
+
lines.push("");
|
|
366
|
+
lines.push(`- **Category**: ${vuln["category"]}`);
|
|
367
|
+
lines.push(`- **Confidence**: ${Math.round(vuln["confidence"] * 100)}%`);
|
|
368
|
+
const loc = vuln["location"];
|
|
369
|
+
if (loc) {
|
|
370
|
+
lines.push(`- **Location**: \`${loc["file"]}\` (line ${loc["line"]})`);
|
|
371
|
+
if (loc["snippet"]) {
|
|
372
|
+
lines.push(`- **Snippet**: \`${loc["snippet"].trim().substring(0, 200)}\``);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (vuln["cvssScore"] !== void 0) {
|
|
376
|
+
lines.push(`- **CVSS**: ${vuln["cvssScore"]}`);
|
|
377
|
+
}
|
|
378
|
+
lines.push(`- **Description**: ${vuln["description"]}`);
|
|
379
|
+
lines.push(`- **Remediation**: ${vuln["remediation"]}`);
|
|
380
|
+
lines.push("");
|
|
381
|
+
}
|
|
382
|
+
if (levelVulns.length > 10) {
|
|
383
|
+
lines.push(`> ... and ${levelVulns.length - 10} more ${level} findings`);
|
|
384
|
+
lines.push("");
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (risks.length > 0) {
|
|
389
|
+
lines.push("## Risk Assessment");
|
|
390
|
+
lines.push("");
|
|
391
|
+
for (const risk of risks) {
|
|
392
|
+
lines.push(`- ${riskLevelLabel(risk["level"])} **${risk["area"]}**: ${risk["description"]}`);
|
|
393
|
+
lines.push(` - Impact: ${risk["impact"]}`);
|
|
394
|
+
lines.push(` - Remediation: ${risk["remediation"]}`);
|
|
395
|
+
}
|
|
396
|
+
lines.push("");
|
|
397
|
+
}
|
|
398
|
+
if (precautions.length > 0) {
|
|
399
|
+
lines.push("## Precautions & Recommendations");
|
|
400
|
+
lines.push("");
|
|
401
|
+
for (const p of precautions) {
|
|
402
|
+
lines.push(`- ${p}`);
|
|
403
|
+
}
|
|
404
|
+
lines.push("");
|
|
405
|
+
}
|
|
406
|
+
if (engineResults.length > 0) {
|
|
407
|
+
lines.push("## Engine Details");
|
|
408
|
+
lines.push("");
|
|
409
|
+
for (const er of engineResults) {
|
|
410
|
+
const vulns = er["vulnerabilities"]?.length ?? 0;
|
|
411
|
+
const meta = er["metadata"];
|
|
412
|
+
const duration = meta?.["duration"] ?? 0;
|
|
413
|
+
lines.push(`- **${er["engineId"]}**: ${vulns} findings, ${duration}ms`);
|
|
414
|
+
}
|
|
415
|
+
lines.push("");
|
|
416
|
+
}
|
|
417
|
+
lines.push("---");
|
|
418
|
+
lines.push(`*Report ID: ${report["id"] ?? "N/A"}*`);
|
|
419
|
+
lines.push(`*Web Dashboard: https://vs.aiclude.com/targets*`);
|
|
420
|
+
return lines.join("\n");
|
|
421
|
+
}
|
|
422
|
+
function formatScanSummary(target, scan) {
|
|
423
|
+
const lines = [];
|
|
424
|
+
const targetName = target["canonicalName"] ?? target["displayName"] ?? "Unknown";
|
|
425
|
+
const riskLevel = scan["riskLevel"] ?? target["riskLevel"] ?? "UNKNOWN";
|
|
426
|
+
const score = scan["score"] ?? target["lastScore"] ?? 0;
|
|
427
|
+
lines.push(`# Security Scan Summary: ${targetName}`);
|
|
428
|
+
lines.push("");
|
|
429
|
+
lines.push(`| Metric | Value |`);
|
|
430
|
+
lines.push(`|--------|-------|`);
|
|
431
|
+
lines.push(`| Risk Level | ${riskLevelLabel(riskLevel)} |`);
|
|
432
|
+
lines.push(`| Risk Score | ${score}/100 |`);
|
|
433
|
+
lines.push(`| Total Vulnerabilities | ${scan["totalVulnerabilities"] ?? 0} |`);
|
|
434
|
+
lines.push(`| CRITICAL | ${scan["criticalCount"] ?? 0} |`);
|
|
435
|
+
lines.push(`| HIGH | ${scan["highCount"] ?? 0} |`);
|
|
436
|
+
lines.push(`| MEDIUM | ${scan["mediumCount"] ?? 0} |`);
|
|
437
|
+
lines.push(`| LOW | ${scan["lowCount"] ?? 0} |`);
|
|
438
|
+
lines.push(`| INFO | ${scan["infoCount"] ?? 0} |`);
|
|
439
|
+
lines.push(`| Scanned At | ${scan["scannedAt"] ?? "N/A"} |`);
|
|
440
|
+
lines.push("");
|
|
441
|
+
lines.push(`*\uC0C1\uC138 \uB9AC\uD3EC\uD2B8\uB294 Web Dashboard\uC5D0\uC11C \uD655\uC778\uD558\uC138\uC694: https://vs.aiclude.com/targets*`);
|
|
442
|
+
return lines.join("\n");
|
|
443
|
+
}
|
|
444
|
+
function createServer() {
|
|
445
|
+
initDataDir();
|
|
446
|
+
let globalConfig = loadGlobalConfig();
|
|
447
|
+
const scanner = createConfiguredScanner();
|
|
448
|
+
const reporter = new ReportGenerator();
|
|
449
|
+
const server = new McpServer(
|
|
450
|
+
{
|
|
451
|
+
name: "asvs-security-scanner",
|
|
452
|
+
version: "0.1.0"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
capabilities: {
|
|
456
|
+
tools: {}
|
|
457
|
+
},
|
|
458
|
+
instructions: "AIclude Security Vulnerability Scanner (ASVS) - Scans MCP servers and Claude Code skills for security vulnerabilities including command injection, tool poisoning, prompt injection, malware, supply chain risks, and more. Use security_scan as the primary tool to check security of any MCP server or Skill by name. It automatically searches existing scan results and triggers new scans if needed. Use scan_mcp_server or scan_skill for local source code scanning. Use list_reports and get_report to review past scan results. Use configure_scan to view or adjust scanning configuration."
|
|
459
|
+
}
|
|
460
|
+
);
|
|
461
|
+
server.tool(
|
|
462
|
+
"security_scan",
|
|
463
|
+
"Search for existing security scan results of an MCP server or Claude Code Skill by name. If results exist, returns the full security report immediately. If not found, registers the target and requests a new scan. Use this as the primary tool for checking security of any MCP server or Skill. Supports npm package names (e.g., '@anthropic/mcp-server-fetch'), GitHub repos, or any registered target name.",
|
|
464
|
+
{
|
|
465
|
+
name: z.string().describe(
|
|
466
|
+
"Name of the MCP server or skill to scan. Examples: '@anthropic/mcp-server-fetch', 'mcp-server-github', 'my-skill-name'"
|
|
467
|
+
),
|
|
468
|
+
type: z.enum(["mcp-server", "skill"]).optional().describe("Target type (default: mcp-server)"),
|
|
469
|
+
description: z.string().optional().describe("Brief description of the target (used if registering a new target)"),
|
|
470
|
+
repository_url: z.string().optional().describe("Repository URL (e.g., GitHub URL)"),
|
|
471
|
+
npm_package: z.string().optional().describe("npm package name if different from the name")
|
|
472
|
+
},
|
|
473
|
+
async ({ name, type, description, repository_url, npm_package }) => {
|
|
474
|
+
try {
|
|
475
|
+
const apiBase = process.env["ASVS_API_URL"] ?? "https://vs-api.aiclude.com";
|
|
476
|
+
const apiUrl = `${apiBase}/api/v1/scan/lookup`;
|
|
477
|
+
const lookupRes = await fetch(apiUrl, {
|
|
478
|
+
method: "POST",
|
|
479
|
+
headers: createAuthHeaders("mcp", name),
|
|
480
|
+
body: JSON.stringify({
|
|
481
|
+
name,
|
|
482
|
+
type: type ?? "mcp-server",
|
|
483
|
+
description: description ?? "",
|
|
484
|
+
repositoryUrl: repository_url ?? "",
|
|
485
|
+
npmPackage: npm_package ?? "",
|
|
486
|
+
source: "mcp"
|
|
487
|
+
})
|
|
488
|
+
});
|
|
489
|
+
const lookupData = await lookupRes.json();
|
|
490
|
+
if (lookupData["status"] === "found") {
|
|
491
|
+
const report = lookupData["report"];
|
|
492
|
+
const scan = lookupData["scan"];
|
|
493
|
+
const target = lookupData["target"];
|
|
494
|
+
if (report) {
|
|
495
|
+
const markdown = formatApiReportAsMarkdown(report, target);
|
|
496
|
+
return { content: [{ type: "text", text: markdown }] };
|
|
497
|
+
}
|
|
498
|
+
const summary = formatScanSummary(target, scan);
|
|
499
|
+
return { content: [{ type: "text", text: summary }] };
|
|
500
|
+
}
|
|
501
|
+
if (lookupData["status"] === "scanning" || lookupData["status"] === "registered") {
|
|
502
|
+
const jobId = lookupData["jobId"];
|
|
503
|
+
const target = lookupData["target"];
|
|
504
|
+
const isNew = lookupData["isNew"];
|
|
505
|
+
const statusMsg = isNew ? `\uC0C8\uB85C\uC6B4 \uD0C0\uAC9F "${name}"\uC744(\uB97C) \uB4F1\uB85D\uD558\uACE0 \uBCF4\uC548 \uC2A4\uCE94\uC744 \uC694\uCCAD\uD588\uC2B5\uB2C8\uB2E4.` : `"${name}" \uD0C0\uAC9F\uC758 \uBCF4\uC548 \uC2A4\uCE94\uC744 \uC694\uCCAD\uD588\uC2B5\uB2C8\uB2E4.`;
|
|
506
|
+
const maxWait = 12e4;
|
|
507
|
+
const interval = 5e3;
|
|
508
|
+
const startTime = Date.now();
|
|
509
|
+
while (Date.now() - startTime < maxWait) {
|
|
510
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
511
|
+
const statusRes = await fetch(`${apiBase}/api/v1/scan/status/${jobId}`, {
|
|
512
|
+
headers: createAuthHeaders("mcp", name)
|
|
513
|
+
});
|
|
514
|
+
const statusData = await statusRes.json();
|
|
515
|
+
if (statusData["status"] === "completed") {
|
|
516
|
+
const report = statusData["report"];
|
|
517
|
+
const scanResult = statusData["scan"];
|
|
518
|
+
const completedTarget = statusData["target"];
|
|
519
|
+
if (report) {
|
|
520
|
+
const markdown = formatApiReportAsMarkdown(report, completedTarget);
|
|
521
|
+
return { content: [{ type: "text", text: markdown }] };
|
|
522
|
+
}
|
|
523
|
+
const summary = formatScanSummary(completedTarget, scanResult);
|
|
524
|
+
return { content: [{ type: "text", text: summary }] };
|
|
525
|
+
}
|
|
526
|
+
if (statusData["status"] === "failed") {
|
|
527
|
+
const job = statusData["job"];
|
|
528
|
+
return {
|
|
529
|
+
content: [{
|
|
530
|
+
type: "text",
|
|
531
|
+
text: `\uC2A4\uCE94 \uC2E4\uD328: ${job?.["error"] ?? "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}
|
|
532
|
+
|
|
533
|
+
\uD0C0\uAC9F: ${name}`
|
|
534
|
+
}],
|
|
535
|
+
isError: true
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
content: [{
|
|
541
|
+
type: "text",
|
|
542
|
+
text: `${statusMsg}
|
|
543
|
+
|
|
544
|
+
\uC2A4\uCE94\uC774 \uC544\uC9C1 \uC9C4\uD589 \uC911\uC785\uB2C8\uB2E4. \uC7A0\uC2DC \uD6C4 \uB2E4\uC2DC \uC774 \uB3C4\uAD6C\uB97C \uD638\uCD9C\uD558\uC5EC \uACB0\uACFC\uB97C \uD655\uC778\uD558\uC138\uC694.
|
|
545
|
+
Job ID: ${jobId}
|
|
546
|
+
\uD0C0\uAC9F: ${target["canonicalName"] ?? name}`
|
|
547
|
+
}]
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
content: [{
|
|
552
|
+
type: "text",
|
|
553
|
+
text: `API \uC751\uB2F5: ${JSON.stringify(lookupData, null, 2)}`
|
|
554
|
+
}]
|
|
555
|
+
};
|
|
556
|
+
} catch (error) {
|
|
557
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
558
|
+
return {
|
|
559
|
+
content: [{
|
|
560
|
+
type: "text",
|
|
561
|
+
text: `\uBCF4\uC548 \uC2A4\uCE94 \uC870\uD68C \uC911 \uC624\uB958 \uBC1C\uC0DD: ${message}`
|
|
562
|
+
}],
|
|
563
|
+
isError: true
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
);
|
|
568
|
+
server.tool(
|
|
569
|
+
"scan_mcp_server",
|
|
570
|
+
"Scan an MCP server for security vulnerabilities including command injection, tool poisoning, prompt injection, supply chain risks, malware, and permission issues. Returns a comprehensive security report with risk levels, findings, and remediation steps.",
|
|
571
|
+
{
|
|
572
|
+
server_path: z.string().describe(
|
|
573
|
+
"Path to the MCP server source code or installation directory"
|
|
574
|
+
),
|
|
575
|
+
sandbox_profile: z.enum(["strict", "standard", "permissive"]).optional().describe(
|
|
576
|
+
"Sandbox isolation profile for dynamic testing (default: standard)"
|
|
577
|
+
)
|
|
578
|
+
},
|
|
579
|
+
async ({ server_path, sandbox_profile }) => {
|
|
580
|
+
try {
|
|
581
|
+
const resolvedPath = validateScanPath(server_path);
|
|
582
|
+
const target = {
|
|
583
|
+
type: "mcp-server",
|
|
584
|
+
name: resolvedPath,
|
|
585
|
+
path: resolvedPath
|
|
586
|
+
};
|
|
587
|
+
const scanConfig = buildScanConfig(globalConfig, {
|
|
588
|
+
sandboxProfile: sandbox_profile
|
|
589
|
+
});
|
|
590
|
+
const scanResult = await scanner.scan(target, scanConfig);
|
|
591
|
+
const report = reporter.generate(scanResult, "markdown");
|
|
592
|
+
saveReport(globalConfig, report);
|
|
593
|
+
const markdown = formatReportAsMarkdown(report);
|
|
594
|
+
return {
|
|
595
|
+
content: [{ type: "text", text: markdown }]
|
|
596
|
+
};
|
|
597
|
+
} catch (error) {
|
|
598
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
599
|
+
return {
|
|
600
|
+
content: [
|
|
601
|
+
{
|
|
602
|
+
type: "text",
|
|
603
|
+
text: `Error scanning MCP server: ${message}`
|
|
604
|
+
}
|
|
605
|
+
],
|
|
606
|
+
isError: true
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
);
|
|
611
|
+
server.tool(
|
|
612
|
+
"scan_skill",
|
|
613
|
+
"Scan a Claude Code skill for security vulnerabilities including hidden instructions, obfuscated code, filesystem abuse, prompt injection patterns, and malware. Returns a security report with risk assessment and usage precautions.",
|
|
614
|
+
{
|
|
615
|
+
skill_path: z.string().describe("Path to the skill directory containing SKILL.md")
|
|
616
|
+
},
|
|
617
|
+
async ({ skill_path }) => {
|
|
618
|
+
try {
|
|
619
|
+
const resolvedPath = validateScanPath(skill_path);
|
|
620
|
+
const target = {
|
|
621
|
+
type: "skill",
|
|
622
|
+
name: resolvedPath,
|
|
623
|
+
path: resolvedPath
|
|
624
|
+
};
|
|
625
|
+
const scanConfig = buildScanConfig(globalConfig);
|
|
626
|
+
const scanResult = await scanner.scan(target, scanConfig);
|
|
627
|
+
const report = reporter.generate(scanResult, "markdown");
|
|
628
|
+
saveReport(globalConfig, report);
|
|
629
|
+
const markdown = formatReportAsMarkdown(report);
|
|
630
|
+
return {
|
|
631
|
+
content: [{ type: "text", text: markdown }]
|
|
632
|
+
};
|
|
633
|
+
} catch (error) {
|
|
634
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
635
|
+
return {
|
|
636
|
+
content: [
|
|
637
|
+
{
|
|
638
|
+
type: "text",
|
|
639
|
+
text: `Error scanning skill: ${message}`
|
|
640
|
+
}
|
|
641
|
+
],
|
|
642
|
+
isError: true
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
);
|
|
647
|
+
server.tool(
|
|
648
|
+
"get_report",
|
|
649
|
+
"Retrieve a specific security scan report by its ID. Supports JSON, markdown, and HTML output formats.",
|
|
650
|
+
{
|
|
651
|
+
report_id: z.string().describe("The report UUID"),
|
|
652
|
+
format: z.enum(["json", "markdown", "html"]).optional().describe("Output format (default: markdown)")
|
|
653
|
+
},
|
|
654
|
+
async ({ report_id, format }) => {
|
|
655
|
+
try {
|
|
656
|
+
const report = loadReport(globalConfig, report_id);
|
|
657
|
+
if (!report) {
|
|
658
|
+
return {
|
|
659
|
+
content: [
|
|
660
|
+
{
|
|
661
|
+
type: "text",
|
|
662
|
+
text: `Report not found: ${report_id}`
|
|
663
|
+
}
|
|
664
|
+
],
|
|
665
|
+
isError: true
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
const outputFormat = format ?? "markdown";
|
|
669
|
+
let text;
|
|
670
|
+
switch (outputFormat) {
|
|
671
|
+
case "json":
|
|
672
|
+
text = JSON.stringify(report, null, 2);
|
|
673
|
+
break;
|
|
674
|
+
case "html":
|
|
675
|
+
text = formatReportAsHtml(report);
|
|
676
|
+
break;
|
|
677
|
+
case "markdown":
|
|
678
|
+
default:
|
|
679
|
+
text = formatReportAsMarkdown(report);
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
return {
|
|
683
|
+
content: [{ type: "text", text }]
|
|
684
|
+
};
|
|
685
|
+
} catch (error) {
|
|
686
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
687
|
+
return {
|
|
688
|
+
content: [
|
|
689
|
+
{
|
|
690
|
+
type: "text",
|
|
691
|
+
text: `Error retrieving report: ${message}`
|
|
692
|
+
}
|
|
693
|
+
],
|
|
694
|
+
isError: true
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
server.tool(
|
|
700
|
+
"list_reports",
|
|
701
|
+
"List available security scan reports with optional filtering by severity and limit.",
|
|
702
|
+
{
|
|
703
|
+
severity_filter: z.enum(["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]).optional().describe(
|
|
704
|
+
"Filter to only show reports with at least this severity level"
|
|
705
|
+
),
|
|
706
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum number of reports to return (default: 20)")
|
|
707
|
+
},
|
|
708
|
+
async ({ severity_filter, limit }) => {
|
|
709
|
+
try {
|
|
710
|
+
const summaries = listReportSummaries(globalConfig, {
|
|
711
|
+
severityFilter: severity_filter,
|
|
712
|
+
limit
|
|
713
|
+
});
|
|
714
|
+
if (summaries.length === 0) {
|
|
715
|
+
return {
|
|
716
|
+
content: [
|
|
717
|
+
{
|
|
718
|
+
type: "text",
|
|
719
|
+
text: "No reports found." + (severity_filter ? ` (filtered by severity >= ${severity_filter})` : "")
|
|
720
|
+
}
|
|
721
|
+
]
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
const lines = [];
|
|
725
|
+
lines.push(`# Security Scan Reports (${summaries.length})`);
|
|
726
|
+
lines.push("");
|
|
727
|
+
lines.push(
|
|
728
|
+
"| # | Risk | Target | Type | Findings | Date | Report ID |"
|
|
729
|
+
);
|
|
730
|
+
lines.push(
|
|
731
|
+
"|---|------|--------|------|----------|------|-----------|"
|
|
732
|
+
);
|
|
733
|
+
for (const [i, s] of summaries.entries()) {
|
|
734
|
+
const date = new Date(s.generatedAt).toLocaleDateString();
|
|
735
|
+
lines.push(
|
|
736
|
+
`| ${i + 1} | ${riskLevelLabel(s.overallRiskLevel)} | ${s.targetName} | ${s.targetType} | ${s.totalVulnerabilities} | ${date} | \`${s.id.slice(0, 8)}...\` |`
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
lines.push("");
|
|
740
|
+
lines.push(
|
|
741
|
+
"_Use `get_report` with the full report ID to view details._"
|
|
742
|
+
);
|
|
743
|
+
return {
|
|
744
|
+
content: [{ type: "text", text: lines.join("\n") }]
|
|
745
|
+
};
|
|
746
|
+
} catch (error) {
|
|
747
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
748
|
+
return {
|
|
749
|
+
content: [
|
|
750
|
+
{
|
|
751
|
+
type: "text",
|
|
752
|
+
text: `Error listing reports: ${message}`
|
|
753
|
+
}
|
|
754
|
+
],
|
|
755
|
+
isError: true
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
);
|
|
760
|
+
server.tool(
|
|
761
|
+
"configure_scan",
|
|
762
|
+
"View or update the global ASVS scan configuration. Use action 'get' to view current settings, or 'set' with a key and value to update.",
|
|
763
|
+
{
|
|
764
|
+
action: z.enum(["get", "set"]).describe("Get current config or set new values"),
|
|
765
|
+
key: z.string().optional().describe(
|
|
766
|
+
"Configuration key to get or set (dot notation, e.g., 'webDashboard.port'). Required when action is 'set'. When omitted with 'get', returns entire config."
|
|
767
|
+
),
|
|
768
|
+
value: z.string().optional().describe(
|
|
769
|
+
"Value to set (will be parsed as JSON if possible, otherwise treated as string). Required when action is 'set'."
|
|
770
|
+
)
|
|
771
|
+
},
|
|
772
|
+
async ({ action, key, value }) => {
|
|
773
|
+
try {
|
|
774
|
+
if (action === "get") {
|
|
775
|
+
if (key) {
|
|
776
|
+
const val = getNestedValue(
|
|
777
|
+
globalConfig,
|
|
778
|
+
key
|
|
779
|
+
);
|
|
780
|
+
if (val === void 0) {
|
|
781
|
+
return {
|
|
782
|
+
content: [
|
|
783
|
+
{
|
|
784
|
+
type: "text",
|
|
785
|
+
text: `Configuration key not found: ${key}`
|
|
786
|
+
}
|
|
787
|
+
],
|
|
788
|
+
isError: true
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
return {
|
|
792
|
+
content: [
|
|
793
|
+
{
|
|
794
|
+
type: "text",
|
|
795
|
+
text: `**${key}**: ${JSON.stringify(val, null, 2)}`
|
|
796
|
+
}
|
|
797
|
+
]
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
return {
|
|
801
|
+
content: [
|
|
802
|
+
{
|
|
803
|
+
type: "text",
|
|
804
|
+
text: "# ASVS Global Configuration\n\n```json\n" + JSON.stringify(globalConfig, null, 2) + "\n```"
|
|
805
|
+
}
|
|
806
|
+
]
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
if (!key) {
|
|
810
|
+
return {
|
|
811
|
+
content: [
|
|
812
|
+
{
|
|
813
|
+
type: "text",
|
|
814
|
+
text: "Error: 'key' is required when action is 'set'"
|
|
815
|
+
}
|
|
816
|
+
],
|
|
817
|
+
isError: true
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
if (value === void 0) {
|
|
821
|
+
return {
|
|
822
|
+
content: [
|
|
823
|
+
{
|
|
824
|
+
type: "text",
|
|
825
|
+
text: "Error: 'value' is required when action is 'set'"
|
|
826
|
+
}
|
|
827
|
+
],
|
|
828
|
+
isError: true
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
const parsed = parseConfigValue(value);
|
|
832
|
+
const configObj = globalConfig;
|
|
833
|
+
setNestedValue(configObj, key, parsed);
|
|
834
|
+
globalConfig = configObj;
|
|
835
|
+
saveGlobalConfig(globalConfig);
|
|
836
|
+
return {
|
|
837
|
+
content: [
|
|
838
|
+
{
|
|
839
|
+
type: "text",
|
|
840
|
+
text: `Configuration updated: **${key}** = ${JSON.stringify(parsed)}`
|
|
841
|
+
}
|
|
842
|
+
]
|
|
843
|
+
};
|
|
844
|
+
} catch (error) {
|
|
845
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
846
|
+
return {
|
|
847
|
+
content: [
|
|
848
|
+
{
|
|
849
|
+
type: "text",
|
|
850
|
+
text: `Error configuring scan: ${message}`
|
|
851
|
+
}
|
|
852
|
+
],
|
|
853
|
+
isError: true
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
return server;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// src/index.ts
|
|
862
|
+
async function main() {
|
|
863
|
+
const server = createServer();
|
|
864
|
+
const transport = new StdioServerTransport();
|
|
865
|
+
await server.connect(transport);
|
|
866
|
+
console.error("[asvs] MCP server started on stdio transport");
|
|
867
|
+
}
|
|
868
|
+
main().catch((error) => {
|
|
869
|
+
console.error("[asvs] Fatal error:", error);
|
|
870
|
+
process.exit(1);
|
|
871
|
+
});
|
|
872
|
+
export {
|
|
873
|
+
createServer
|
|
874
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aiclude/security-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AIclude Security Vulnerability Scanner - MCP Server for scanning MCP servers and Skills for security vulnerabilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"asvs-mcp": "./dist/index.js",
|
|
10
|
+
"aiclude-security": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"mcp",
|
|
20
|
+
"mcp-server",
|
|
21
|
+
"security",
|
|
22
|
+
"vulnerability",
|
|
23
|
+
"scanner",
|
|
24
|
+
"ai-agent",
|
|
25
|
+
"claude",
|
|
26
|
+
"cursor",
|
|
27
|
+
"aiclude",
|
|
28
|
+
"sast",
|
|
29
|
+
"sca",
|
|
30
|
+
"malware",
|
|
31
|
+
"prompt-injection",
|
|
32
|
+
"tool-poisoning"
|
|
33
|
+
],
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"author": "AICLUDE Inc. <dev@aiclude.com>",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/aiclude/asvs"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://vs.aiclude.com",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/aiclude/asvs/issues"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20.0.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
],
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
57
|
+
"zod": "^3.25.0",
|
|
58
|
+
"@asvs/core": "0.1.0",
|
|
59
|
+
"@asvs/reporter": "0.1.0",
|
|
60
|
+
"@asvs/sandbox": "0.1.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"tsup": "^8.0.0",
|
|
64
|
+
"typescript": "^5.5.0"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
68
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
69
|
+
"start": "node dist/index.js",
|
|
70
|
+
"test": "vitest run",
|
|
71
|
+
"clean": "rm -rf dist"
|
|
72
|
+
}
|
|
73
|
+
}
|