T05 · Unauthorized Access and Privilege Escalation
- Location
rituals/migrate_memories.py:57- Finding
Persistent Duplication of Sensitive Workspace and Agent-State Files
- Content
View full analysis
Vulnerability Details
File Location:
rituals/migrate_memories.py:57-86, 95-133
Vulnerability Type: Excessive access to and duplication of workspace state
Risk Level: MediumEvidence
python def migrate_file(file_path: Path, source_name: str, file_type: str = "general") -> dict: """Migrate one file into shared memory.""" key_info = extract_key_info(file_path, file_type) if not key_info or key_info == "[读取失败: ]": return {"status": "skipped", "reason": "无有效内容", "file": str(file_path)} timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") filename = f"migrated_{source_name}_{timestamp}.md" filepath = L1_DIR / filename markdown = f"""# 迁移记忆 - {source_name} **来源**: {file_path.name} **迁移时间**: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")} **类型**: {file_type} --- {key_info} --- *此记忆由共生前迁移而来* """ with open(filepath, "w", encoding="utf-8") as f: f.write(markdown)python def migrate_all(): """Perform complete migration.""" results = [] memory_dir = WORKSPACE / "memory" if memory_dir.exists(): for f in sorted(memory_dir.glob("*.md")): if f.name.startswith("."): continue result = migrate_file(f, f"memory_{f.stem[:10]}", "memory") results.append(result) memory_md = WORKSPACE / "MEMORY.md" if memory_md.exists(): result = migrate_file(memory_md, "长期记忆", "memory") results.append(result) soul_md = WORKSPACE / "SOUL.md" if soul_md.exists(): result = migrate_file(soul_md, "灵魂定义", "soul") results.append(result) user_md = WORKSPACE / "USER.md" if user_md.exists(): result = migrate_file(user_md, "用户画像", "user") results.append(result) agents_md = WORKSPACE / "AGENTS.md" if agents_md.exists(): result = migrate_file(agents_md, "智能体框架" ...[truncated 2257 chars]- Remediation
View remediation
Remediation Suggestions
- Require explicit, informed consent before migration and present a per-file selection list.
- Default to migrating only user-designated memory files; exclude
AGENTS.md,TOOLS.md,SOUL.md, andUSER.md. - Establish an allowlist of approved paths and reject symbolic links or paths that resolve outside the expected memory directory.
- Scan extracted content for credentials, tokens, private keys, connection strings, and other secrets before writing it.
- Keep agent configuration, tool configuration, and user memories in separate stores with distinct access controls.
- Add retention, deletion, and source-tracking controls so migrated copies can be located and removed when the originals are revoked.
- Set restrictive owner-only permissions on
.twindirectories and generated files. - Record an audit event identifying which files were read, what categories were retained, and who authorized the migration.
