Back to skill

Security audit

Optimize Context

Security checks for vulnerabilities and agentic risk

Overview

The skill is a disclosed context optimizer, but it can automatically rewrite agent memory and active conversation context in unsafe, under-scoped ways.

Review this before installing. Use it only in a test workspace or after disabling automatic cleanup, scheduled runs, and MEMORY.md updates. Do not rely on the supplied manual optimization scripts as-is because they can write sample data as if it were real user memory.

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 (3)

T02 · Agent Memory Poisoning

Error
Location
skills/context-optimizer/optimize.js:215
Finding

Untrusted Conversation Content Is Persisted into Long-Term Agent Memory

Content
View full analysis
{ let match; while ((match = pattern.exec(content)) !== null) { facts.push(match[0].trim()); } }); return facts; } ``` ```js updateMemory(summary) { // Use configured memory file const memoryFile = path.join(this.workspaceDir, this.config.storage.memory_file); let memoryContent = ''; if (fs.existsSync(memoryFile)) { memoryContent = fs.readFileSync(memoryFile, 'utf8'); } // Append new facts to memory const newMemoryContent = summary.factsToRemember .filter(fact => !memoryContent.includes(fact)) .map(fact => `- ${fact}`) .join('\n'); if (newMemoryContent && this.config.summarization.include_facts) { const timestamp = new Date().toISOString(); const updatedContent = memoryContent + `\n\n## Context Optimization - ${timestamp}\n${newMemoryContent}\n`; fs.writeFileSync(memoryFile, updatedContent); console.log(`Updated ${this.config.storage.memory_file} with ${summary.factsToRemember.length} new facts`); } } ``` ### Technical Analysis The optimizer treats text from user and assistant messages as trusted facts. Broad regular expressions extract matching text and pass it directly into `MEMORY.md` without validating its source, semantic meaning, ...[truncated 1861 chars]
Remediation
View remediation

T01 · Skill Instruction Hijacking

Error
Location
skills/context-optimizer/optimize.js:318
Finding

Context Cleanup Removes Original System Instructions and Inserts a Replacement System Message

Content
View full analysis
Remediation
View remediation

T02 · Agent Memory Poisoning

Warning
Location
commands/optimize-context.js:19
Finding

Manual Optimization Commands Persist Fabricated Demonstration Data as User Memory

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (18)

Missing User Warnings

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

Automatic removal of old context with auto-purge enabled can silently discard information that may be necessary for safe, accurate, or compliant task execution. In agent workflows, losing prior instructions, constraints, or safety-relevant facts can cause unsafe actions, incorrect outputs, or failure to preserve required records.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill explicitly advertises automatic context optimization that may clear or alter prior conversation state, but it does not clearly warn users about the risk of losing important instructions, safety constraints, or auditability. In an agent setting, silent context pruning can change model behavior and omit critical prior information, which can lead to unsafe or incorrect task execution.

Content

No source excerpt is available for this finding.

Context Window Stuffing

Medium
Category
Memory Poisoning
Confidence
80% confidence
Finding

The skill describes automatic splitting and sequential processing of tasks that exceed token limits while 'maintaining context', which creates a real risk of context window stuffing or unsafe carryover between subtasks if boundaries are not enforced. Large-task decomposition itself is legitimate, but without safeguards it can propagate untrusted content, duplicate sensitive instructions across steps, or degrade security controls through repeated summarization and re-injection.

Content

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

md
- Prevents "prompt too large" errors

### Task Processor
- Detects large tasks that exceed token limits
- Automatically splits large tasks into smaller subtasks
- Processes subtasks sequentially while maintaining context
- Integrates with context optimization to prevent overflow

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The command claims to optimize the current session context, but it actually operates on hardcoded mock messages instead of real conversation history. This can mislead users and downstream components into believing sensitive context was summarized or preserved when no real optimization occurred, creating integrity and reliability risks around context handling.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This manifest file defines "/large-task" as an alias, but that phrase is generic and could overlap with ordinary user requests about any big task rather than a specific command intent. The manifest does not provide constraints or negative examples to clarify when this alias should or should not activate.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README promotes automatic summarization, cleanup, and memory-file updates without clearly warning that prior conversation context may be removed or that persistent files may be modified. In an agent skill, this can cause silent data loss, integrity issues in MEMORY.md, and operator misunderstanding about destructive behavior.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · skills/context-optimizer/README.md (reported line 10)May include surrounding context.

md
- **Automatic Summarization**: Converts lengthy conversations into 10-20 key bullet points
- **Fact Extraction**: Identifies and preserves important facts and information
- **Memory Management**: Updates your main MEMORY.md with important facts
- **Scheduled Cleanup**: Automatically runs to maintain optimal context size
- **History Tracking**: Keeps track of context optimization activities
- **Configurable Settings**: Uses `task_processing_config.json` for customization
- **Output Optimization**: Prevents overflow and optimizes token usage

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The documented configuration enables auto_purge and removal of old context, but the surrounding documentation does not explain the retention consequences or risk of irreversible context loss. Users may enable the default behavior expecting optimization only, while the skill performs destructive cleanup on conversation history.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill explicitly states it will save summaries to memory and clear old context, but it provides no requirement for explicit user confirmation, backup, or warning about potential loss or mutation of conversation state. In an agent setting, modifying memory files and deleting prior context can cause unintended data loss, preserve incorrect summaries as truth, or remove auditability of earlier instructions and evidence.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Allowing scheduled automatic execution means the skill may alter memory and prune context without a user being present to validate the summary or approve deletion. This increases the risk of unattended state corruption, silent loss of important history, and persistence of inaccurate summaries that could affect later agent behavior.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The trigger phrases are generic and closely match normal user requests about summarizing, cleaning, or maintaining conversation context. Because this skill performs automatic cleanup and summarization, broad activation language increases the chance of unintended invocation, which could delete, condense, or alter conversational state when the user did not explicitly intend to run a destructive maintenance action.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The module header describes the script as summarizing context and cleaning up old messages, which implies reduction or removal of prior context. In addition to summarization, the implementation extracts user/assistant facts and appends them to a persistent MEMORY.md file, creating a lasting memory store rather than merely cleaning up context.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script writes summarized conversation content and extracted facts to persistent files in the workspace without any notice, consent, or retention controls at the point of collection. This can silently retain sensitive user data, credentials, personal preferences, or project details beyond the active session, increasing privacy and data-exposure risk if the workspace is later accessed or exfiltrated.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Appending extracted 'facts' into MEMORY.md creates long-term storage of user-derived statements such as preferences, needs, schedules, or identity details using broad regex extraction. In a context-optimizer skill, this is especially dangerous because users may assume old context is merely trimmed for performance, not promoted into durable memory, leading to covert retention of sensitive information.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The cleanup routine removes prior summary files using fs.unlinkSync based on age. While a console message is printed after deletion, there is no advance warning or confirmation that persisted summaries may be irreversibly deleted during optimization.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

Automatically clearing older messages from active context without explicit warning can remove important safety, consent, or operational history while replacing it with a system-generated summary. If the summary is incomplete or inaccurate, this may distort subsequent agent behavior and can hide the fact that detailed conversation content was discarded from context but retained elsewhere.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

This manifest enables scheduled context optimization every 60 minutes once a message threshold is reached, but it does not define clear boundaries for when optimization should not run or what contexts are excluded. For a manifest file, this is an ambiguous activation condition that could cause unintended invocation of summarization or cleanup behavior.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The configuration turns on automatic task splitting based only on a token threshold, but it does not specify contextual limits, exclusions, or a narrow invocation scope. In a manifest/config file, this makes the trigger overly broad because any sufficiently large task may be split without clearer criteria.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.