T09 · Insecure Skill Coding Practices
- Location
scripts/super_mem_cli.py:185- Finding
Incomplete Credential Filtering Permits Plaintext Secret Duplication
- Content
View full analysis
Vulnerability Details
File Location:
scripts/super_mem_cli.py:137-151andscripts/super_mem_cli.py:185-207
Vulnerability Type: Incomplete secret detection and unsafe persistent storage
Risk Level: MediumVulnerable Code
python _CRED_PATTERNS = [(r'ghp_[a-zA-Z0-9]{36}', '[GITHUB_TOKEN]')] def filter_credentials(content: str) -> str: for pat, repl in _CRED_PATTERNS: content = re.sub(pat, repl, content) return contentpython def bridge() -> Dict: try: import chromadb mp = chromadb.PersistentClient(path=os.path.expanduser("~/.mempalace/palace")) mp_col = mp.get_collection("mempalace_drawers") items = mp_col.get(limit=10000, include=["documents", "metadatas"]) if not items["ids"]: return {"synced": 0, "note": "MemPalace empty"} shared = _get_coll("super_mem_shared") all_ids = shared.get(limit=10000, include=[])["ids"] old_ids = [mid for mid in all_ids if mid.startswith("mp_") and not mid.startswith("mp_bridge_")] if old_ids: shared.delete(ids=old_ids) docs, metas, ids, embs = [], [], [], [] for i, did in enumerate(items["ids"]): doc = items["documents"][i] if items["documents"] else "" meta = items["metadatas"][i] if items["metadatas"] else {} docs.append(filter_credentials(doc)) metas.append({**meta, "source": "mempalace_bridge", "original_id": did}) ids.append(f"mp_bridge_{did}") embs = ollama_embed(docs) shared.add(documents=docs, metadatas=metas, ids=ids, embeddings=embs) return {"synced": len(docs), "deleted_old": len(old_ids)}Technical Analysis
The bridge copies as many as 10,000 MemPalace documents into a second persistent ChromaDB collection. Before persistence,
filter_credentials()only redacts GitHub classic personal acce ...[truncated 2458 chars]- Remediation
View remediation
Remediation Suggestions
- Apply a single, centralized secret-validation routine to all storage paths, including
bridge(),store(), and mining workflows. - Make bridge synchronization fail closed: reject or quarantine any document that may contain a credential instead of persisting partially redacted content.
- Detect a broader set of secret formats, including:
- PEM and OpenSSH private-key blocks
- AWS and other cloud-provider credentials
- Bearer and authorization headers
- Database and service connection strings
- GitHub, GitLab, Slack, OAuth, and generic API tokens
- Password and secret assignments in common configuration formats
- Use entropy-based detection or a maintained secret-scanning library in addition to regular expressions.
- Exclude sensitive files and directories before mining, including credential stores, environment files, SSH directories, cloud configuration directories, key files, and version-control secret files.
- Do not submit rejected or unredacted content to the embedding service.
- Minimize duplicated data and define retention and deletion controls for both MemPalace and SuperMem databases.
- Restrict database file permissions to the owning account and review whether backups include these stores.
- Add automated tests covering representative private keys, cloud keys, authorization headers, connection strings, and provider-specific tokens.
- Provide a dry-run bridge mode that reports rejected records without copying their contents.
- Apply a single, centralized secret-validation routine to all storage paths, including
