memorylink 2.0.2 β 2.1.1
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/CHANGELOG.md +47 -0
- package/README.md +43 -11
- package/dist/cli/commands/doctor.d.ts +20 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +356 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/scan.d.ts +5 -0
- package/dist/cli/commands/scan.d.ts.map +1 -1
- package/dist/cli/commands/scan.js +66 -4
- package/dist/cli/commands/scan.js.map +1 -1
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/quarantine/patterns.d.ts.map +1 -1
- package/dist/quarantine/patterns.js +93 -2
- package/dist/quarantine/patterns.js.map +1 -1
- package/docs/REMEDIATION.md +269 -171
- package/docs/THREAT_MODEL.md +279 -0
- package/package.json +2 -2
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# π MemoryLink Threat Model
|
|
2
|
+
|
|
3
|
+
**Version:** 2.1.0
|
|
4
|
+
**Last Updated:** January 3, 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.
|
|
4
|
-
"description": "MemoryLink - Prevent secret leaks in AI-assisted development",
|
|
3
|
+
"version": "2.1.1",
|
|
4
|
+
"description": "MemoryLink - Prevent secret leaks in AI-assisted development. 127 patterns including India-specific (Aadhaar, PAN, UPI).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|