T09 · Insecure Skill Coding Practices
- Location
scripts/vector_search.py:331- Finding
Agent Memory Persisted in an Unprotected Plaintext SQLite Database
- Content
View full analysis
Vulnerability Details
File Location:
scripts/vector_search.py:15-17, 50-58, 85, 331-340
Vulnerability Type: Plaintext storage of potentially sensitive agent memory
Risk Level: MediumVulnerable Code
python # Config MEMORY_PATH = Path("/root/.openclaw/workspace/MEMORY.md") VECTORS_DIR = Path("/root/.openclaw/workspace/memory/vectors") DB_PATH = VECTORS_DIR / "vectors.db"python cursor.execute(""" CREATE TABLE IF NOT EXISTS sections ( id TEXT PRIMARY KEY, title TEXT NOT NULL, content TEXT NOT NULL, hash TEXT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) """)python content = MEMORY_PATH.read_text(encoding='utf-8')python if update: cursor.execute(""" UPDATE sections SET title = ?, content = ?, hash = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ? """, (section['title'], section['content'], section['hash'], section['id'])) else: cursor.execute(""" INSERT INTO sections (id, title, content, hash) VALUES (?, ?, ?, ?) """, (section['id'], section['title'], section['content'], section['hash']))Technical Analysis
The Skill reads the complete configured
MEMORY.mdfile and duplicates every parsed section into thecontentcolumn of a persistent SQLite database. The stored text is not encrypted or redacted. The implementation creates the destination directory using the process's default permission behavior and does not explicitly enforce owner-only permissions on either the directory or database.This is security-sensitive because
SKILL.md:103-110describes memory search as a required step before tasks and explicitly anticipates retrieval of server addresses and credentials. Persisting full section content is not necessary to calculate TF-IDF similarity; th ...[truncated 1945 chars]- Remediation
View remediation
Remediation Suggestions
- Create the vectors directory with owner-only permissions (
0700) and enforce0600permissions on the SQLite database after creation. - Do not index credentials, private keys, access tokens, session secrets, or other authentication material. Add configurable section and pattern-based exclusions.
- Redact common secret formats before persistence and reject sections marked as confidential.
- Minimize stored data by retaining vectors and source offsets or section identifiers rather than duplicating complete plaintext content.
- If full content must remain searchable, encrypt the database using a securely managed key that is not stored alongside it.
- Limit printed search excerpts and provide a mode that returns titles or references only. Warn users that standard output may be logged.
- Add explicit retention and secure-deletion behavior for rebuilds, updates, removed sections, old databases, backups, and temporary SQLite files.
- Replace the documentation's mandatory “before every task” search instruction with an opt-in, task-scoped workflow that accesses only the minimum relevant memory.
- Document that the index is a sensitive derivative of
MEMORY.mdand must receive equivalent or stronger access controls.
- Create the vectors directory with owner-only permissions (
