Back to skill

Security audit

Context Assembler

Security checks for vulnerabilities and agentic risk

Overview

This context-preprocessor is not malicious, but it warrants Review because it reads local memory, turns selected content into prompt instructions, and attempts to retain task metadata on disk.

Install only if you are comfortable letting this skill read OpenClaw memory files and insert selected excerpts into an agent's prompt. Review or redact sensitive memory first, prefer explicit manual invocation over the generic trigger, inspect the generated context before use, and disable or protect the feedback log if task descriptions may contain private information.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • 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
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T01 · Skill Instruction Hijacking

Error
Location
scripts/assembler.py:346
Finding
Agent Session Instruction Hijacking Through Prompt-Ready Context Injection<![CDATA[ ## Vulnerability Details **File Location**: `scripts/assembler.py:346-457`; supporting usage instructions at `SKILL.md:30-42` **Vulnerability Type**: Agent prompt and behavior hijacking **Risk Level**: High ### Vulnerable Code ```python # scripts/assembler.py:346-356 agent_name = os.environ.get("AGENT_NAME", "your personal AI agent") identity = f"""=== IDENTITY [永久] === 你是 {agent_name} 的 personal AI agent。你有深度分析能力和自我进化机制。 """ blocks.append(identity) used += len(identity) date_str = datetime.now().strftime("%Y-%m-%d") task_block = f"""=== TASK CONTEXT === 任务: {task_desc} 时间: {date_str} (GMT+8) """ blocks.append(task_block) used += len(task_block) ``` ```python # scripts/assembler.py:376-386 # Add context snippets for high-relevance hits (up to 3) high_relevance = [r for r in memory_results if r["relevance"] == "high"][:3] for r in high_relevance: snippet = r["text"][:300].replace("\n", " ") line = f" 摘要: {snippet}\n" if len(line) <= remaining: mem_lines.append(line) remaining -= len(line) ``` ```python # scripts/assembler.py:411-424 if forbidden: forb_header = "=== FORBIDDEN PATTERNS [历史失败,禁止重试] ===\n" forb_lines = [forb_header] remaining = char_budget - used for fp in forbidden[:5]: ln = f"{fp}\n" if len(ln) <= remaining: forb_lines.append(ln) remaining -= len(ln) forb_block = "".join(forb_lines) blocks.append(forb_block) used += len(forb_block) ``` ```python # scripts/assembler.py:427-432 if profile.get("require_rules_core"): rules = """=== CORE RULES === - 操作前先写方案,等确认再动手 - trash > rm(删文件优先回收站) - 严格按事实陈述,标明信源 """ blocks.append(rules) used += len(rules) ``` ```python # scripts/assembler.py:455-457 # ── Block 7: Task Directive ── blocks.append(f"\n=== TASK ===\n{task_desc}\n") return "".join(blocks) ``` The documentation directs callers to place this output before the agent reasons: ```markdown <!-- SKILL.md:30-42 --> Task arrives → ...[truncated 2926 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Return structured data, such as JSON, instead of a prompt-ready instruction block. Separate fields should identify retrieved memories, timeline entries, and metadata. 2. Remove the permanent identity declaration, mandatory core rules, generated prohibitions, and repeated task directive from assembler output. 3. Treat `MEMORY.md`, daily notes, preference files, task descriptions, and environment variables as untrusted data. 4. Place retrieved content inside explicit data delimiters and state that it is reference material that cannot override system, developer, safety, or user instructions. 5. Validate and length-limit `AGENT_NAME` and task text. Reject control characters and instruction delimiters where practical. 6. Do not translate repeated failure titles into mandatory “do not retry” instructions. Return them as historical observations requiring independent validation. 7. Require the consuming agent to resolve instructions according to the established authority hierarchy and to ignore instructions embedded in retrieved content. 8. Add adversarial tests using memory entries and environment values containing prompt-injection payloads. Verify that they remain quoted data and cannot create new instruction sections. 9. If prompt insertion remains an intentional feature, document it explicitly as prompt modification and require informed opt-in by the caller. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
Findings (9)

Ae1

High
Category
analysis-evasion
Content
python3 scripts/assembler.py --task "check NAS disk health" --max-tokens 1500
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Lp3

Medium
Category
MCP Least Privilege
Confidence
82% confidence
Finding
The skill describes executable usage and references a Python script that reads workspace memory and may produce output files or logs, but it declares no explicit tool scope or permissions. In an agent ecosystem, missing scope declarations can let the agent invoke file and environment-capable behavior without clear policy boundaries, increasing the chance of unintended data exposure or unsafe file access.

Vague Triggers

Medium
Confidence
93% confidence
Finding
The agent-assisted trigger phrase, "optimize my context," is generic enough to overlap with normal user language, so the skill could activate when a user is merely making a broad request rather than intentionally invoking this preprocessor. Because the skill is designed to inject and transform context before reasoning, accidental invocation could alter agent behavior, expose internal memory selection logic, or cause unnecessary access to workspace memory.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
The file's natural-language instructions and output description are written entirely in Chinese, and multiple emitted prompt blocks also prescribe Chinese phrasing, but there is no indication that language is user-selectable or that the tool is intentionally region-specific. This creates a locale/language policy concern because the skill implicitly forces a specific language without opt-in.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The skill reads workspace memory files and injects matched content into its stdout output, which is intended to be spliced directly into later prompts. In this context, that means local notes, preferences, and memory content can be surfaced to downstream models or logs without explicit disclosure, increasing the risk of inadvertent sensitive-data propagation.

Description-Behavior Mismatch

Medium
Confidence
96% confidence
Finding
The skill advertises itself as a context preprocessor that outputs an injection block, but it also appends persistent telemetry to feedback/outcomes.jsonl. That hidden side effect changes the trust model: task descriptions and usage metadata are retained on disk, which can expose sensitive prompts, agent goals, or user data to later readers or other components.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The script stores the raw task description and related execution metadata in a persistent JSONL log without any visible warning, consent, or sanitization. Because task text may contain secrets, internal project details, or personal data, this creates a privacy and data-retention risk disproportionate to a preprocessing utility.

Natural-Language Policy Violations

Low
Confidence
78% confidence
Finding
The natural-language task keyword lists are partly language-specific and implicitly bias task classification toward Chinese and English inputs, but the file does not state that the skill is limited to those locales or provide any opt-in or fallback behavior. Under the policy for language/locale handling, this is a natural-language constraint that should be explicitly documented or made user-configurable.

Context-Inappropriate Capability

Low
Confidence
80% confidence
Finding
The skill's purpose is context preprocessing from workspace memory, but it derives its workspace root from OPENCLAW_WORKSPACE and injects agent identity from AGENT_NAME. While not inherently dangerous, reading environment state is not an obvious requirement of memory selection/timeline collapse and expands the skill's capability beyond the manifest's described scope.

Static analysis

No suspicious patterns detected.