T02 · Agent Memory Poisoning
- Location
memory_api.py:19- Finding
Persistent Memory Poisoning Through Untrusted Captured Content
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a local memory system, but it stores and reuses user/agent content persistently with weak controls and overstates its safety and implemented features.
Review carefully before installing. Use it only if you are comfortable with local long-term storage of conversation-derived memories, command errors, corrections, and vectorized text under ~/.openclaw/workspace. Do not enable automatic capture for sensitive work unless redaction, review, deletion, and rule-promotion controls are added, and avoid following the sudo, --break-system-packages, and kill -9 examples without manual verification.
memory_api.py:19Persistent Memory Poisoning Through Untrusted Captured Content
memory_api.py:19Sensitive Data Is Persisted Without the Advertised Automatic Redaction
SKILL.md:82Unpinned Dependencies and Unsafe System-Package Installation Guidance
The declared description promises a broader self-evolving memory system with automatic error capture, learning from corrections, best-practice accumulation, BGE-based vector modeling, and a four-layer architecture. The supplied code only performs retrieval: it reads existing markdown files from local memory directories, runs a Chroma semantic query, and prints results before command execution. Chroma usage is consistent with part of the description, and checking errors/corrections/practices before execution is related to memory retrieval. However, the major advertised capabilities—automatic capture, learning/evolution, explicit BGE integration, and the four-layer architecture—are not implemented in this code chunk. Therefore the description materially overstates what this code actually does.
该代码与声明存在明显描述—行为不一致。虽然代码确实涉及“记忆”管理,并且使用了 Chroma 做查询,部分符合“向量记忆/语义检索”的方向,但核心卖点没有落地:没有 BGE 向量模型集成、没有四层记忆架构、没有自动从错误或用户纠正中进行自我进化的逻辑。代码更准确地说是一个简化的本地记忆记录与查询接口,其中“capture”是手动写入 Markdown,“search”依赖外部已存在的 Chroma collection,“check_before_execute”只是做关键词扫描提醒。因此其实际能力弱于且不同于声明的主要目的,构成实质性不匹配。
The declared description promises a sophisticated vector-memory self-evolution system with embedding models, a vector store, semantic retrieval, and learning from corrections. The supplied code does none of that. It only reads local Markdown files from a memory directory, uses regex to extract rule-like sentences, performs very simple contradiction checks based on keywords such as '禁止', '必须', and '不要', and appends conflicts to a JSONL log. This is a materially different and much narrower function than the declared purpose, so the description does not accurately represent the actual behavior.
声明描述的是一个较完整的自我进化向量记忆系统,包含学习、错误捕获、记忆分层和知识积累等多种能力;但实际代码仅执行本地 Chroma 向量库查询并输出结果,功能范围明显更窄,且还通过硬编码日期过滤到特定一天的对话记录。虽然“语义检索”这一点与声明部分一致,但代码并没有实现声明中的核心系统能力,主用途更像是一个临时的当天对话快速搜索工具,因此描述与实际行为存在明显不匹配。
该代码块的核心行为与声明用途明显不符。声明描述的是一个复杂的向量记忆与自我进化系统,但代码只做基于正则的敏感信息脱敏,并在日志写入前清洗内容。这不是对声明功能的实现细节支撑,而是一个完全不同的主要用途。虽然函数名中有 memory_api.log,可能属于更大记忆系统的配套工具,但就该代码块本身而言,它既不进行向量化、存储到 Chroma、语义检索,也不执行错误捕获学习或最佳实践积累,因此应判定为描述与行为不匹配。
The declared description presents a full self-evolving memory system with embedding/model integration, layered memory design, and adaptive learning behaviors. The supplied code does not implement those capabilities. Instead, it is a read-only test utility for an already-existing Chroma database: it connects to a local persistent vector store, retrieves a collection, counts entries, and prints sample records and metadata. While it is related to vector memory infrastructure in a narrow sense, its actual primary purpose is database inspection/testing, which is materially narrower and different from the declared autonomous memory-evolution system.
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
for pattern in patterns:
matches = re.findall(pattern, content, re.IGNORECASE)
rules.extend(matches)
return rules
def check_conflicts(new_memory):
"""检查新记忆是否与现有记忆冲突"""
该文档全文以中文呈现,未见提供其他语言选项、用户选择机制,或说明该技能仅面向特定中文场景。根据规则,未经过用户选择而强制特定语言/locale 属于自然语言策略违规。
The skill documents file read/write and network-capable behavior but does not declare any explicit tool scope or permission boundaries. In agent environments, missing scope declarations can cause over-broad execution authority and make it harder for users or platforms to constrain what the skill may access.
The skill explicitly promotes automatic recording of errors, corrections, events, and chat-analysis outputs into persistent storage, but the privacy warning is minimal and does not clearly describe user-data impact, retention, or consent. This can lead to unintended collection and long-term storage of sensitive user content, especially in agent environments handling secrets, internal code, or personal data.
The feature list advertises broad automatic retention of user corrections, events, and chat history for later analysis and reuse. Persistent collection of conversational and behavioral data can expose secrets, personal information, and sensitive business context if the stored files or vector database are later accessed, indexed, or reused improperly.
Auto-writing validated rules into SOUL.md and analyzing chat history creates a persistence-and-policy mutation risk: transient or sensitive user instructions may become durable guidance that affects future behavior. If incorrect, sensitive, or adversarial content is promoted, it can poison future responses or leak private preferences and internal practices.
The architecture explicitly instructs the system to automatically log user corrections and important events into persistent memory layers, increasing the likelihood that sensitive interaction data is retained beyond the immediate session. Because the system also describes later semantic retrieval and rule application, stored content may propagate into future decisions in ways users did not expect.
The documented setup creates persistent session memory directories for errors, corrections, events, archives, and vector data under the user's home directory. Persistent storage is central to the skill's design, but without explicit consent, retention limits, access control guidance, or deletion procedures, it increases the risk of long-lived sensitive data accumulation.
# 1. 创建目录结构
mkdir -p ~/.openclaw/workspace/memory/{errors,corrections,practices,events,gaps}
mkdir -p ~/.openclaw/workspace/memory_archive
mkdir -p ~/.openclaw/workspace/vector_db/memories
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
capture( typ="error", title="npm install 权限不足", content="需要 sudo 或使用本地安装", context="全局安装依赖" )
The example shows an execution-precheck system recommending sudo npm install, which can encourage unnecessary privileged package installation. In agent-assisted workflows, normalizing auto-suggested root elevation is risky because it may lead users to run untrusted install scripts as root, expanding compromise impact.
check_before_execute("npm install -g xxx")
### 4. 触发进化
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
title="npm install 权限不足",
content="permission denied",
context="全局安装依赖",
suggested_fix="使用 sudo 或本地安装"
)
# 下次执行前自动检查
The example demonstrates the system recommending sudo npm install based on historical memory. A memory-driven mechanism that suggests privileged commands can amplify prior bad practice and potentially steer future executions toward root-level actions without adequate safety review.
check_before_execute("npm install")
### 场景 2:用户纠正后的规则固化
The troubleshooting instructions include a destructive command sequence that force-kills any process bound to port 11434 using kill -9, without warning about collateral impact. In shared or reused environments, this can terminate unrelated services and cause denial of service or data loss.
The skill states that validated rules are automatically written into SOUL.md, which is a persistent file modification with behavioral impact, but it does not warn the user or require confirmation. Because this file appears to influence future agent behavior, silent writes can create configuration drift, persistence of bad rules, or unauthorized modification of trusted instructions.
The skill explicitly describes analysis of chat records and automatic recording/report generation, but does not present a clear consent, retention, or privacy warning. In a memory/self-evolution skill, this creates a real risk of collecting, storing, and mining sensitive user content without informed approval, especially because the capability is framed as automatic and continuous.
The module docstring and all user-facing messages are written only in Chinese, and the file provides no indication that language selection is optional or that the skill is intentionally limited to a Chinese-only context. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation.
The module description and all user-facing messages are written in Chinese, which imposes a specific language on users. The file does not offer any language selection or explain that the skill is intended only for a Chinese-speaking or region-specific context.
The docstring at L019 explicitly claims the function captures memory to "L2", implying a specific layer in the advertised four-layer memory architecture. However, the implementation writes entries directly to MEMORY_DIR / <date>.md without any layer-specific handling, and this also differs from check_before_execute, which expects per-type subdirectories under MEMORY_DIR. That is an active mismatch between stated intent and behavior.
The module docstring and function docstring are written only in Chinese, and all user-facing CLI messages in the script are also Chinese. This imposes a specific language on users without any opt-in, fallback, or documented regional justification, which matches the language/locale policy violation criteria.