visus-mcp 0.2.0 → 0.6.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 (107) hide show
  1. package/.claude/settings.local.json +22 -0
  2. package/LINKEDIN-STRATEGY.md +367 -0
  3. package/README.md +491 -16
  4. package/ROADMAP.md +214 -34
  5. package/SECURITY-AUDIT-v1.md +277 -0
  6. package/STATUS.md +801 -42
  7. package/TROUBLESHOOT-AUTH-20260322-2019.md +291 -0
  8. package/TROUBLESHOOT-JEST-20260323-1357.md +139 -0
  9. package/TROUBLESHOOT-LAMBDA-20260322-1945.md +183 -0
  10. package/VISUS-CLAUDE-CODE-PROMPT.md +1 -1
  11. package/VISUS-PROJECT-PLAN.md +7 -0
  12. package/dist/browser/playwright-renderer.d.ts.map +1 -1
  13. package/dist/browser/playwright-renderer.js +7 -0
  14. package/dist/browser/playwright-renderer.js.map +1 -1
  15. package/dist/browser/reader.d.ts +31 -0
  16. package/dist/browser/reader.d.ts.map +1 -0
  17. package/dist/browser/reader.js +98 -0
  18. package/dist/browser/reader.js.map +1 -0
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +37 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/lambda-handler.d.ts +0 -6
  24. package/dist/lambda-handler.d.ts.map +1 -1
  25. package/dist/lambda-handler.js +97 -25
  26. package/dist/lambda-handler.js.map +1 -1
  27. package/dist/sanitizer/framework-mapper.d.ts +22 -0
  28. package/dist/sanitizer/framework-mapper.d.ts.map +1 -0
  29. package/dist/sanitizer/framework-mapper.js +296 -0
  30. package/dist/sanitizer/framework-mapper.js.map +1 -0
  31. package/dist/sanitizer/index.d.ts +10 -2
  32. package/dist/sanitizer/index.d.ts.map +1 -1
  33. package/dist/sanitizer/index.js +22 -6
  34. package/dist/sanitizer/index.js.map +1 -1
  35. package/dist/sanitizer/patterns.js +1 -1
  36. package/dist/sanitizer/patterns.js.map +1 -1
  37. package/dist/sanitizer/pii-allowlist.d.ts +49 -0
  38. package/dist/sanitizer/pii-allowlist.d.ts.map +1 -0
  39. package/dist/sanitizer/pii-allowlist.js +231 -0
  40. package/dist/sanitizer/pii-allowlist.js.map +1 -0
  41. package/dist/sanitizer/pii-redactor.d.ts +13 -1
  42. package/dist/sanitizer/pii-redactor.d.ts.map +1 -1
  43. package/dist/sanitizer/pii-redactor.js +26 -2
  44. package/dist/sanitizer/pii-redactor.js.map +1 -1
  45. package/dist/sanitizer/severity-classifier.d.ts +33 -0
  46. package/dist/sanitizer/severity-classifier.d.ts.map +1 -0
  47. package/dist/sanitizer/severity-classifier.js +113 -0
  48. package/dist/sanitizer/severity-classifier.js.map +1 -0
  49. package/dist/sanitizer/threat-reporter.d.ts +65 -0
  50. package/dist/sanitizer/threat-reporter.d.ts.map +1 -0
  51. package/dist/sanitizer/threat-reporter.js +160 -0
  52. package/dist/sanitizer/threat-reporter.js.map +1 -0
  53. package/dist/tools/fetch-structured.d.ts +5 -0
  54. package/dist/tools/fetch-structured.d.ts.map +1 -1
  55. package/dist/tools/fetch-structured.js +59 -8
  56. package/dist/tools/fetch-structured.js.map +1 -1
  57. package/dist/tools/fetch.d.ts +5 -0
  58. package/dist/tools/fetch.d.ts.map +1 -1
  59. package/dist/tools/fetch.js +43 -9
  60. package/dist/tools/fetch.js.map +1 -1
  61. package/dist/tools/read.d.ts +51 -0
  62. package/dist/tools/read.d.ts.map +1 -0
  63. package/dist/tools/read.js +127 -0
  64. package/dist/tools/read.js.map +1 -0
  65. package/dist/tools/search.d.ts +45 -0
  66. package/dist/tools/search.d.ts.map +1 -0
  67. package/dist/tools/search.js +220 -0
  68. package/dist/tools/search.js.map +1 -0
  69. package/dist/types.d.ts +74 -0
  70. package/dist/types.d.ts.map +1 -1
  71. package/dist/types.js.map +1 -1
  72. package/dist/utils/format-converter.d.ts +39 -0
  73. package/dist/utils/format-converter.d.ts.map +1 -0
  74. package/dist/utils/format-converter.js +191 -0
  75. package/dist/utils/format-converter.js.map +1 -0
  76. package/dist/utils/truncate.d.ts +26 -0
  77. package/dist/utils/truncate.d.ts.map +1 -0
  78. package/dist/utils/truncate.js +54 -0
  79. package/dist/utils/truncate.js.map +1 -0
  80. package/infrastructure/stack.ts +55 -6
  81. package/jest.config.js +3 -0
  82. package/package.json +9 -2
  83. package/src/browser/playwright-renderer.ts +8 -0
  84. package/src/browser/reader.ts +129 -0
  85. package/src/index.ts +49 -5
  86. package/src/lambda-handler.ts +131 -26
  87. package/src/sanitizer/framework-mapper.ts +347 -0
  88. package/src/sanitizer/index.ts +28 -6
  89. package/src/sanitizer/patterns.ts +1 -1
  90. package/src/sanitizer/pii-allowlist.ts +273 -0
  91. package/src/sanitizer/pii-redactor.ts +43 -2
  92. package/src/sanitizer/severity-classifier.ts +132 -0
  93. package/src/sanitizer/threat-reporter.ts +261 -0
  94. package/src/tools/fetch-structured.ts +63 -8
  95. package/src/tools/fetch.ts +45 -9
  96. package/src/tools/read.ts +143 -0
  97. package/src/tools/search.ts +263 -0
  98. package/src/types.ts +71 -0
  99. package/src/utils/format-converter.ts +236 -0
  100. package/src/utils/truncate.ts +64 -0
  101. package/tests/auth-smoke.test.ts +480 -0
  102. package/tests/fetch-tool.test.ts +595 -2
  103. package/tests/pii-allowlist.test.ts +282 -0
  104. package/tests/reader.test.ts +353 -0
  105. package/tests/sanitizer.test.ts +52 -0
  106. package/tests/search.test.ts +456 -0
  107. package/tests/threat-reporter.test.ts +266 -0
package/ROADMAP.md CHANGED
@@ -1,41 +1,221 @@
1
1
  # Visus MCP — Product Roadmap
2
2
 
3
- ## v0.1.0 PUBLISHED
3
+ ## v0.1.0 PUBLISHED (2026-03-21)
4
4
  - 43 injection pattern categories
5
- - PII redaction (email, phone, SSN, CC, IP)
6
- - undici fetch() renderer
5
+ - PII redaction (email, phone, SSN, credit card, IP)
6
+ - undici fetch() renderer (static + server-rendered pages)
7
7
  - visus_fetch + visus_fetch_structured tools
8
8
  - 95/95 tests passing
9
9
  - Published to npm
10
+ - Claude Desktop smoke tested (4/4 passing)
10
11
 
11
- ## v0.2.0 — IN PROGRESS
12
- - Lambda browser renderer (Playwright, Amazon Linux x86_64)
13
- - BYOC support (user-supplied Lambda endpoint)
14
- - Lateos managed endpoint (open, no auth — rate limiting deferred)
15
- - CDK deployment template for self-hosted users
16
- - Three-tier renderer fallback: Lambda fetch()
17
-
18
- ## v0.3.0 PLANNED
19
- - API key authentication for managed endpoint
20
- - Cognito user pool for multi-user support
21
- - DynamoDB audit logging (HIPAA compliance trail)
22
- - Rate limiting on managed tier (free vs paid)
23
- - CloudWatch metrics dashboard
24
-
25
- ## v0.4.0 — PLANNED
26
- - Paid tier billing (Stripe integration)
27
- - Usage dashboard for managed tier users
28
- - BYOC enterprise tier (dedicated Lambda, SLA)
29
- - Lateos platform integration
30
-
31
- ## Deferred / Under Consideration
32
- - Playwright local rendering (blocked by macOS ARM64 compatibility)
33
- - Chrome extension / user-session relay (Phase 3 Visus feature)
34
- - WAF protection on managed endpoint (post-v0.3.0)
35
- - Pattern library expansion based on bypass reports
36
-
37
- ## Architecture Decisions
38
- - Sanitizer ALWAYS runs locally — PHI never touches Lateos infrastructure
39
- - Managed tier open (no auth) until v0.3.0 — minimize adoption friction
40
- - BYOC uses same CDK template as Lateos managed deployment
41
- - x86_64 Lambda required for Playwright (ARM64 incompatible)
12
+ ## v0.2.0 — PUBLISHED + DEPLOYED (2026-03-22)
13
+ - Playwright headless Chromium (JavaScript-rendered pages, SPAs)
14
+ - AWS Lambda renderer (x86_64, Amazon Linux, Node.js 20)
15
+ - API Gateway (REST API)
16
+ - Cognito User Pool with OAuth 2.0 (email authentication)
17
+ - DynamoDB audit logging table (KMS-encrypted, PITR in prod)
18
+ - IAM roles with scoped permissions
19
+ - CloudWatch structured logging (30-day retention)
20
+ - Dual-mode runtime (stdio MCP + Lambda unified codebase)
21
+ - BYOC support (user-supplied Lambda endpoint via VISUS_RENDERER_URL)
22
+ - Lateos managed endpoint live:
23
+ https://wyomy29zd7.execute-api.us-east-1.amazonaws.com
24
+ - 95/95 tests passing (no regressions)
25
+ - Lambda smoke tests: 3/3 passing
26
+ - example.com (static): 1.0s warm
27
+ - github.com (SPA): 6.2s warm
28
+ - medlineplus.gov (clinical): 3.0s warm
29
+
30
+ ## v0.3.0 — PUBLISHED (2026-03-22)
31
+ - Domain-scoped PII allowlist for health authority phone numbers
32
+ - Security hardening: scrubbed sensitive infrastructure details from STATUS.md
33
+ - Test suite expanded to 121/121 tests passing
34
+ - npm publish v0.3.0
35
+
36
+ ---
37
+
38
+ ## 🔒 v0.3.x — Managed Tier Security Hardening (IN PROGRESS)
39
+ Target: this week
40
+
41
+ - [ ] Enforce Cognito auth on managed endpoint (currently deployed, not enforced)
42
+ - [ ] Activate DynamoDB audit logging (table exists, no writes yet)
43
+ - [ ] Restrict CORS from * to claude.ai + localhost
44
+ - [ ] Add API Gateway usage plan: 1,000 req/day, 10 rps per API key
45
+ - [ ] Add TTL (90-day) to audit records
46
+ - [ ] Smoke test: unauthenticated request returns 401
47
+ - [ ] Update STATUS.md after deploy
48
+
49
+ ---
50
+
51
+ ## 📣 Phase 0 — Visibility & Distribution (2 weeks, zero-cost)
52
+ *Do these before any new features. Adoption stays at zero without them.*
53
+
54
+ ### MCP Registry Submission (Day 1)
55
+ - [ ] Submit visus-mcp to https://github.com/modelcontextprotocol/servers
56
+ - [ ] Follow submission format exactly (name, description, install command, tools list)
57
+ - [ ] This is free permanent distribution — do not skip
58
+
59
+ ### GitHub Polish
60
+ - [ ] CI/CD badge (GitHub Actions: build + test passing)
61
+ - [ ] Auto-release workflow on git tag push
62
+ - [ ] CONTRIBUTING.md — focus on allowlist PRs (how to submit trusted domains)
63
+ - [ ] Issue templates: Bug report, Feature request, Allowlist submission
64
+ - [ ] Update README test count and fix all known stale content
65
+
66
+ ### Injection Arena — Public Demo Site
67
+ - [ ] GitHub Pages site (React, no backend required)
68
+ - [ ] User pastes a URL → sees raw content vs Visus-sanitized side-by-side
69
+ - [ ] Highlighted blocked patterns (color-coded by category)
70
+ - [ ] Redacted PII shown with [REDACTED:TYPE] markers
71
+ - [ ] 5 pre-loaded famous attack examples:
72
+ - Hidden DAN prompt via CSS display:none
73
+ - Base64-encoded jailbreak in meta tag
74
+ - Role hijacking via invisible Unicode
75
+ - System prompt extraction in page footer
76
+ - Whitespace steganography in prose
77
+ - [ ] "Try in Claude Desktop" one-click config snippet
78
+ - [ ] Links to GitHub + npm
79
+
80
+ ### Benchmark Report
81
+ - [ ] Test corpus: 50 real-world attack pages (mix of known CVEs + synthetic)
82
+ - [ ] Measure: Visus vs raw fetch vs Firecrawl — bypass rate, PII leakage, token count
83
+ - [ ] Publish as BENCHMARK.md in repo + LinkedIn post
84
+ - [ ] Target: 0% bypass rate for Visus on known patterns
85
+
86
+ ### LinkedIn Launch Sequence (6 posts, 1 per week)
87
+ See LINKEDIN-STRATEGY.md for full post drafts.
88
+ - [ ] Post 1: OpenClaw CVE story — the credential leak nobody fixed
89
+ - [ ] Post 2: What prompt injection actually looks like (show the Injection Arena)
90
+ - [ ] Post 3: Why "engineered not vibe-coded" — the 43-pattern story
91
+ - [ ] Post 4: Healthcare angle — why PHI + AI agents is a compliance disaster waiting to happen
92
+ - [ ] Post 5: Benchmark results drop
93
+ - [ ] Post 6: Community call — allowlist PRs, contributors, roadmap
94
+
95
+ ---
96
+
97
+ ## v0.4.0 — Content Distillation + Managed Tier Activation
98
+ Target: 4–6 weeks
99
+
100
+ ### Content Distillation (new feature)
101
+ Reduce token consumption by stripping irrelevant content before it reaches Claude.
102
+ Pipeline position: runs AFTER sanitization, never before.
103
+
104
+ - [ ] New module: src/sanitizer/content-distiller.ts
105
+ - [ ] Input: sanitized HTML/text + distill_level param (0–3)
106
+ - [ ] Level 0: off (default, current behavior)
107
+ - [ ] Level 1 (safe): remove nav/footer boilerplate, cookie banners, excessive whitespace
108
+ - [ ] Level 2 (moderate): also remove decorative emoji, social share blocks, ad artifacts
109
+ - [ ] Level 3 (aggressive): extract main content block only (Reader Mode equivalent)
110
+ - [ ] Expose as optional param in visus_fetch and visus_fetch_structured tool inputs
111
+ - [ ] Add bytes_distilled field to sanitization metadata output
112
+ - [ ] Test corpus: 20 pages across content types (news, docs, medical, ecommerce)
113
+ - [ ] Feature flag: default off, user opts in per-request
114
+ - [ ] Note: emoji that carry semantic meaning (ratings ⭐, warnings ⚠️) must be preserved
115
+
116
+ ### Managed Tier Activation
117
+ - [ ] Stripe billing integration (free tier: 1,000 req/day; paid: unlimited)
118
+ - [ ] Usage dashboard (Next.js, reads from DynamoDB audit log)
119
+ - [ ] Blocked attacks heatmap, PII redaction count, token savings report
120
+ - [ ] API key management UI (issue, revoke, view usage)
121
+ - [ ] Provisioned concurrency on Lambda (eliminate 4s cold starts)
122
+ - [ ] WAF rules on API Gateway (bot protection, geo-blocking)
123
+ - [ ] CloudWatch metrics dashboard
124
+ - [ ] CORS restricted to authenticated origins only
125
+ - [ ] npm publish v0.4.0
126
+
127
+ ### Community Allowlist Program
128
+ - [ ] Extend PII allowlist beyond health authorities to finance, legal, government
129
+ - [ ] GitHub PR template for allowlist submissions
130
+ - [ ] Manual review process documented in CONTRIBUTING.md
131
+ - [ ] Allowlist becomes community data moat (only Visus has verified trusted-domain DB)
132
+
133
+ ---
134
+
135
+ ## v0.5.0 — Cryptographic Audit Proofs
136
+ Target: 3 months
137
+
138
+ The enterprise differentiator. Proves in compliance audits that content was
139
+ sanitized before reaching the LLM.
140
+
141
+ - [ ] SHA-256 hash of original HTML included in every response
142
+ - [ ] SHA-256 hash of sanitized content included in every response
143
+ - [ ] Diff summary (patterns removed, bytes stripped, PII types redacted)
144
+ - [ ] Signed proof bundle: {original_hash, sanitized_hash, diff, visus_version, timestamp}
145
+ - [ ] Proof stored in DynamoDB audit log, retrievable by request_id
146
+ - [ ] New API endpoint: GET /proof/{request_id} → returns signed proof bundle
147
+ - [ ] Verification CLI: visus verify {request_id} → pass/fail
148
+ - [ ] Compliance report export (PDF) for SOC2/HIPAA audit packages
149
+ - [ ] Add proof_bundle field to sanitization metadata output
150
+
151
+ ---
152
+
153
+ ## Phase 3 — Chrome Extension Session Relay
154
+ Target: 4 months
155
+ *The killer feature. Unlocks LinkedIn, banking portals, EHR systems.*
156
+
157
+ - [ ] Chrome extension: captures rendered DOM from user's authenticated browser tab
158
+ - [ ] Content piped through local Visus sanitizer before reaching Claude
159
+ - [ ] Zero Lateos infrastructure in the authentication path (user's own session)
160
+ - [ ] Sanitizer runs locally regardless of which renderer is used (existing guarantee)
161
+ - [ ] Structured extraction schema for LinkedIn profiles, job postings
162
+ - [ ] Structured extraction schema for EHR patient portal views
163
+ - [ ] Demo: "Ask Claude to summarize this LinkedIn profile" with Visus
164
+ - [ ] Documentation: "Your credentials never leave your machine"
165
+ - [ ] Ship Chrome extension to Web Store under Lateos publisher account
166
+
167
+ ---
168
+
169
+ ## Phase 4 — ML Hybrid Detector (Managed Tier Only)
170
+ Target: 6 months
171
+ *Rule-based 43 patterns + embedding similarity for zero-day detection.*
172
+
173
+ - [ ] Train lightweight classifier on public injection datasets + synthetic attacks
174
+ - [ ] Bounty-driven attack corpus (community-submitted, manually verified)
175
+ - [ ] Deploy as sidecar to managed Lambda — NOT bundled in npm package
176
+ - [ ] Zero impact on open-source install size
177
+ - [ ] Managed tier users get ML detection automatically, no config change
178
+ - [ ] Report: ML detector catches X% of novel attacks that pattern matching misses
179
+ - [ ] Compounding moat: attack corpus grows with every bounty submission
180
+
181
+ ---
182
+
183
+ ## Phase 5 — Enterprise & Revenue
184
+ Target: 9 months
185
+
186
+ - [ ] SOC2 Type I audit (existing KMS + audit logs + proofs make this achievable)
187
+ - [ ] HIPAA BAA available for healthcare customers
188
+ - [ ] Custom policy engine: YAML rules per domain
189
+ - [ ] Multi-region deployment (add me-central-1 for MENA healthcare — existing plan)
190
+ - [ ] Dedicated Lambda instances for enterprise tier
191
+ - [ ] "Visus Shield" API for non-MCP agents (REST API, no MCP required)
192
+ - [ ] Lateos platform integration (full dashboard, team management)
193
+
194
+ ---
195
+
196
+ ## Architecture Decisions (permanent record)
197
+
198
+ | Decision | Rationale |
199
+ |---|---|
200
+ | Sanitizer always runs locally | PHI never touches Lateos infrastructure |
201
+ | x86_64 Lambda only | ARM64 incompatible with Playwright |
202
+ | us-east-1 for managed endpoint | Best Lambda cold start globally |
203
+ | me-central-1 reserved | Future Lateos backend (MENA healthcare) |
204
+ | Open endpoint until v0.3.0 | Minimize adoption friction at launch |
205
+ | Cognito deployed in v0.2.0 | Available, not yet enforced |
206
+ | DynamoDB deployed in v0.2.0 | Available, not yet activated for audit |
207
+ | undici fallback retained | Graceful degradation if Lambda unavailable |
208
+ | Content distiller runs after sanitizer | Prevents distiller from obscuring injection patterns |
209
+ | ML detector managed-tier only | Keeps npm package lightweight (<170MB Playwright already) |
210
+ | Cryptographic proofs stored 90 days | Matches audit log TTL, sufficient for compliance windows |
211
+ | Chrome extension local sanitizer path | Maintains PHI-never-touches-Lateos guarantee |
212
+
213
+ ## Known Limitations
214
+
215
+ | Limitation | Resolution |
216
+ |---|---|
217
+ | Login-gated pages (LinkedIn, X) | Phase 3 user-session relay |
218
+ | Lambda cold start 4-5s | Provisioned concurrency (v0.3.0) |
219
+ | No rate limiting on managed endpoint | v0.3.0 |
220
+ | DynamoDB audit log not yet active | v0.3.0 activation |
221
+ | Cognito auth deployed but not enforced | v0.3.0 activation |
@@ -0,0 +1,277 @@
1
+ # Visus MCP — Security Audit v1
2
+
3
+ **Status:** ✅ **COMPLETED** — Auth Smoke Tests (2026-03-22)
4
+ **Scope:** Authentication enforcement and Lambda handler security
5
+ **Version:** v0.3.1 (security hardening release)
6
+
7
+ ---
8
+
9
+ ## Executive Summary
10
+
11
+ **Audit Completed:** 2026-03-22
12
+ **Tests Executed:** 146 passing (24 auth-specific tests)
13
+ **Findings:** 2 (1 HIGH, 1 LOW)
14
+ **Resolution:** ✅ Both findings resolved in v0.3.1
15
+ **Security Posture:** SECURE (after remediation)
16
+
17
+ ---
18
+
19
+ ## Audit Scope — Authentication Enforcement
20
+
21
+ ### Objectives
22
+ 1. Verify authentication is enforced at both infrastructure and application layers
23
+ 2. Identify gaps where direct Lambda invocation could bypass API Gateway auth
24
+ 3. Validate CORS enforcement and origin validation
25
+ 4. Ensure health check endpoints follow REST conventions
26
+ 5. Confirm no sensitive data exposure in unauthenticated paths
27
+
28
+ ### Methodology
29
+ - **Approach:** Comprehensive smoke testing with mock API Gateway events
30
+ - **Test Categories:** 8 (health endpoints, auth validation, CORS, method enforcement, input validation, unknown endpoints, security audit)
31
+ - **Test Count:** 24 auth-specific tests (22 original + 2 added in v0.3.1)
32
+ - **Environment:** Jest with mocked AWS Lambda context
33
+ - **Documentation:** `TROUBLESHOOT-AUTH-20260322-2019.md`
34
+
35
+ ---
36
+
37
+ ## Findings and Resolutions
38
+
39
+ ### 🔴 FINDING 1: No Application-Level Auth Enforcement (HIGH)
40
+
41
+ **Status:** ✅ **RESOLVED in v0.3.1**
42
+ **Location:** `src/lambda-handler.ts:190-209` (post-fix)
43
+ **Severity:** HIGH
44
+ **Discovered:** 2026-03-22
45
+
46
+ **Original Issue:**
47
+ - Lambda handler trusted API Gateway's Cognito authorizer without validation
48
+ - Fell back to `user_id = 'anonymous'` if authorizer context was missing (line 132, v0.3.0)
49
+ - Direct Lambda invocation (AWS SDK, console, cross-account) bypassed all authentication
50
+ - Audit logs showed "anonymous" making attribution impossible
51
+
52
+ **Risk:**
53
+ - Unauthenticated requests possible via direct Lambda invocation
54
+ - Resource policy or IAM-based invocations would process without auth
55
+ - Security gap violated defense-in-depth principle
56
+
57
+ **Resolution (v0.3.1):**
58
+ ```typescript
59
+ // SECURITY FIX (FINDING 1): Application-level authentication enforcement
60
+ // Extract user ID from Cognito authorizer
61
+ const userId = event.requestContext.authorizer?.claims?.sub;
62
+
63
+ // Require authentication for all protected endpoints (not already handled above)
64
+ if (!userId) {
65
+ console.error(JSON.stringify({
66
+ timestamp: new Date().toISOString(),
67
+ event: 'auth_required',
68
+ request_id: requestId,
69
+ path: event.path,
70
+ reason: 'Missing Cognito authorizer context - Lambda must be invoked via API Gateway',
71
+ }));
72
+
73
+ return {
74
+ statusCode: 401,
75
+ headers: corsHeaders,
76
+ body: JSON.stringify({
77
+ error: 'Unauthorized: Authentication required. This Lambda must be invoked via API Gateway with Cognito authorizer.',
78
+ }),
79
+ };
80
+ }
81
+ ```
82
+
83
+ **Verification:**
84
+ - ✅ Tests confirm 401 returned for missing auth context
85
+ - ✅ `auth_required` event logged for security monitoring
86
+ - ✅ No anonymous audit logs possible
87
+ - ✅ Health check endpoint explicitly excluded
88
+
89
+ **Impact:** Defense-in-depth implemented. Direct Lambda invocation now rejected.
90
+
91
+ ---
92
+
93
+ ### 🟡 FINDING 2: Health Endpoint Requires POST (LOW)
94
+
95
+ **Status:** ✅ **RESOLVED in v0.3.1**
96
+ **Location:** `src/lambda-handler.ts:152-165` (post-fix)
97
+ **Severity:** LOW
98
+ **Discovered:** 2026-03-22
99
+
100
+ **Original Issue:**
101
+ - Health check endpoint required POST method (non-standard)
102
+ - Method validation occurred before path routing (lines 156-162, v0.3.0)
103
+ - Standard monitoring tools (AWS Health Checks, CloudWatch Synthetics) expect GET
104
+ - API Gateway health check configuration could fail with default settings
105
+
106
+ **Impact:**
107
+ - Operational tooling compatibility issues
108
+ - Non-standard REST convention
109
+ - Not a security vulnerability, but affects observability
110
+
111
+ **Resolution (v0.3.1):**
112
+ ```typescript
113
+ // Health check endpoint (no auth required, allows GET and POST)
114
+ // SECURITY FIX (FINDING 2): Moved before POST-only validation to support standard GET health checks
115
+ if (event.path === '/health' || event.path === '/dev/health' || event.path === '/prod/health') {
116
+ return {
117
+ statusCode: 200,
118
+ headers: corsHeaders,
119
+ body: JSON.stringify({
120
+ status: 'healthy',
121
+ service: 'visus-mcp',
122
+ version: '0.3.1',
123
+ timestamp: new Date().toISOString(),
124
+ }),
125
+ };
126
+ }
127
+
128
+ // Only allow POST requests for protected endpoints
129
+ if (event.httpMethod !== 'POST') {
130
+ return {
131
+ statusCode: 405,
132
+ headers: corsHeaders,
133
+ body: JSON.stringify({ error: 'Method not allowed. Use POST.' }),
134
+ };
135
+ }
136
+ ```
137
+
138
+ **Changes:**
139
+ - Health check moved before POST-only validation
140
+ - Supports both GET and POST methods
141
+ - CORS updated to allow `GET, POST, OPTIONS`
142
+
143
+ **Verification:**
144
+ - ✅ GET /health returns 200 without auth
145
+ - ✅ POST /health returns 200 without auth
146
+ - ✅ CORS headers include GET method
147
+ - ✅ Standard monitoring tools compatible
148
+
149
+ **Impact:** Standard REST conventions restored. Operational tooling compatibility ensured.
150
+
151
+ ---
152
+
153
+ ## Security Posture Assessment
154
+
155
+ ### Before v0.3.1
156
+ **Overall:** ADEQUATE WITH GAPS
157
+ **Critical Issue:** Application-level auth missing (HIGH severity)
158
+ **Compliance:** 93.75% (7.5/8 CLAUDE.md security rules)
159
+
160
+ ### After v0.3.1
161
+ **Overall:** ✅ **SECURE**
162
+ **Critical Issues:** NONE
163
+ **Compliance:** 100% (8/8 CLAUDE.md security rules)
164
+
165
+ ---
166
+
167
+ ## Confirmed Secure (No Changes Required)
168
+
169
+ ✅ **CORS Enforcement** - Origin validation working correctly, malicious origins rejected
170
+ ✅ **User ID Extraction** - Cognito claims properly extracted when present
171
+ ✅ **Input Validation** - Malformed requests (missing url, schema, invalid JSON) rejected
172
+ ✅ **Method Enforcement** - Non-POST requests blocked for protected endpoints
173
+ ✅ **Audit Logging** - Fire-and-forget DynamoDB logging operational
174
+ ✅ **Health Check Bypass** - Intentionally unauthenticated, returns only non-sensitive metadata
175
+ ✅ **Unknown Endpoints** - Returns 404 with clear error message
176
+
177
+ ---
178
+
179
+ ## Infrastructure Layer (Not Tested - Requires Live Deployment)
180
+
181
+ ⚠️ **API Gateway Cognito Authorizer** - Requires live Cognito User Pool
182
+ ⚠️ **API Key Enforcement** - Requires live API Gateway deployment
183
+ ⚠️ **Usage Plan Rate Limiting** - Requires traffic simulation
184
+ ⚠️ **Lambda Resource Policy** - Requires IAM integration testing
185
+ ⚠️ **Cross-Account Invocation** - Requires multi-account test environment
186
+
187
+ **Recommendation:** Create integration test suite for deployed infrastructure validation.
188
+
189
+ ---
190
+
191
+ ## Test Results
192
+
193
+ **Total Tests:** 146 passing (100%)
194
+ **Test Suites:** 4 passing
195
+ **Execution Time:** ~3.9s
196
+ **Zero Regressions:** All existing tests continue to pass
197
+
198
+ **Test Breakdown:**
199
+ 1. Sanitizer tests: 43 passing
200
+ 2. Fetch tool tests: 50+ passing
201
+ 3. PII allowlist tests: 26 passing
202
+ 4. **Auth smoke tests: 24 passing** (4 health endpoint, 3 protected without auth, 3 protected with auth, 3 CORS, 3 method enforcement, 3 input validation, 1 unknown endpoint, 4 security audit resolutions)
203
+
204
+ ---
205
+
206
+ ## Compliance with CLAUDE.md Security Rules
207
+
208
+ | Rule | Status | Verification |
209
+ |------|--------|-------------|
210
+ | RULE 1: No secrets in code | ✅ PASS | No hardcoded secrets found |
211
+ | RULE 2: No wildcard IAM | ✅ PASS | All policies scoped in stack.ts |
212
+ | RULE 3: No public endpoints without Cognito | ✅ PASS | /health is public (intentional), /fetch and /fetch-structured require auth |
213
+ | RULE 4: No shell execution | ✅ PASS | No os.system/subprocess/eval/exec |
214
+ | RULE 5: Sanitize user input | ✅ PASS | All content passes through sanitizer |
215
+ | RULE 6: No cross-user data access | ✅ PASS | DynamoDB writes scoped to user_id |
216
+ | RULE 7: Reserved concurrent executions | ✅ PASS | Set to 10 (dev) / 100 (prod) |
217
+ | RULE 8: No plaintext PII logging | ✅ PASS | Structured logging, no secrets |
218
+
219
+ **Overall Compliance:** 100% (8/8 rules)
220
+
221
+ ---
222
+
223
+ ## Recommendations for Future Audits
224
+
225
+ ### Phase 2 (Next Audit - Post-Deployment)
226
+ 1. **Integration Testing:** Deploy to dev account and verify:
227
+ - API Gateway Cognito authorizer blocks unauthenticated requests
228
+ - Direct Lambda invocation properly restricted via resource policy
229
+ - Rate limiting triggers at configured thresholds
230
+ - Cross-account invocation properly denied
231
+
232
+ 2. **Penetration Testing:** Red team engagement to test:
233
+ - JWT manipulation attempts
234
+ - Token replay attacks
235
+ - CORS bypass attempts
236
+ - DynamoDB injection via audit log fields
237
+
238
+ 3. **Sanitizer Deep Dive:** Comprehensive bypass testing:
239
+ - 50+ crafted payloads across all 43 pattern categories
240
+ - Novel obfuscation techniques
241
+ - False positive rate measurement
242
+
243
+ ### Phase 3 (After User-Session Relay)
244
+ - Chrome extension security review
245
+ - Cookie/session token handling
246
+ - Login-gated page access controls
247
+
248
+ ---
249
+
250
+ ## Bug Bounty Program (Planned)
251
+
252
+ | Severity | Reward |
253
+ |---|---|
254
+ | Critical (sanitizer bypass, auth bypass) | $500–$2,000 |
255
+ | High (PII leakage, rate limit bypass) | $200–$500 |
256
+ | Medium (false positive causing data loss) | $50–$200 |
257
+ | Low (documentation issues, minor bypasses) | Recognition + HALL_OF_FAME.md |
258
+
259
+ *Bounty program activates after v0.4.0 deployment.*
260
+
261
+ ---
262
+
263
+ ## Documentation References
264
+
265
+ - **Troubleshooting Log:** `TROUBLESHOOT-AUTH-20260322-2019.md`
266
+ - **Test Suite:** `tests/auth-smoke.test.ts`
267
+ - **Fixed Code:** `src/lambda-handler.ts` (v0.3.1)
268
+ - **Project Status:** `STATUS.md` (updated 2026-03-22 20:23 JST)
269
+
270
+ ---
271
+
272
+ *Audit Conducted By:* Claude Code (Anthropic)
273
+ *Audit Date:* 2026-03-22
274
+ *Remediation Date:* 2026-03-22
275
+ *Version:* v0.3.1
276
+ *Contact:* security@lateos.ai
277
+ *Repository:* https://github.com/visus-mcp/visus-mcp