Back to skill

Security audit

Dragon Session Compactor

Security checks for vulnerabilities and agentic risk

Overview

This skill has a coherent local session-compaction purpose, but it rewrites retained conversation content into a system-role message and can persist sensitive chat history automatically.

Review before installing. Use only with conversations you are comfortable storing locally, avoid automatic or cron-based compaction unless you trust the environment, and prefer changes that store summaries as non-system data with redaction and bounded retention.

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

Error
Location
scripts/compact.mjs:177
Finding

Untrusted Conversation Content Is Promoted to a System-Role Message

Content
View full analysis
{ lines.push(`${i + 1}. ${req}`); }); // 待完成事项 const pending = extractPendingWork(messages); if (pending.length > 0) { lines.push(''); lines.push('### 待完成事项'); pending.forEach(item => { lines.push(`- ${item}`); }); } ``` ```javascript const newMessages = [ { role: 'system', content: `\n${newSummary}\n\n### 最近消息(未压缩)\n---\n`, timestamp: new Date().toISOString() }, ...toPreserve ]; ``` ### Technical Analysis The compaction process extracts portions of user and assistant messages and inserts them substantially verbatim into `newSummary`. It then stores that summary as a message with the privileged `system` role. No trust-boundary separation, instruction filtering, structured encoding, or explicit untrusted-data delimiters are applied before the extracted conversation text is promoted. An attacker-controlled user message can therefore contain imperative instructions that become embedded in a system-role message following compaction. The `extractRecentUserRequests()` path copies recent user content, while `extractPendingWork()` copies content containing keywords such as `todo`, `next`, or `pending`. These provide direct routes for attacker-controlled instructions to reach the generated system message. ### Attack Path 1. An attacker submits a user message containing malicious instructions. 2. The attacker structures the message as a recent request or includes a pending-work keyword such as `todo`, `next`, or `pending`. 3. The session reaches the configured compaction threshold and `compact()` is invoked. 4. The extraction functions copy the attacker-controlled text into the generated summary. 5. The application stores the generated summary with `role: 'system'`. ...[truncated 687 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/check-compact.mjs:15
Finding

Scheduled Checker Writes a Log Outside the Project Boundary

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (14)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/compact.mjs run

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
node scripts/compact.mjs run

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
node scripts/compact.mjs run

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/compact.mjs run

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/compact.mjs run

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger phrases include common natural-language expressions like 'compact' and '上下文满了', which can plausibly appear in ordinary conversation and unintentionally activate the skill. In a context-rewriting skill, accidental invocation can cause unwanted summarization, persistence, or loss of fine-grained prior context.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill stores conversation content in a local '.clawsession.json' file and rewrites context, but the description does not clearly warn users about persistence, retention, and transformation of their messages. This undermines informed consent and can lead to sensitive data being stored or resurfaced unexpectedly.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The design explicitly retains user requests, tool-call history, file paths, and raw recent messages, which are all common carriers of secrets, personal data, and operational details. Summarization does not eliminate sensitivity; it can consolidate and preserve information in a form that is easier to leak or reuse later.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The sample summary format preserves named files, user requests, pending work, and uncompressed recent messages, demonstrating a concrete pathway for sensitive conversational details to be carried forward. Because this summary becomes part of future context, it increases the chance of accidental disclosure to later prompts, tools, or users with file access.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Incremental compaction accumulates prior summaries over time, creating durable long-term retention of historical conversation details that might otherwise age out of context. This increases both the exposure window and the probability that old sensitive data resurfaces in future interactions or local file inspection.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This code uses Chinese-only natural-language comments and user-facing console output, and nothing in the file indicates that the skill is region-specific or that users can opt into a language preference. That creates a language/locale policy concern under the rule for natural-language policy violations.

Content

No source excerpt is available for this finding.

Vague Triggers

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The manual invocation example uses a casual phrase ('压缩一下') rather than a strict command syntax, increasing the chance that ordinary user wording triggers compaction unexpectedly. While lower severity than automatic broad triggers, it still risks unintended state mutation and data persistence.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code presents all user-facing console messages in Chinese, including status, errors, usage, and help text. That creates a language/locale restriction in natural-language output without any user opt-in or documented justification, which matches the policy-violation category for forced language choice.

Content

No source excerpt is available for this finding.