Back to skill

Security audit

Context Cleaner

Security checks for vulnerabilities and agentic risk

Overview

The skill is openly about cleanup, but it asks agents to automatically and persistently alter sessions and terminate sub-agents with too little user control.

Install only if you are comfortable giving the skill authority to manage session history and sub-agents. Prefer using it in dry-run or archive-only mode, avoid enabling cron or heartbeat automation until you have clear retention rules, and require explicit confirmation before deletion, context replacement, or sub-agent termination.

Vulnerability Patterns
  • System PersistenceInstalls backdoors, hooks, services, or scheduled tasks that survive the run
  • 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
Findings (1)

T06 · System Persistence

Error
Location
SKILL.md:15
Finding

Persistent Autonomous Cleanup Enables Destructive Cross-Session Operations

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 15–16, 21–32, 46–62, and 91–109
Vulnerability Type: Persistent scheduled execution and excessive session-management authority
Risk Level: High

Vulnerable Code

markdown
| Sub-agent idle > 30min | Terminate automatically |
| Old sessions (> 7 days) | Archive or delete |
markdown
No special setup required. The skill automatically:

1. **Monitors session sizes** - Checks if current session context is growing too large
2. **Terminates idle sub-agents** - Stops sub-agents that haven't been used recently
3. **Archives old sessions** - Moves completed sessions to archive
4. **Compresses context** - Replaces verbose message chains with summaries

## Usage

### Automatic Operation

The skill runs automatically during heartbeat checks when context size exceeds thresholds.
markdown
Use `sessions_list` and `subagents` tools internally. The skill orchestrates:

1. List all sessions
2. Check sub-agent status
3. Terminate idle sub-agents
4. Compress large contexts
5. Archive old sessions
markdown
3. **Replace verbose content** - Keep only essential information
markdown
### Heartbeat Integration

Add to `HEARTBEAT.md`:

```markdown
## 上下文管理
- [ ] 检查会话大小
- [ ] 清理过期子代理
- [ ] 压缩过大上下文

Cron Integration

Schedule regular cleanup:

bash
# Weekly full cleanup
cron add -name "weekly-context-clean" -schedule "0 3 * * 0" -payload "Compress contexts and clean expired sessions"
text

### Technical Analysis

The Skill instructs an agent to establish recurring execution through heartbeat configuration and a weekly cron task. These mechanisms survive the individual Skill invocation and repeatedly trigger cleanup behavior in later sessions, matching system persistence.

The persistent process is granted authority to enumerate all sessions, terminate sub-agents, rewrite co
...[truncated 2707 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the heartbeat and cron installation instructions. Cleanup should run only after an explicit, current user request.
  2. Default to a read-only audit that lists cleanup candidates and explains why each candidate was selected.
  3. Require separate, explicit confirmation before every session deletion, context replacement, archive operation, or sub-agent termination.
  4. Restrict management operations to the current session unless the user explicitly identifies other sessions by stable identifier.
  5. Do not infer authorization from age or inactivity alone. Verify task completion, pending work, ownership, locks, and active processes.
  6. Preserve original context. Store summaries as additional metadata rather than replacing source messages.
  7. Prefer reversible archival over deletion and create a verified backup before any mutation.
  8. Provide dry-run, restoration, retention, and rollback mechanisms.
  9. Enforce least-privilege tool access so the Skill cannot modify scheduler or heartbeat configuration by default.
  10. Record an audit log containing the initiating user, authorization decision, affected resource, action, timestamp, and restoration location.
  11. Correct the statement that no special permissions are needed and document every required capability.
  12. If scheduled maintenance is genuinely necessary, require an administrator-approved policy with narrowly scoped targets, non-destructive defaults, and per-run reporting.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill advertises automatic archiving or deletion of old sessions without a prominent upfront warning that user data may be modified, moved, or removed. Because the skill also runs automatically during heartbeat checks, users may not realize that historical sessions or temporary work can be altered without an explicit, informed approval at the time of action.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manual trigger phrases are generic enough to be invoked during ordinary conversation, which can cause unintended cleanup actions such as context compression or session removal. In a skill that performs state-changing operations automatically, ambiguous natural-language triggers increase the risk of accidental activation and loss of useful context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The sample HEARTBEAT.md block is written entirely in Chinese, but the rest of the skill is in English and no language preference, opt-in, or regional rationale is provided. This creates a natural-language locale policy issue because the skill implicitly directs users to adopt a specific language for integration content.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.