Back to skill

Security audit

Adaptive Rag Engine

Security checks for vulnerabilities and agentic risk

Overview

This RAG memory skill is not clearly malicious, but it asks agents to implicitly follow unreviewed workspace files and can index private memory content into a plaintext local file.

Review this before installing if your OpenClaw memory folder contains private, medical, financial, business, or credential-like notes. Only use it in a workspace where you control the referenced protocol file and are comfortable with automatic retrieval behavior and creation of a plaintext memory index.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T01 · Skill Instruction Hijacking

Warning
Location
SKILL.md:32
Finding
Unvalidated External Protocol Can Override Agent Behavior<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 32-34 **Vulnerability Type**: `T01: Skill Instruction Hijacking` **Risk Level**: Medium ### Vulnerable Code ```markdown 1. **读取协议文件**: `rules/adaptive-rag-protocol.md` — 获取完整决策树 2. **读取胶囊索引**: `memory/topics/.capsule-index.json` — 获取 42 个胶囊元数据 3. **按决策树执行**: 每次需要记忆时,走 Router → Pre-filter → Search → Rank → CRAG → Generate → Verify ``` ### Technical Analysis The Skill instructs the Agent to read and follow `rules/adaptive-rag-protocol.md`, but that protocol is not included in the audited Skill package. It is a mutable workspace file outside the reviewed trust boundary. No integrity verification, schema validation, instruction filtering, or precedence restriction is defined before the external protocol is followed. Consequently, anyone who can modify that workspace file could insert instructions unrelated to retrieval, alter session goals, request unsafe tool use, or attempt to override existing safety constraints. The external capsule index is also loaded without validation. While the index is primarily presented as data, untrusted textual fields could be interpreted as instructions unless the Agent strictly separates retrieved content from executable directives. ### Attack Path 1. An attacker or compromised local process obtains write access to `rules/adaptive-rag-protocol.md`. 2. The attacker adds instructions that redirect the Agent, modify retrieval behavior, disclose information, or invoke available tools. 3. A user submits a request that activates the Adaptive RAG Skill. 4. Following `SKILL.md`, the Agent reads the modified external protocol. 5. The Agent treats the injected content as operational instructions and changes its current-session behavior. 6. The resulting impact depends on the tools and data available to the Agent during that session. ### Impact Assessment This issue can alter the Agent's current-session goals, retrieval decisions, output validation, and tool-use ...[truncated 551 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Package the protocol inside the reviewed Skill directory rather than loading it from a mutable workspace location. 2. Pin the protocol to an approved version or verify it against a cryptographic hash before use. 3. Explicitly state that loaded protocols, indexes, memories, and retrieved documents are untrusted data and cannot override system, developer, user, or safety instructions. 4. Parse the protocol through a restrictive schema that accepts only defined routing and scoring fields instead of arbitrary natural-language directives. 5. Reject unexpected fields, tool requests, role-like instructions, and content that attempts to change instruction precedence. 6. Apply restrictive filesystem permissions so only the trusted Skill administrator can modify the protocol. 7. Record and surface the protocol version and integrity result whenever it is loaded. 8. Validate and sanitize textual fields from `.capsule-index.json` before placing them in an Agent context. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
scripts/build-capsule-index.py:14
Finding
Broad Agent-Memory Content Is Aggregated into a Plaintext Index<![CDATA[ ## Vulnerability Details **File Location**: `scripts/build-capsule-index.py`, lines 14-15, 41-66, and 68-105 **Vulnerability Type**: `T09: Insecure Skill Coding Practices` **Risk Level**: Low ### Vulnerable Code ```python TOPICS_DIR = Path(os.path.expanduser("~/.openclaw/workspace/memory/topics")) OUTPUT_FILE = TOPICS_DIR / ".capsule-index.json" ``` ```python def extract_summary(filepath, max_chars=200): """提取胶囊摘要:优先取第一个标题或前几行""" try: with open(filepath, 'r', encoding='utf-8') as f: content = f.read(2000) lines = content.strip().split('\n') # 跳过开头的标题行(# 开头) summary_lines = [] for line in lines: stripped = line.strip() if not stripped: continue if stripped.startswith('#'): continue # 跳过标题行 summary_lines.append(stripped) if len(' '.join(summary_lines)) > max_chars: break summary = ' '.join(summary_lines)[:max_chars] return summary if summary else "(空胶囊)" except Exception: return "(读取失败)" ``` ```python def build_index(): """扫描所有胶囊,构建索引""" capsules = [] md_files = sorted(TOPICS_DIR.glob("*.md")) for f in md_files: name = f.stem size = f.stat().st_size mtime = datetime.fromtimestamp(f.stat().st_mtime).isoformat() summary = extract_summary(f) tags = classify_capsule(name) capsules.append({ "id": name, "name": name, "size_bytes": size, "modified": mtime, "summary": summary, "tags": tags, "path": str(f.relative_to(Path(os.path.expanduser("~/.openclaw/workspace")))), }) index = { "version": "1.0", "built_at": datetime.now().isoformat(), "total_capsules": len(capsules), "categories": { "medical": [c["id"] for c in ...[truncated 3049 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Require an explicit allowlist of files eligible for indexing rather than scanning every Markdown file automatically. 2. Support a front-matter property or dedicated marker such as `index: false` for confidential memories. 3. Detect and redact common secrets, credentials, personal identifiers, medical information, and financial data before storing summaries. 4. Store only the minimum metadata required for retrieval; omit excerpts and full paths when they are unnecessary. 5. Create the output atomically with owner-only permissions, such as mode `0600`, and document the required ownership of the containing directory. 6. Refuse to overwrite a symbolic link and verify that the resolved output remains inside the expected topics directory. 7. Consider storing hashes or derived search tokens instead of raw memory excerpts. 8. Provide a preview mode that shows which files and fields will be indexed before writing the output. 9. Define retention and deletion behavior so stale sensitive excerpts do not remain after source files are removed or reclassified. 10. Add tests confirming that excluded files, secret patterns, symbolic-link destinations, and overly permissive output modes are handled safely. ]]>
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The skill is described as an autonomous adaptive RAG engine with routing, CRAG correction, and validation, but the documented concrete behavior is limited to reading local files and running indexing/evaluation scripts. This mismatch can mislead operators and downstream agents into granting trust, autonomy, or broader activation than the implementation justifies, which is a security concern because capability transparency is required for safe delegation.

Lp3

Medium
Category
MCP Least Privilege
Confidence
86% confidence
Finding
The skill advertises behavior that reads protocol and index files and invokes local Python scripts, but it does not declare any explicit tool scope such as file access permissions. In an agent environment, undeclared file read/write capability weakens least-privilege boundaries and can cause the skill to access or modify workspace data without clear review or consent.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The trigger description is very broad, covering memory search, retrieval, and answering complex questions, which overlaps with many normal conversations. In an agentic system, overly broad activation criteria can cause the skill to run unexpectedly, expanding access to files and scripts in contexts where the user did not intend retrieval or background processing.

Natural-Language Policy Violations

Medium
Confidence
83% confidence
Finding
文件中的名称说明和整体使用文案均以中文固定表述,且未声明这是面向特定中文环境的受限技能,也未向用户提供语言/locale 选择。按照语言/locale 策略,若技能实际强制特定语言而无用户选择或合理约束说明,属于自然语言政策风险。

Vague Triggers

Medium
Confidence
89% confidence
Finding
Stating that the skill operates at the protocol layer and does not require explicit invocation makes activation implicit, while the document does not define concrete constraints or guardrails for when it should run. Implicit auto-execution increases the chance of unauthorized or unintended behavior, especially for a skill that reads files and influences memory/search workflows across conversations.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This code file includes natural-language strings such as the title, usage comments, argument help text, and runtime output only in Chinese. That imposes a specific language on all users without any documented opt-in or locale selection, which matches the language/locale policy violation category.

Natural-Language Policy Violations

Low
Confidence
94% confidence
Finding
This Python file contains natural-language descriptions and console output in Chinese only, including the header comments and runtime status messages. Under the policy for natural-language violations, forcing a specific language without opt-in can be a locale-policy issue when no alternative or user choice is offered.

Static analysis

No suspicious patterns detected.