memorylink 2.0.2 β†’ 2.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.
@@ -0,0 +1,279 @@
1
+ # πŸ” MemoryLink Threat Model
2
+
3
+ **Version:** 2.0.2
4
+ **Last Updated:** January 2, 2026
5
+ **Status:** Production
6
+
7
+ This document describes the security boundaries, threat model, and trust assumptions for MemoryLink.
8
+
9
+ ---
10
+
11
+ ## πŸ“‹ Overview
12
+
13
+ MemoryLink is a **local-first** secret detection tool. It operates entirely on your machine with:
14
+ - No network calls
15
+ - No telemetry
16
+ - No cloud dependencies
17
+
18
+ ---
19
+
20
+ ## 🎯 Security Goals
21
+
22
+ | Goal | Description | Status |
23
+ |------|-------------|--------|
24
+ | **Prevent Secret Leaks** | Block secrets from reaching Git remotes | βœ… Implemented |
25
+ | **Protect Detected Secrets** | Encrypt quarantined secrets at rest | βœ… Implemented |
26
+ | **Maintain Audit Trail** | Log all security events immutably | βœ… Implemented |
27
+ | **Zero Data Exfiltration** | No data leaves user's machine | βœ… Implemented |
28
+ | **Minimal Attack Surface** | No network, minimal dependencies | βœ… Implemented |
29
+
30
+ ---
31
+
32
+ ## πŸ—οΈ Architecture Security
33
+
34
+ ### Data Flow
35
+
36
+ ```
37
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
38
+ β”‚ USER'S MACHINE β”‚
39
+ β”‚ β”‚
40
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
41
+ β”‚ β”‚ Your Code │────▢│ MemoryLink │────▢│ Git Repo β”‚ β”‚
42
+ β”‚ β”‚ (Scanned) β”‚ β”‚ (Scanner) β”‚ β”‚ (Clean) β”‚ β”‚
43
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
44
+ β”‚ β”‚ β”‚
45
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
46
+ β”‚ β”‚ If Secrets β”‚ β”‚
47
+ β”‚ β”‚ Detected β”‚ β”‚
48
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
49
+ β”‚ β”‚ β”‚
50
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
51
+ β”‚ β–Ό β–Ό β–Ό β”‚
52
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
53
+ β”‚ β”‚ Quarantine β”‚ β”‚ Audit Trail β”‚ β”‚ Block β”‚ β”‚
54
+ β”‚ β”‚ (Encrypted) β”‚ β”‚ (Logs) β”‚ β”‚ Commit β”‚ β”‚
55
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
56
+ β”‚ β”‚
57
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
58
+ β”‚
59
+ β–Ό
60
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
61
+ β”‚ NETWORK NEVER β”‚
62
+ β”‚ ACCESSED β”‚
63
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
64
+ ```
65
+
66
+ ### Trust Boundaries
67
+
68
+ | Zone | Trust Level | Data |
69
+ |------|-------------|------|
70
+ | **User's Home Dir** | High | `~/.memorylink/keys/` (encryption keys) |
71
+ | **Project Dir** | Medium | `.memorylink/` (project config, quarantine) |
72
+ | **Git Working Tree** | Low | Scanned for secrets |
73
+ | **Git Remote** | Untrusted | Should never receive secrets |
74
+ | **Network** | N/A | Never accessed |
75
+
76
+ ---
77
+
78
+ ## πŸ”‘ Cryptographic Design
79
+
80
+ ### Encryption
81
+
82
+ | Component | Algorithm | Key Size | Notes |
83
+ |-----------|-----------|----------|-------|
84
+ | **Quarantine Encryption** | AES-256-GCM | 256-bit | Authenticated encryption |
85
+ | **Key Derivation** | Random | 256-bit | Crypto-secure random |
86
+ | **IV Generation** | Random | 96-bit | Unique per encryption |
87
+
88
+ ### Key Storage
89
+
90
+ ```
91
+ ~/.memorylink/
92
+ └── keys/
93
+ └── <project-hash>.key # 256-bit AES key
94
+ ```
95
+
96
+ **Key Properties:**
97
+ - βœ… Stored outside project directory
98
+ - βœ… Never committed to Git
99
+ - βœ… One key per project (isolated)
100
+ - ⚠️ Should be 600 permissions (Unix) / User-only ACL (Windows)
101
+
102
+ ### Key Rotation
103
+
104
+ Currently, keys are:
105
+ - Created on first `ml init`
106
+ - Never automatically rotated
107
+ - Manual rotation: Delete key file, re-run `ml init`
108
+
109
+ **Future (v2.1):** Automatic key rotation with `ml keys rotate`
110
+
111
+ ---
112
+
113
+ ## 🚨 Threat Analysis
114
+
115
+ ### Threats Mitigated
116
+
117
+ | Threat | Mitigation | Effectiveness |
118
+ |--------|------------|---------------|
119
+ | **Accidental secret commit** | Pre-commit hook | βœ… High |
120
+ | **Accidental secret push** | Pre-push hook | βœ… High |
121
+ | **Secret in CI logs** | Masked output | βœ… High |
122
+ | **Quarantine file theft** | AES-256-GCM encryption | βœ… High |
123
+ | **Telemetry/tracking** | No network calls | βœ… Complete |
124
+
125
+ ### Threats NOT Mitigated
126
+
127
+ | Threat | Why | Recommendation |
128
+ |--------|-----|----------------|
129
+ | **Malicious user disabling hooks** | User has full control | Use CI enforcement (`ml gate`) |
130
+ | **Key file theft** | If attacker has machine access | Use disk encryption (FileVault/BitLocker) |
131
+ | **Memory dump attacks** | Secrets in RAM during scan | Use secure OS, avoid shared machines |
132
+ | **Supply chain attacks** | npm dependency risks | Audit dependencies, use lockfile |
133
+ | **Secrets in Git history** | Already committed secrets | Use `ml gate --history` + `git filter-branch` |
134
+
135
+ ### Out of Scope
136
+
137
+ These threats are explicitly NOT in MemoryLink's threat model:
138
+
139
+ 1. **Malware on user's machine** - MemoryLink cannot protect against rootkits/keyloggers
140
+ 2. **Physical access attacks** - Use full-disk encryption
141
+ 3. **Social engineering** - User education required
142
+ 4. **Zero-day vulnerabilities** - Keep MemoryLink updated
143
+
144
+ ---
145
+
146
+ ## πŸ›‘οΈ Security Controls
147
+
148
+ ### Input Validation
149
+
150
+ | Input | Validation | Risk |
151
+ |-------|------------|------|
152
+ | **File paths** | Normalized, no symlinks | Path traversal |
153
+ | **Regex patterns** | Pre-tested for ReDoS | Denial of service |
154
+ | **Config files** | JSON schema validation | Injection |
155
+ | **CLI arguments** | Type-checked | Command injection |
156
+
157
+ ### File System Security
158
+
159
+ | Control | Implementation |
160
+ |---------|----------------|
161
+ | **Symlink handling** | Skipped by default |
162
+ | **Binary files** | Skipped (detected by magic bytes) |
163
+ | **Large files** | Size limit configurable |
164
+ | **Hidden files** | Scanned by default (configurable) |
165
+
166
+ ### Git Integration Security
167
+
168
+ | Hook | Security Property |
169
+ |------|-------------------|
170
+ | **pre-commit** | Blocks staged files with secrets |
171
+ | **pre-push** | Full repo scan before push |
172
+ | **Bypass** | `--no-verify` (logged in audit) |
173
+
174
+ ---
175
+
176
+ ## πŸ“Š Security Comparison
177
+
178
+ | Feature | MemoryLink | gitleaks | truffleHog | GitGuardian |
179
+ |---------|-----------|----------|------------|-------------|
180
+ | **Local-only** | βœ… | βœ… | βœ… | ❌ Cloud |
181
+ | **Zero telemetry** | βœ… | βœ… | ⚠️ Opt-out | ❌ Required |
182
+ | **Encrypted quarantine** | βœ… | ❌ | ❌ | ❌ |
183
+ | **Audit trail** | βœ… | ❌ | ❌ | βœ… Cloud |
184
+ | **Key isolation** | βœ… Home dir | N/A | N/A | N/A |
185
+
186
+ ---
187
+
188
+ ## πŸ” Security Verification
189
+
190
+ ### Self-Check Command
191
+
192
+ ```bash
193
+ ml self-check
194
+ ```
195
+
196
+ Verifies:
197
+ - βœ… Installation integrity
198
+ - βœ… Git hooks installed
199
+ - βœ… Config file valid
200
+ - βœ… Key file exists and accessible
201
+
202
+ ### Manual Verification
203
+
204
+ ```bash
205
+ # Verify no network calls (run while scanning)
206
+ sudo lsof -i -P | grep memorylink
207
+ # Expected: No output (no network connections)
208
+
209
+ # Verify key permissions (Unix)
210
+ ls -la ~/.memorylink/keys/
211
+ # Expected: -rw------- (600)
212
+
213
+ # Verify quarantine encryption
214
+ file .memorylink/quarantined/*
215
+ # Expected: "data" (encrypted, not readable)
216
+ ```
217
+
218
+ ---
219
+
220
+ ## 🚨 Incident Response
221
+
222
+ ### If Secrets Were Committed
223
+
224
+ 1. **Don't push** - If not pushed, secret is still local
225
+ 2. **Remove from history**: `git filter-branch` or BFG Repo Cleaner
226
+ 3. **Rotate the secret** - Consider it compromised
227
+ 4. **Run `ml gate --history`** - Find all historical secrets
228
+ 5. **Review audit logs** - `.memorylink/audit/`
229
+
230
+ ### If Key File Compromised
231
+
232
+ 1. **Delete the key**: `rm ~/.memorylink/keys/<project>.key`
233
+ 2. **Re-initialize**: `ml init`
234
+ 3. **Quarantined secrets** are now unreadable (acceptable loss)
235
+ 4. **Audit logs** remain readable (not encrypted)
236
+
237
+ ---
238
+
239
+ ## πŸ“‹ Compliance Notes
240
+
241
+ ### Relevant Standards
242
+
243
+ | Standard | Relevance | Status |
244
+ |----------|-----------|--------|
245
+ | **OWASP ASVS** | Secret management | Aligned |
246
+ | **OWASP ASI06** | AI security | Planned v3.0 |
247
+ | **PCI DSS** | Payment card data | Detects card patterns |
248
+ | **GDPR** | Personal data (India: Aadhaar) | Detects PII patterns |
249
+
250
+ ### Audit Support
251
+
252
+ MemoryLink provides:
253
+ - βœ… Immutable audit logs (append-only)
254
+ - βœ… Timestamped events
255
+ - βœ… Detection fingerprints
256
+ - βœ… User action logging
257
+
258
+ ---
259
+
260
+ ## πŸ“ž Security Contact
261
+
262
+ **Report security issues:** security@memorylink.dev (or GitHub Security Advisory)
263
+
264
+ **Response time:** 48 hours for initial response
265
+
266
+ **Disclosure policy:** Coordinated disclosure, 90-day window
267
+
268
+ ---
269
+
270
+ ## πŸ“ Revision History
271
+
272
+ | Version | Date | Changes |
273
+ |---------|------|---------|
274
+ | 1.0 | 2026-01-02 | Initial threat model |
275
+
276
+ ---
277
+
278
+ *This document is part of MemoryLink's security documentation.*
279
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "memorylink",
3
- "version": "2.0.2",
4
- "description": "MemoryLink - Prevent secret leaks in AI-assisted development",
3
+ "version": "2.1.0",
4
+ "description": "MemoryLink - Prevent secret leaks in AI-assisted development. 120+ patterns including India-specific (Aadhaar, PAN, UPI).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "bin": {