visus-mcp 0.8.0 → 0.10.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 (101) hide show
  1. package/.claude/settings.local.json +18 -1
  2. package/.env.example +55 -0
  3. package/CHANGELOG.md +45 -0
  4. package/CRYPTO-PROOF-SPEC.md +244 -0
  5. package/README.md +175 -17
  6. package/SECURITY.md +93 -0
  7. package/STATUS.md +283 -7
  8. package/dist/audit/logger.d.ts +90 -0
  9. package/dist/audit/logger.d.ts.map +1 -0
  10. package/dist/audit/logger.js +170 -0
  11. package/dist/audit/logger.js.map +1 -0
  12. package/dist/audit/middleware.d.ts +51 -0
  13. package/dist/audit/middleware.d.ts.map +1 -0
  14. package/dist/audit/middleware.js +138 -0
  15. package/dist/audit/middleware.js.map +1 -0
  16. package/dist/audit/report.d.ts +96 -0
  17. package/dist/audit/report.d.ts.map +1 -0
  18. package/dist/audit/report.js +224 -0
  19. package/dist/audit/report.js.map +1 -0
  20. package/dist/audit/schema.d.ts +128 -0
  21. package/dist/audit/schema.d.ts.map +1 -0
  22. package/dist/audit/schema.js +108 -0
  23. package/dist/audit/schema.js.map +1 -0
  24. package/dist/browser/playwright-renderer.d.ts.map +1 -1
  25. package/dist/browser/playwright-renderer.js +27 -5
  26. package/dist/browser/playwright-renderer.js.map +1 -1
  27. package/dist/crypto/primitives.d.ts +188 -0
  28. package/dist/crypto/primitives.d.ts.map +1 -0
  29. package/dist/crypto/primitives.js +192 -0
  30. package/dist/crypto/primitives.js.map +1 -0
  31. package/dist/crypto/proof-builder.d.ts +43 -0
  32. package/dist/crypto/proof-builder.d.ts.map +1 -0
  33. package/dist/crypto/proof-builder.js +110 -0
  34. package/dist/crypto/proof-builder.js.map +1 -0
  35. package/dist/crypto/verifier.d.ts +54 -0
  36. package/dist/crypto/verifier.d.ts.map +1 -0
  37. package/dist/crypto/verifier.js +61 -0
  38. package/dist/crypto/verifier.js.map +1 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +35 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/lambda-handler.js +1 -1
  43. package/dist/lambda-handler.js.map +1 -1
  44. package/dist/sanitizer/framework-mapper.d.ts +4 -0
  45. package/dist/sanitizer/framework-mapper.d.ts.map +1 -1
  46. package/dist/sanitizer/framework-mapper.js +92 -0
  47. package/dist/sanitizer/framework-mapper.js.map +1 -1
  48. package/dist/sanitizer/index.d.ts +24 -0
  49. package/dist/sanitizer/index.d.ts.map +1 -1
  50. package/dist/sanitizer/index.js +48 -0
  51. package/dist/sanitizer/index.js.map +1 -1
  52. package/dist/sanitizer/threat-reporter.d.ts +5 -0
  53. package/dist/sanitizer/threat-reporter.d.ts.map +1 -1
  54. package/dist/sanitizer/threat-reporter.js +15 -6
  55. package/dist/sanitizer/threat-reporter.js.map +1 -1
  56. package/dist/tools/fetch-structured.d.ts.map +1 -1
  57. package/dist/tools/fetch-structured.js +4 -0
  58. package/dist/tools/fetch-structured.js.map +1 -1
  59. package/dist/tools/fetch.d.ts.map +1 -1
  60. package/dist/tools/fetch.js +14 -5
  61. package/dist/tools/fetch.js.map +1 -1
  62. package/dist/tools/read.d.ts.map +1 -1
  63. package/dist/tools/read.js +12 -5
  64. package/dist/tools/read.js.map +1 -1
  65. package/dist/tools/report.d.ts +62 -0
  66. package/dist/tools/report.d.ts.map +1 -0
  67. package/dist/tools/report.js +97 -0
  68. package/dist/tools/report.js.map +1 -0
  69. package/dist/tools/search.d.ts.map +1 -1
  70. package/dist/tools/search.js +8 -3
  71. package/dist/tools/search.js.map +1 -1
  72. package/dist/tools/verify.d.ts +48 -0
  73. package/dist/tools/verify.d.ts.map +1 -0
  74. package/dist/tools/verify.js +60 -0
  75. package/dist/tools/verify.js.map +1 -0
  76. package/dist/types.d.ts +9 -1
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/types.js.map +1 -1
  79. package/package.json +1 -1
  80. package/server.json +25 -14
  81. package/src/audit/README.md +177 -0
  82. package/src/audit/logger.ts +285 -0
  83. package/src/audit/middleware.ts +183 -0
  84. package/src/audit/report.ts +304 -0
  85. package/src/audit/schema.ts +272 -0
  86. package/src/browser/playwright-renderer.ts +29 -6
  87. package/src/crypto/primitives.ts +309 -0
  88. package/src/crypto/proof-builder.ts +166 -0
  89. package/src/crypto/verifier.ts +103 -0
  90. package/src/index.ts +47 -1
  91. package/src/lambda-handler.ts +1 -1
  92. package/src/sanitizer/framework-mapper.ts +94 -0
  93. package/src/sanitizer/index.ts +69 -0
  94. package/src/sanitizer/threat-reporter.ts +17 -6
  95. package/src/tools/fetch-structured.ts +5 -0
  96. package/src/tools/fetch.ts +15 -5
  97. package/src/tools/read.ts +13 -5
  98. package/src/tools/report.ts +122 -0
  99. package/src/tools/search.ts +14 -3
  100. package/src/tools/verify.ts +64 -0
  101. package/src/types.ts +9 -1
@@ -60,7 +60,24 @@
60
60
  "Bash(unzip:*)",
61
61
  "Bash(mkdir:*)",
62
62
  "Bash(comm -13:*)",
63
- "Bash(comm -23:*)"
63
+ "Bash(comm -23:*)",
64
+ "Bash(npx @modelcontextprotocol/registry-cli:*)",
65
+ "Bash(make:*)",
66
+ "Bash(tar:*)",
67
+ "Bash(./mcp-publisher:*)",
68
+ "Bash(/tmp/mcp-publisher auth login:*)",
69
+ "Bash(/tmp/mcp-publisher login:*)",
70
+ "Bash(/tmp/mcp-publisher publish:*)",
71
+ "WebFetch(domain:airc.nist.gov)",
72
+ "WebFetch(domain:csf.tools)",
73
+ "Bash(npx ts-node:*)",
74
+ "Bash(npx tsc:*)",
75
+ "Bash(npm --version:*)",
76
+ "Bash(env)",
77
+ "Bash(.gitignore)",
78
+ "Bash(npm whoami:*)",
79
+ "Bash(npm login:*)",
80
+ "Bash(~/.npmrc)"
64
81
  ],
65
82
  "deny": [],
66
83
  "ask": []
package/.env.example ADDED
@@ -0,0 +1,55 @@
1
+ # Visus-MCP Environment Configuration
2
+ # Copy this file to .env and fill in your values
3
+
4
+ # =======================================
5
+ # Cryptographic Configuration
6
+ # =======================================
7
+
8
+ # REQUIRED for production proof signatures.
9
+ # Generate: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
10
+ # Minimum length: 32 bytes (64 hex chars recommended)
11
+ # Rotate: on compromise, on personnel change, on annual audit cycle
12
+ VISUS_HMAC_SECRET=
13
+
14
+ # =======================================
15
+ # Audit Configuration
16
+ # =======================================
17
+
18
+ # DynamoDB audit table name
19
+ VISUS_AUDIT_TABLE=visus-audit-log
20
+
21
+ # AWS region for DynamoDB
22
+ AWS_REGION=us-east-1
23
+
24
+ # Set to "true" to make audit write failures propagate (fail-closed)
25
+ # Default "false" = fail-open (audit failure does not break tool call)
26
+ AUDIT_FAIL_CLOSED=false
27
+
28
+ # Set to "false" to disable audit logging (dev/test only)
29
+ VISUS_AUDIT_ENABLED=true
30
+
31
+ # =======================================
32
+ # Browser Configuration (optional)
33
+ # =======================================
34
+
35
+ # Fetch timeout in milliseconds
36
+ VISUS_TIMEOUT_MS=10000
37
+
38
+ # Max content size before truncation (in KB)
39
+ VISUS_MAX_CONTENT_KB=512
40
+
41
+ # =======================================
42
+ # Lambda Configuration (Hosted tier only)
43
+ # =======================================
44
+
45
+ # Lambda function ARN (set by CDK)
46
+ # LAMBDA_FUNCTION_ARN=
47
+
48
+ # API Gateway endpoint (set by CDK)
49
+ # API_GATEWAY_ENDPOINT=
50
+
51
+ # Cognito User Pool ID (set by CDK)
52
+ # COGNITO_USER_POOL_ID=
53
+
54
+ # Cognito App Client ID (set by CDK)
55
+ # COGNITO_APP_CLIENT_ID=
package/CHANGELOG.md CHANGED
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.9.0] - 2026-03-26
11
+
12
+ ### Added
13
+
14
+ - **NIST AI RMF Framework Mappings** (`src/sanitizer/framework-mapper.ts`)
15
+ - Added NIST AI Risk Management Framework (AI 100-1) mappings for all 43 injection patterns
16
+ - Maps threats to four core functions: GOVERN, MAP, MEASURE, and MANAGE
17
+ - Examples: GOVERN-1.1 (Legal Requirements), MEASURE-2.7 (AI System Security), MANAGE-2.3 (Respond to Unknown Risks)
18
+ - Provides comprehensive risk management alignment for federal/government users
19
+
20
+ - **NIST CSF 2.0 Framework Mappings** (`src/sanitizer/framework-mapper.ts`)
21
+ - Added NIST Cybersecurity Framework 2.0 mappings for all 43 injection patterns
22
+ - Maps threats to six core functions: IDENTIFY, PROTECT, DETECT, RESPOND, RECOVER, and GOVERN
23
+ - Examples: DE.CM-01 (Network Monitoring), PR.DS-01 (Data at Rest Protection), PR.AC-04 (Access Control)
24
+ - Widely adopted enterprise cybersecurity framework for compliance and audit requirements
25
+
26
+ - **Enhanced Threat Reporting** (`src/sanitizer/threat-reporter.ts`)
27
+ - Expanded framework coverage from 4 to 6 compliance frameworks
28
+ - Updated TOON format from 10 fields to 12 fields (added nist_ai_rmf, nist_csf_2_0)
29
+ - Enhanced Markdown threat report table with new AI-RMF and CSF 2.0 columns
30
+ - All threat reports now include comprehensive 6-framework alignment
31
+
32
+ ### Changed
33
+
34
+ - **Framework Badge** (README.md) - Updated security badge to highlight NIST AI RMF and CSF 2.0
35
+ - **Tool Descriptions** (README.md) - All 4 MCP tools now reference 6 frameworks in their descriptions
36
+ - **Framework Alignments Section** (README.md) - Expanded to document all 6 frameworks with descriptions
37
+ - **Test Coverage** (tests/threat-reporter.test.ts) - Updated to verify 6 frameworks and 12 TOON fields
38
+
39
+ ### Fixed
40
+
41
+ - **server.json Version Sync** - Ensured server.json version matches package.json per MCP Registry requirements
42
+
43
+ ## [0.8.1] - 2026-03-25
44
+
10
45
  ### Added
11
46
 
12
47
  - **PDF Content Handler** (`src/content-handlers/pdf-handler.ts`)
@@ -56,9 +91,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
56
91
  - Tests for error handling (corrupt/invalid content)
57
92
  - Tests for edge cases (nested structures, arrays, malformed input)
58
93
 
94
+ ### Fixed
95
+
96
+ - **PDF Text Extraction** - Fixed critical bug where PDF content was passed as corrupted UTF-8 strings instead of binary data
97
+ - Root cause: `response.text()` in `playwright-renderer.ts` converted all response bodies to strings, mangling binary PDFs
98
+ - Fix: Use `response.arrayBuffer()` for binary content types (`application/pdf`, `image/*`, `application/octet-stream`)
99
+ - Impact: PDF handler now receives proper binary data, text extraction works correctly
100
+ - Files modified: `src/types.ts`, `src/browser/playwright-renderer.ts`, `src/tools/fetch.ts`, `src/tools/read.ts`, `src/tools/fetch-structured.ts`
101
+ - Note: Some complex PDFs may fail with "Invalid Root reference" error - this is a limitation of the pdf-parse library, not Visus
102
+
59
103
  ### Changed
60
104
 
61
105
  - Added `pdf-parse` dependency (v2.4.5) for PDF text extraction
106
+ - Updated `BrowserRenderResult.html` type to `string | Buffer` to support binary content
62
107
 
63
108
  ## [0.6.2] - 2026-03-14
64
109
 
@@ -0,0 +1,244 @@
1
+ # Visus-MCP Cryptographic Proof Specification
2
+
3
+ Version: 1.0.0
4
+ Status: Normative
5
+ Regulatory basis: EU AI Act Art. 9, 11, 13, 15 | GDPR Art. 5(2), 32
6
+
7
+ ---
8
+
9
+ ## Purpose
10
+
11
+ This document specifies the cryptographic proof scheme used by Visus-MCP to
12
+ provide verifiable, tamper-evident evidence that its prompt injection
13
+ sanitization pipeline executed before any web content was forwarded to a
14
+ large language model.
15
+
16
+ Any third party — regulator, DPA, conformity assessment body, or security
17
+ researcher — can independently verify any Visus-MCP proof record using only
18
+ this specification and standard SHA-256 / HMAC-SHA-256 implementations.
19
+
20
+ ---
21
+
22
+ ## Proof Fields
23
+
24
+ Every Visus-MCP tool response includes a `visus_proof` object with these fields:
25
+
26
+ | Field | Type | Description |
27
+ |---|---|---|
28
+ | `request_id` | hex string (32 chars) | Unique identifier for this tool call |
29
+ | `proof_hash` | hex string (64 chars) | SHA-256 commitment over all proof fields |
30
+ | `chain_hash` | hex string (64 chars) | Links this proof to previous proof |
31
+ | `injection_detected` | boolean | Whether any injection pattern fired |
32
+ | `patterns_evaluated` | integer | Total patterns checked |
33
+ | `patterns_triggered` | integer | Patterns that fired |
34
+ | `redactions` | integer | Number of redactions applied |
35
+ | `sanitization_applied` | boolean | Whether content was modified |
36
+ | `timestamp_utc` | ISO 8601 string | When sanitization completed |
37
+ | `pipeline_version` | semver string | Sanitization library version |
38
+ | `schema_version` | semver string | Proof schema version |
39
+
40
+ The `proof_signature` (HMAC) is stored in the audit log but **not** returned
41
+ in tool responses. It is disclosed only to authorised auditors.
42
+
43
+ ---
44
+
45
+ ## Proof Hash Computation
46
+
47
+ The `proof_hash` is computed as:
48
+
49
+ ```
50
+ proof_hash = SHA-256(canonical_string)
51
+
52
+ canonical_string = join([
53
+ request_id,
54
+ input_hash,
55
+ output_hash,
56
+ sorted(triggered_pattern_ids).join(","),
57
+ str(patterns_evaluated),
58
+ timestamp_utc,
59
+ pipeline_version,
60
+ ], separator="\x00|\x00")
61
+ ```
62
+
63
+ Where:
64
+
65
+ - `input_hash = SHA-256(raw_content_utf8)` — hash of content BEFORE sanitization
66
+ - `output_hash = SHA-256(sanitized_content_utf8)` — hash of content AFTER sanitization
67
+ - `triggered_pattern_ids` = sorted lexicographically before joining
68
+ - All string encoding is UTF-8
69
+ - The field separator `\x00|\x00` (null-pipe-null) prevents field boundary ambiguity
70
+
71
+ ---
72
+
73
+ ## Proof Signature Computation
74
+
75
+ ```
76
+ proof_signature = HMAC-SHA-256(proof_hash, VISUS_HMAC_SECRET)
77
+ ```
78
+
79
+ The signature is disclosed to authorised auditors under NDA. It proves the
80
+ proof was issued by a pipeline instance holding the secret key, not forged
81
+ by an external observer.
82
+
83
+ ---
84
+
85
+ ## Chain Hash Computation
86
+
87
+ ```
88
+ chain_hash = SHA-256(previous_proof_hash + "\x00|\x00" + current_proof_hash)
89
+ ```
90
+
91
+ - First record: `previous_proof_hash = "GENESIS"`
92
+ - The chain allows auditors to detect gaps (deleted records) or reordering.
93
+
94
+ ---
95
+
96
+ ## Verification Procedure
97
+
98
+ ### Hash-only verification (no signing key required)
99
+
100
+ 1. Obtain `request_id`, `timestamp_utc`, `pipeline_version`, `patterns_evaluated`, `patterns_triggered` from the `visus_proof` object
101
+ 2. Obtain `input_hash` and `output_hash` from the audit log record
102
+ 3. Obtain `triggered_pattern_ids` (list) from the audit log record
103
+ 4. Recompute `canonical_string` using the formula above
104
+ 5. Compute `SHA-256(canonical_string)`
105
+ 6. Compare against `proof_hash` — must match byte-for-byte
106
+
107
+ ### Full cryptographic verification (requires signing key)
108
+
109
+ 1. Perform hash-only verification first
110
+ 2. Compute `HMAC-SHA-256(recomputed_proof_hash, VISUS_HMAC_SECRET)`
111
+ 3. Compare against `proof_signature` from audit log — must match byte-for-byte
112
+
113
+ ### Using the `visus_verify` MCP tool
114
+
115
+ ```json
116
+ {
117
+ "tool": "visus_verify",
118
+ "input": {
119
+ "proof": { "<paste the visus_proof object here>" },
120
+ "signingKey": "<VISUS_HMAC_SECRET — omit for hash-only>"
121
+ }
122
+ }
123
+ ```
124
+
125
+ ### Using the CLI verifier
126
+
127
+ ```bash
128
+ # TypeScript
129
+ echo '{"proof": {...}, "signingKey": "..."}' | \
130
+ node dist/crypto/verifier.js
131
+
132
+ # Exit code 0 = valid, 1 = invalid, 2 = parse error
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Regulatory Mapping
138
+
139
+ | Proof Component | EU AI Act | GDPR |
140
+ |---|---|---|
141
+ | `input_hash` + `output_hash` | Art. 15 Robustness — proves pipeline ran | Art. 32 Security — cryptographic evidence |
142
+ | `proof_hash` | Art. 9 Risk Management — tamper-evident record | Art. 5(2) Accountability — verifiable |
143
+ | `proof_signature` (audit-only) | Art. 11 Technical Documentation | Art. 32(1)(d) Regular testing evidence |
144
+ | `chain_hash` | Art. 9 Risk Management — deletion detection | Art. 5(2) Accountability |
145
+ | `visus_verify` tool | Art. 13 Transparency — callable verification | Art. 30 Records — machine-readable |
146
+ | `patterns_evaluated` / `patterns_triggered` | Art. 9(4) Risk Management documentation | Art. 32 — evidence of controls |
147
+
148
+ ### Presumption of Conformity Path
149
+
150
+ Deployers can reference this specification as part of the technical
151
+ documentation required under EU AI Act Annex IV. The `visus_verify` tool
152
+ constitutes the "testing, validation and verification procedures" required
153
+ by Annex IV §2(f).
154
+
155
+ ---
156
+
157
+ ## Security Properties
158
+
159
+ | Property | Mechanism | Guarantee |
160
+ |---|---|---|
161
+ | **Tamper evidence** | SHA-256 over all fields | Any field change invalidates proof_hash |
162
+ | **Authenticity** | HMAC-SHA-256 with secret key | Proves pipeline issued the proof |
163
+ | **Non-repudiation** | Audit log + chain_hash | Deletion of records is detectable |
164
+ | **Privacy preservation** | Hashes only, no raw content | Verification without data exposure |
165
+ | **Timing safety** | `timingSafeEqual` / `hmac.compare_digest` | No timing oracle on verification |
166
+ | **Ordering proof** | Chain hash | Record sequence is tamper-evident |
167
+
168
+ ---
169
+
170
+ ## Reference Implementation Test Vectors
171
+
172
+ Use these to verify your implementation is correct:
173
+
174
+ ### Input:
175
+ ```
176
+ request_id = "test-request-id-0000"
177
+ input_hash = SHA-256("raw content")
178
+ = "a6e5d15bf571ca7a23fd704caad6c4c071210ba8d38ea0296dc58c3ce0a0e514"
179
+ output_hash = SHA-256("clean content")
180
+ = "573b1d8589d0623b86749785dae7a299483d140d551299578f0fcb30bdcece28"
181
+ triggered_pattern_ids = ["PI-001", "PI-007"] (sort → ["PI-001","PI-007"])
182
+ patterns_evaluated = 43
183
+ timestamp_utc = "2026-03-26T00:00:00.000Z"
184
+ pipeline_version = "1.0.0"
185
+
186
+ canonical_string = "test-request-id-0000\x00|\x00a6e5d15bf571ca7a23fd704caad6c4c071210ba8d38ea0296dc58c3ce0a0e514\x00|\x00573b1d8589d0623b86749785dae7a299483d140d551299578f0fcb30bdcece28\x00|\x00PI-001,PI-007\x00|\x0043\x00|\x002026-03-26T00:00:00.000Z\x00|\x001.0.0"
187
+ ```
188
+
189
+ ### Expected Output:
190
+ ```
191
+ proof_hash = "9cda5595b2f9865e1f1f50ac366a79daa488bd85db02551c20c3de22a65c902d"
192
+
193
+ signing_key = "test-signing-key-for-spec-vectors-only-000000"
194
+ proof_signature = "0d7a6102117ed1c6d5ceb8dcc132000f96ddf3d1c4a97bf18328063dded959b5"
195
+ ```
196
+
197
+ ### Verification:
198
+
199
+ Recompute the `proof_hash` from the inputs above. It must match exactly. Then compute the HMAC signature using the test signing key. It must also match exactly.
200
+
201
+ If either hash does not match, your implementation is incorrect. Common causes:
202
+ - Field ordering wrong in canonical string
203
+ - Separator string incorrect (must be `\x00|\x00`)
204
+ - Pattern IDs not sorted lexicographically
205
+ - Encoding not UTF-8
206
+ - Extra whitespace or newlines in canonical string
207
+
208
+ ---
209
+
210
+ ## Compliance Checklist
211
+
212
+ For deployers preparing for conformity assessment under EU AI Act:
213
+
214
+ - [ ] `VISUS_HMAC_SECRET` configured in production (minimum 32 bytes)
215
+ - [ ] Audit logging enabled (`VISUS_AUDIT_ENABLED=true`)
216
+ - [ ] Audit records retained for 90 days minimum
217
+ - [ ] `visus_verify` tool accessible to auditors
218
+ - [ ] Test vectors verified against your deployment
219
+ - [ ] Chain tip persisted across server restarts (if applicable)
220
+ - [ ] HMAC key rotation procedure documented
221
+ - [ ] Incident response plan for key compromise
222
+ - [ ] Data sharing agreement covers proof signature disclosure to DPAs
223
+ - [ ] Technical documentation references this specification
224
+
225
+ ---
226
+
227
+ ## Changelog
228
+
229
+ | Version | Date | Changes |
230
+ |---|---|---|
231
+ | 1.0.0 | 2026-03-28 | Initial release — comprehensive cryptographic proof system |
232
+
233
+ ---
234
+
235
+ ## Contact
236
+
237
+ For questions about this specification or security disclosures:
238
+
239
+ - Email: security@lateos.ai
240
+ - GitHub: https://github.com/visus-mcp/visus-mcp/security
241
+
242
+ ---
243
+
244
+ **End of Specification**