Back to skill

Security audit

session-compactor

Security checks for vulnerabilities and agentic risk

Overview

This skill appears to be a session-compaction tool, but it needs review because it can weaken agent instruction boundaries and includes an unrelated GitHub publishing script.

Install only after reviewing the session-compaction behavior and removing or ignoring deploy.sh. Do not use this skill for security-sensitive sessions unless it preserves trusted instructions separately and never promotes user-derived summaries to system authority.

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

Error
Location
scripts/compact_session.js:67
Finding

User-Controlled Content Is Elevated to a System Message During Compaction

Content
View full analysis
80 ? '...' : ''); return `- **对话目标**: ${topic}\n- **消息数量**: 共 ${messages.length} 条 (已压缩)\n- **工具调用**: ${toolCalls.length} 次\n- **关键信息**: ${facts.length} 条\n- **保留上下文**: 最新 ${Math.floor(messages.length/3)} 条消息保持完整`; ``` ```javascript const keepCount = Math.max(config.minMessagesToKeep, Math.floor(messages.length / 3)); const toKeep = messages.slice(-keepCount); const toCompact = messages.slice(0, -keepCount); // 3. 生成摘要 const summary = generateSummary(toCompact); // 4. 构建压缩后的消息数组 const compressedMessages = [ { role: 'system', content: `## 会话摘要 (已压缩早期 ${toCompact.length} 条消息)\n\n${summary}\n\n---\n*注: 为控制token使用量,早期对话已压缩为摘要。如需回顾细节,请询问。*` }, ...toKeep ]; ``` ### Technical Analysis The implementation selects messages for removal solely according to their age. Consequently, early trusted system or developer instructions may be included in `toCompact` and removed from the resulting conversation. At the same time, `generateSummary()` extracts the first user message and interpolates up to its first 80 characters directly into `summary`. That summary is then assigned the privileged `system` role. This creates a trust-boundary violation: attacker-controlled user text is promoted from user-level content to system-level instructions. The generated text is not represented as quoted or separately typed untrusted data. A downstream language model may therefore interpret an injected directive as part of its active system instructions. Merely escaping Markdown would not resolve the fundamental issue because the role elevation itself is unsafe. This behavior also contradicts the architectural claim that ...[truncated 1490 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
deploy.sh:13
Finding

Deployment Script Can Publish Unintended Files to a Hardcoded External Repository

Content
View full analysis
/dev/null || true git remote add origin "${REMOTE_URL}" git branch -M main echo "📤 正在推送到 GitHub..." git push -u origin main ``` ### Technical Analysis The deployment script stages all files visible to Git by invoking `git add -A`. It does not use an allowlist, inspect staged files for secrets, or confirm which files will be committed. The script then removes any existing `origin` remote and replaces it with a hardcoded repository under `fangbb-coder`. The only working-directory validation is the presence of `SKILL.md`, which does not establish that the directory contains only intended project files. This creates both a confidentiality risk and a destructive configuration risk. Local credentials, environment files, generated artifacts, unrelated source files, or other untracked data may be committed and transmitted to the hardcoded external repository. An existing legitimate remote is silently discarded. ### Attack Path 1. A user downloads the project or copies its deployment script into a working directory. 2. The directory contains `SKILL.md` and also contains untracked or modified sensitive files, such as environment configuration, credentials, private notes, or unrelated source code. 3. The user runs `deploy.sh`, believing it will publi ...[truncated 972 chars]
Remediation
View remediation
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The declared description is for a runtime/session-management capability: automatically compacting conversation history when message counts exceed a threshold. The provided code does not implement any compaction, summarization, token optimization, message-threshold logic, or conversation processing. Instead, it is a deployment helper script for publishing the project to GitHub. This is a materially different primary purpose and introduces undeclared capabilities involving source control and network publishing.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

整体方向与声明基本一致:代码确实估算 token、在阈值超出时压缩早期消息、保留较新的消息,并参考会话压缩思路实现。但存在实质性描述偏差。最主要的是,声明称会“保留工具调用和关键事实”,而代码的 generateSummary 仅输出工具调用次数,以及通过正则提取的少量词项/数字片段;并没有把具体工具调用记录、参数、结果或系统化事实列表纳入压缩后的上下文。其次,compactSession 内部构造了 compressedMessages 数组,但最终返回时 compressedMessages 字段被设置为 compressedMessages.length,导致调用方拿不到真正的压缩后消息数组,这与描述中的“自动会话压缩”可实际用于上下文替换不完全一致。CLI 测试模式属于附带功能,不足以单独构成主要不匹配,但也未在描述中体现。综合判断为存在描述与行为不一致。

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 122)May include surrounding context.

md
核心算法实现于 `scripts/compact_session.js`:

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script performs Git initialization, remote reconfiguration, and pushes the repository to GitHub even though the skill's declared purpose is local session compaction. This capability is unrelated to runtime compaction behavior and can cause unintended publication of code or sensitive local contents if a user runs it without carefully auditing what will be committed and pushed.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script's core behavior is publishing the repository to GitHub, which is an unjustified side effect for a session-compaction skill and expands the trust boundary from local processing to external network publication. In skill context, that mismatch is especially risky because users may expect token-optimization logic, not source-control and exfiltration-adjacent behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The file’s user-facing description and instructions are consistently presented only in Chinese, which imposes a specific language on users without offering opt-in or alternatives. The policy allows locale constraints only when explicitly justified or when the user is given a choice, neither of which appears here.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script removes and recreates the git remote, renames the branch, commits local changes, and pushes to GitHub without any confirmation checkpoint. This can alter repository state and publish content immediately, increasing the chance of accidental disclosure or destructive repository changes if executed in the wrong directory or with unexpected local files staged by git add -A.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The entire skill document is written in Chinese and does not indicate that language selection is optional or that the skill is region-specific. Under the policy rule, forcing a specific language or locale without opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file’s natural-language comments and all user-facing CLI strings are written only in Chinese, and the generated summary content is also hard-coded in Chinese. This indicates the skill is designed to force a specific language/locale without offering the user any language choice or documenting a justified region-specific constraint.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

compactSession 在返回对象中将 compressedMessages 设为数字计数(压缩后消息数量),但 CLI 代码随后在 L208-L210 用 result.compressedMessages.slice(...) 把它当作消息数组处理。该实现与函数返回值文档“压缩结果”以及字段命名表达的含义直接冲突,说明代码注释/接口意图和实际用法不一致。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script's comments and all user-visible echo messages are written in Chinese, which imposes a specific language on users. There is no indication that the skill is region-specific or that users can opt into another language, creating a natural-language locale policy issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The package description is written only in Chinese and presents the skill as such without any indication that language selection is optional or that the skill is intended exclusively for a Chinese-speaking context. This can conflict with a language/locale policy requiring user choice or explicit documentation of locale constraints.

Content

No source excerpt is available for this finding.