visus-mcp 0.3.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 (96) 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 +167 -30
  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 +2 -0
  32. package/dist/sanitizer/index.d.ts.map +1 -1
  33. package/dist/sanitizer/index.js +14 -1
  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/severity-classifier.d.ts +33 -0
  38. package/dist/sanitizer/severity-classifier.d.ts.map +1 -0
  39. package/dist/sanitizer/severity-classifier.js +113 -0
  40. package/dist/sanitizer/severity-classifier.js.map +1 -0
  41. package/dist/sanitizer/threat-reporter.d.ts +65 -0
  42. package/dist/sanitizer/threat-reporter.d.ts.map +1 -0
  43. package/dist/sanitizer/threat-reporter.js +160 -0
  44. package/dist/sanitizer/threat-reporter.js.map +1 -0
  45. package/dist/tools/fetch-structured.d.ts +5 -0
  46. package/dist/tools/fetch-structured.d.ts.map +1 -1
  47. package/dist/tools/fetch-structured.js +54 -6
  48. package/dist/tools/fetch-structured.js.map +1 -1
  49. package/dist/tools/fetch.d.ts +5 -0
  50. package/dist/tools/fetch.d.ts.map +1 -1
  51. package/dist/tools/fetch.js +42 -9
  52. package/dist/tools/fetch.js.map +1 -1
  53. package/dist/tools/read.d.ts +51 -0
  54. package/dist/tools/read.d.ts.map +1 -0
  55. package/dist/tools/read.js +127 -0
  56. package/dist/tools/read.js.map +1 -0
  57. package/dist/tools/search.d.ts +45 -0
  58. package/dist/tools/search.d.ts.map +1 -0
  59. package/dist/tools/search.js +220 -0
  60. package/dist/tools/search.js.map +1 -0
  61. package/dist/types.d.ts +64 -0
  62. package/dist/types.d.ts.map +1 -1
  63. package/dist/types.js.map +1 -1
  64. package/dist/utils/format-converter.d.ts +39 -0
  65. package/dist/utils/format-converter.d.ts.map +1 -0
  66. package/dist/utils/format-converter.js +191 -0
  67. package/dist/utils/format-converter.js.map +1 -0
  68. package/dist/utils/truncate.d.ts +26 -0
  69. package/dist/utils/truncate.d.ts.map +1 -0
  70. package/dist/utils/truncate.js +54 -0
  71. package/dist/utils/truncate.js.map +1 -0
  72. package/infrastructure/stack.ts +55 -6
  73. package/jest.config.js +3 -0
  74. package/package.json +9 -2
  75. package/src/browser/playwright-renderer.ts +8 -0
  76. package/src/browser/reader.ts +129 -0
  77. package/src/index.ts +49 -5
  78. package/src/lambda-handler.ts +131 -26
  79. package/src/sanitizer/framework-mapper.ts +347 -0
  80. package/src/sanitizer/index.ts +18 -1
  81. package/src/sanitizer/patterns.ts +1 -1
  82. package/src/sanitizer/severity-classifier.ts +132 -0
  83. package/src/sanitizer/threat-reporter.ts +261 -0
  84. package/src/tools/fetch-structured.ts +58 -6
  85. package/src/tools/fetch.ts +44 -9
  86. package/src/tools/read.ts +143 -0
  87. package/src/tools/search.ts +263 -0
  88. package/src/types.ts +69 -0
  89. package/src/utils/format-converter.ts +236 -0
  90. package/src/utils/truncate.ts +64 -0
  91. package/tests/auth-smoke.test.ts +480 -0
  92. package/tests/fetch-tool.test.ts +595 -2
  93. package/tests/reader.test.ts +353 -0
  94. package/tests/sanitizer.test.ts +52 -0
  95. package/tests/search.test.ts +456 -0
  96. package/tests/threat-reporter.test.ts +266 -0
package/ROADMAP.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Visus MCP — Product Roadmap
2
2
 
3
- ## v0.1.0 PUBLISHED (2026-03-21)
3
+ ## v0.1.0 PUBLISHED (2026-03-21)
4
4
  - 43 injection pattern categories
5
5
  - PII redaction (email, phone, SSN, credit card, IP)
6
6
  - undici fetch() renderer (static + server-rendered pages)
@@ -9,7 +9,7 @@
9
9
  - Published to npm
10
10
  - Claude Desktop smoke tested (4/4 passing)
11
11
 
12
- ## v0.2.0 PUBLISHED + DEPLOYED (2026-03-22)
12
+ ## v0.2.0 PUBLISHED + DEPLOYED (2026-03-22)
13
13
  - Playwright headless Chromium (JavaScript-rendered pages, SPAs)
14
14
  - AWS Lambda renderer (x86_64, Amazon Linux, Node.js 20)
15
15
  - API Gateway (REST API)
@@ -27,38 +27,171 @@
27
27
  - github.com (SPA): 6.2s warm
28
28
  - medlineplus.gov (clinical): 3.0s warm
29
29
 
30
- ## v0.3.0 — PLANNED
31
- Focus: managed tier activation make the deployed
32
- infrastructure useful to end users
33
-
34
- - Activate Cognito authentication on managed endpoint
35
- (currently deployed but open — no auth enforced)
36
- - Free tier rate limiting (requests/day per user)
37
- - API key management for managed tier users
38
- - CloudWatch metrics dashboard (usage visibility)
39
- - WAF rules on API Gateway (bot protection)
40
- - CORS restricted to authenticated origins
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
41
34
  - npm publish v0.3.0
42
35
 
43
- ## v0.4.0 — PLANNED
44
- Focus: paid tier + enterprise
36
+ ---
45
37
 
46
- - Stripe billing integration
47
- - Usage dashboard for managed tier users
48
- - Paid tier gating (rate limit increase)
49
- - BYOC enterprise tier (dedicated Lambda, SLA documentation)
50
- - Lateos platform integration
51
- - Multi-region consideration (me-central-1 for MENA healthcare)
38
+ ## 🔒 v0.3.x — Managed Tier Security Hardening (IN PROGRESS)
39
+ Target: this week
52
40
 
53
- ## Phase 3 USER SESSION RELAY (future)
54
- Focus: login-gated content (LinkedIn, X, EHR portals)
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
55
48
 
56
- - Chrome extension / in-app browser layer
57
- - User-authenticated session relay
58
- - Content passes through Visus sanitizer before reaching Claude
59
- - Zero Lateos infrastructure in the auth path (user's own session)
60
- - Tagline: "What the web shows you, Lateos reads safely"
61
- - This is the feature that unlocks LinkedIn, X, and clinical portals
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
+ ---
62
195
 
63
196
  ## Architecture Decisions (permanent record)
64
197
 
@@ -72,8 +205,12 @@ Focus: login-gated content (LinkedIn, X, EHR portals)
72
205
  | Cognito deployed in v0.2.0 | Available, not yet enforced |
73
206
  | DynamoDB deployed in v0.2.0 | Available, not yet activated for audit |
74
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 |
75
212
 
76
- ## Known Limitations (Phase 2)
213
+ ## Known Limitations
77
214
 
78
215
  | Limitation | Resolution |
79
216
  |---|---|
@@ -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