T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/brain.py:222
- Finding
- Automatic cloud mirroring can disclose persistent memory without explicit per-write consent<![CDATA[ ## Vulnerability Details **File Location**: `scripts/brain.py:222-299`, `scripts/brain.py:748-778`, `scripts/memory.sh:49-77`, `_meta.json:11-14` **Vulnerability Type**: Automatic transmission of sensitive persistent data **Risk Level**: High ### Vulnerable Code ```python def _supermemory_mode() -> str: return os.environ.get("AGENT_BRAIN_SUPERMEMORY_SYNC", "auto").strip().lower() def _supermemory_api_key() -> str: return os.environ.get("SUPERMEMORY_API_KEY", "").strip() def _maybe_sync_supermemory(entry: dict): mode = _supermemory_mode() if _is_falsy(mode): return api_key = _supermemory_api_key() if not api_key: if mode != "auto" and _is_truthy(os.environ.get("AGENT_BRAIN_SUPERMEMORY_DEBUG", "")): print("SuperMemory sync warning: SUPERMEMORY_API_KEY is not set", file=sys.stderr) return memory_payload = { "origin": "agent-brain", "entry_id": entry.get("id"), "type": entry.get("type"), "content": entry.get("content"), "source": entry.get("source"), "source_url": entry.get("source_url"), "tags": entry.get("tags", []), "context": entry.get("context"), "created": entry.get("created"), "confidence": entry.get("confidence"), "session_id": entry.get("session_id"), "correction_meta": entry.get("correction_meta"), } tags = [_sanitize_supermemory_tag("agent-brain"), _sanitize_supermemory_tag(entry.get("type", "entry"))] for tag in entry.get("tags", []): if len(tags) >= 8: break tags.append(_sanitize_supermemory_tag(tag)) tags = list(dict.fromkeys(tags)) req_payload = { "content": json.dumps(memory_payload, ensure_ascii=False), "customId": f"agent_brain_{entry.get('id', uuid.uuid4())}", "containerTags": tags, } api_url = os.environ.get( "SUPERMEMORY_API_URL", "https://api.supermemory.ai/v3/documents", ...[truncated 4384 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Change `AGENT_BRAIN_SUPERMEMORY_SYNC` to `off` by default. 2. Require explicit, informed user consent before enabling cloud synchronization. 3. Avoid automatically loading cloud credentials from a generic `.env` file. 4. Display the destination and data categories before the first outbound transfer. 5. Require HTTPS and restrict `SUPERMEMORY_API_URL` to an explicit allowlist. 6. Reject URLs containing user information and revalidate the final connection destination. 7. Minimize outbound payloads; omit correction history, context, session IDs, and source URLs unless individually required. 8. Apply comprehensive sensitive-data detection and redaction to every outbound field. 9. Provide a separate command for explicit synchronization instead of invoking it implicitly after every write. 10. Add tests proving that no network request occurs under the default configuration. ]]>
