Back to skill

Security audit

Tiered Context Manager

Security checks for vulnerabilities and agentic risk

Overview

The skill has a legitimate context-management purpose, but it can rewrite sessions and persist/share conversation content across agents with weak scoping and several integrity risks.

Review carefully before installing. Use only on non-sensitive sessions unless you are comfortable with conversation content being summarized, rewritten, backed up, and copied into shared agent memory/inbox files. Prefer dry-run operation, restrict filesystem permissions to approved OpenClaw session and memory directories, and avoid enabling cross-agent handoffs until consent, redaction, path validation, and session rewrite bugs are fixed.

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
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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 (5)

T02 · Agent Memory Poisoning

Error
Location
scripts/cross_agent_context.js:22
Finding

Persistent Cross-Agent Memory Poisoning Through Untrusted Session Content

Content
View full analysis
5 && cleaned.length < 500) { extracted ...[truncated 2571 chars]
Remediation
View remediation

T01 · Skill Instruction Hijacking

Error
Location
scripts/l3_ai_compressor.js:94
Finding

Indirect Prompt Injection in L3 AI Compression Tasks

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/tiered-engine.js:112
Finding

Malformed JSONL Serialization Can Corrupt Session Files

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/tiered-engine.js:284
Finding

Inverted Compression Threshold Logic Causes Premature and Excessive Mutation

Content
View full analysis
0) { const writeResult = safeWriteSession(sessionFile, messages, rawLines, this._logger); if (writeResult.ok) { incrementCompactCount(sessionFile); return { ok: true, compacted: true, reason: `tiered_l1_micro`, result: { summary: `L1微压缩: ${l1Result.compacted}项, 释放~${l1Result.tokensFreed.toFixed(0)}tokens`, tokensBefore: currentTokenCount, tokensAfter: Math.max(0, currentTokenCount - l1Result.tokensFreed), details: { level: 1, compacted: l1Result.compacted, backup: writeResult.backupFile } } }; } } return { ok: true, compacted: false, reason: "tiered_l1_nothing_to_compress" }; } // L2: 部分压缩 (0.75 <= ratio < 0.90) if (ratio < LEVEL2_THRESHOLD) { l2Result = level2PartialCompact(messages, this._logger); if (l2Result.compacted > 0) { const writeResult = safeWriteSession(sessionFile, messages, rawLines, this._logger); if (writeResult.ok) { incrementCompactCount(sessionFile); return { ok: true, compacted: true, reason: `tiered_l2_partial`, result: { summary: `L2部分压缩: ${l2Result.compacted}项, 释放~${l2Result.tokensFreed.toFixed(0)}tokens`, tokensBefore: currentTokenCount, tokensAfter: Math.max(0, currentTokenCount - l2Result.tokensFreed), details: { level: 2, compacted: l2Result.compacted, backup: writeResult.backupFile } } }; } } return { ok: true, compacted: false, reason: "tiered_l2_nothing_to_compress" }; } // L3: 需要我们自己的AI来处理(写入inbox) this._logger.info(`[TieredContextEngine] L3 needs ...[truncated 1504 chars]
Remediation
View remediation
= 0.95) { // L3 } else if (ratio >= 0.90) { // L2 } else if (ratio >= 0.75) { // L1 } else { return { ok: true, compacted: false, reason: "below_threshold" }; } ``` 2. Define a dedicated `LEVEL3_THRESHOLD` constant rather than treating the final branch as unconditional. 3. Align comments, documentation, configuration, and runtime behavior. 4. Add boundary tests for ratios immediately below, equal to, and immediately above 0.75, 0.90, and 0.95. 5. Require a minimum estimated token count in addition to file size before allowing standalone mutation. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/tiered_standalone.js:159
Finding

Unvalidated Session Paths Permit Reads and Overwrites Outside the Session Directory

Content
View full analysis
b.sizeKb - a.sizeKb); return result; } catch (e) { logError(`Failed to load sessions.json: ${e.message}`); return []; } } ``` ```javascript const result = await engine.compact({ sessionFile: session.sessionFile, tokenBudget, currentTokenCount, sessionId: session.sessionId, runtimeContext: { workspaceDir: "E:\\zhuazhua\\.openclaw\\.openclaw\\workspace" } }); ``` ```javascript const dir = path.dirname(sessionFile); const basename = path.basename(sessionFile); tmpFile = path.join(dir, `.${basename}.tmp`); fs.writeFileSync(tmpFile, newLines.join("}\n") + "\n", "utf-8"); if (fs.existsSync(sessionFile)) { fs.copyFileSync(sessionFile, backupFile); } fs.renameSync(tmpFile, sessionFile); ``` ### Technical Analysis The scanner obtains `sessionFile` from `sessions.json` and only verifies that the path exists. It does not canonicalize the path, confirm that it is beneath an approved agent-session directory, reject symbolic links, or verify that it is a regular session file. The engine then reads, creates a temporary file be ...[truncated 1334 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (48)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The skill claims advanced context compression and monitoring but apparently only writes shared state files and backups locally. This is risky in context-management software because conversation state is sensitive, and undocumented backups or shared-state files can expose data to other processes or cause unintended retention beyond user expectations.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The skill claims advanced context compression and monitoring but apparently only writes shared state files and backups locally. This is risky in context-management software because conversation state is sensitive, and undocumented backups or shared-state files can expose data to other processes or cause unintended retention beyond user expectations.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

The skill claims advanced context compression and monitoring but apparently only writes shared state files and backups locally. This is risky in context-management software because conversation state is sensitive, and undocumented backups or shared-state files can expose data to other processes or cause unintended retention beyond user expectations.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The skill claims advanced context compression and monitoring but apparently only writes shared state files and backups locally. This is risky in context-management software because conversation state is sensitive, and undocumented backups or shared-state files can expose data to other processes or cause unintended retention beyond user expectations.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill claims advanced context compression and monitoring but apparently only writes shared state files and backups locally. This is risky in context-management software because conversation state is sensitive, and undocumented backups or shared-state files can expose data to other processes or cause unintended retention beyond user expectations.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 69)May include surrounding context.

md
| 主引擎 | `tiered-engine.js` | L1/L2/L3压缩入口 |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 70)May include surrounding context.

md
| L3压缩 | `l3_ai_compressor.js` | AI摘要任务队列 |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 72)May include surrounding context.

md
| 跨Agent | `cross_agent_context.js` | 知识共享 |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 74)May include surrounding context.

md
| 统计分析 | `compression_stats.js` | 效果统计 |

Ssd 3

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module is explicitly designed to extract and share session knowledge between agents, including user-originated information, which creates a built-in data retention and dissemination mechanism. In a context-management skill, that functionality is especially risky because it normalizes broad persistence and reuse of conversational content beyond the originating agent's scope.

Content

No source excerpt is available for this finding.

Ssd 3

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The extraction patterns deliberately target 'remember' and 'record' style statements, which are likely to include durable user instructions, personal preferences, and sensitive facts, and then prepare them for shared persistence. That semantic targeting increases the likelihood that the system captures exactly the kinds of data users expect to remain contextual rather than broadly redistributed.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

Session-derived content is written to shared files with no user-facing warning, consent, or disclosure mechanism. Silent persistence of conversational data is dangerous because users may reveal credentials, internal paths, business data, or personal information under the assumption the content remains within the active session.

Content

No source excerpt is available for this finding.

Ssd 3

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

Including recent message previews and extracted knowledge in handoff files exposes raw user content to another agent by default, not just abstract state needed for continuation. Because this skill's stated purpose is context optimization, the inclusion of readable conversation snippets makes the feature more dangerous by preserving and spreading sensitive content rather than merely compressing it.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The agent handoff flow copies recent messages and extracted knowledge into another agent's inbox without warning or approval. This silently expands access to user content and can leak sensitive material across agents, sessions, or operators, especially in multi-tenant or shared workstation environments.

Content

No source excerpt is available for this finding.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
90% confidence
Finding

The code constructs and returns a prompt that embeds session-file paths, message previews, and operational instructions telling another AI to read and process the full session. This creates a prompt-injection and data-exfiltration pathway: untrusted session content can flow into a downstream AI task, and the generated task artifact may expose sensitive context to other agents in the shared inbox environment.

Content

Scanner excerpt · scripts/l3_ai_compressor.js (reported line 171)May include surrounding context.

js
请现在开始处理这个压缩任务。`;

  return prompt;
}

/**

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill advertises executable scripts and engine APIs that imply file read/write behavior, but the manifest does not declare any tool scope or permissions boundary. In an agent ecosystem, undeclared filesystem access reduces reviewability and can let a skill modify local state or conversation artifacts in ways the operator did not explicitly approve.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill describes tiered compression and memory tiering without warning that data may be truncated, summarized, altered, or discarded. In a conversation-management context, this can directly affect integrity and auditability by causing users or downstream agents to act on incomplete or lossy history without informed consent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Cross-agent knowledge sharing is advertised with no privacy or confidentiality warning, even though it may expose conversation context, summaries, or memory artifacts to other agents. In a multi-agent environment this increases the blast radius of sensitive data and can create unauthorized disclosure across tasks, users, or trust boundaries.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The document explicitly describes cross-agent knowledge sharing and real-time session monitoring, but provides no privacy boundaries, consent model, data minimization rules, or retention/access controls. In a multi-agent context manager, these features can enable unannounced propagation of sensitive conversation content across agents or dashboards, increasing the risk of privacy leakage and inappropriate secondary use of user data.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The docstrings and function names for loadDailyStats/saveDailyStats indicate a dedicated daily-stats persistence mechanism, and getDailyStats reads from DAILY_STATS_FILE. However, recordCompression updates stats.daily in the main stats object and never calls saveDailyStats, so the documented daily-stats file workflow is contradicted by actual behavior.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The module persists extracted conversation content into a globally shared directory and appends it to a shared knowledge file accessible across agents. That creates an unauthorized data propagation channel for user instructions, preferences, facts, and potentially secrets, which exceeds simple local context compression and increases the blast radius of any sensitive data present in a session.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The handoff feature writes extracted knowledge plus previews of recent messages into another agent's inbox file, effectively copying conversation content across agent boundaries. This can expose sensitive user content to agents that were not part of the original interaction and creates a secondary persistent record without consent or need-to-know enforcement.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The top-level comment explicitly states the workflow ends with 'Compressed content is written back'. In the implementation, the module reads session files, writes task/result/log markdown files under the inbox, and parses completed results, but never writes compressed content into the original session file.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The generated prompt is written entirely in Chinese, including task instructions and output expectations, which imposes a specific language on downstream processing. There is no indication that the user can choose the language or that the Chinese-only constraint is justified by a region-specific requirement.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The summarization instructions explicitly direct retention of user preferences and system configuration from full session contents, which can cause sensitive data to be surfaced and propagated into derivative artifacts. In a cross-agent knowledge-sharing skill, this increases privacy risk and may expose secrets or environment details more broadly than the original session required.

Content

No source excerpt is available for this finding.