Back to skill

Security audit

Self Improving Agent

Security checks for vulnerabilities and agentic risk

Overview

This skill is review-worthy because it persistently learns from sessions and errors, exports those records, and automatically loads executable Python hooks without enough safeguards.

Install only in a trusted workspace. Keep auto_learn and auto_apply disabled until you have reviewed what gets stored, restrict who can write to the hooks directory, inspect learning JSON files before reuse, and do not export or email learnings unless you have redacted secrets, private prompts, tracebacks, and business data.

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

T09 · Insecure Skill Coding Practices

Error
Location
src/hooks.py:39
Finding

Arbitrary Code Execution Through Untrusted Workspace Hooks

Content
View full analysis

Vulnerability Details

File Location: src/hooks.py, lines 39-56 and 66-73
Vulnerability Type: Untrusted dynamic Python module loading
Risk Level: High

Vulnerable Code

python
def _load_hooks(self) -> List[Any]:
    """Load all hooks from the hooks directory."""
    hooks = []

    for hook_file in self.hooks_path.glob('*.py'):
        hook = self._load_hook(hook_file)
        if hook:
            hooks.append(hook)

    return hooks

def _load_hook(self, hook_file: Path):
    """Load a single hook from file."""
    try:
        spec = importlib.util.spec_from_file_location(
            hook_file.stem,
            hook_file
        )

        if spec and spec.loader:
            module = importlib.util.module_from_spec(spec)
            spec.loader.exec_module(module)

            if hasattr(module, 'apply'):
                return module

        return None
    except Exception as e:
        print(f"⚠️  Failed to load hook {hook_file}: {e}")
        return None

def _apply_hook(self, hook):
    """Apply a single hook."""
    try:
        hook.apply()
    except Exception as e:
        print(f"⚠️  Hook failed: {e}")
        # Trigger error hook
        self.trigger_error(e)

Technical Analysis

HookManager scans every *.py file in the configured workspace hook directory and loads each file as an executable Python module. There is no hook allowlist, integrity validation, signature verification, ownership or permission check, or explicit approval step.

Calling spec.loader.exec_module(module) executes all module-level statements immediately. Consequently, the later hasattr(module, 'apply') check is not a security boundary: malicious code has already executed before that check occurs. A qualifying module's apply() function can subsequently execute additional attacker-controlled code.

The configured workspace can be supplied through the CLI's --workspace option. The issue is exploitable whenever an attacker can create or ...[truncated 1701 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace directory-wide discovery with an explicit allowlist of trusted hook identifiers and paths.
  2. Keep executable hooks in an application-owned directory that is not writable by untrusted users or workspace content.
  3. Resolve each hook path and verify that it remains beneath the trusted hook root before loading it.
  4. Verify file ownership and reject group- or world-writable hook files and parent directories where supported.
  5. Pin and verify approved hook contents using cryptographic hashes or signed manifests.
  6. Require explicit administrator or user approval before enabling a newly discovered or modified hook.
  7. Do not treat the presence of an apply() function as validation because module import has already executed top-level code.
  8. Prefer a declarative, schema-validated hook format over executable Python when hooks only need to describe learning behavior.
  9. If third-party executable hooks are necessary, execute them in a restricted subprocess or sandbox with minimal filesystem, environment, and network access.
  10. Add tests confirming that unapproved hooks, path escapes, symlink escapes, and files with unsafe ownership or permissions are rejected.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
Findings (42)

YARA rule 'agent_skill_mcp_tool_poisoning_metadata': MCP/tool metadata poisoning indicators in tool schemas or skill manifests [agent_skills]

High
Category
YARA Match
Confidence
80% confidence
Finding

YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Content

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

md
---
name: self-improving-agent
description: Self-improving agent system for OpenClaw. Enables continuous learning from interactions, errors, and recoveries. Automatically improves performance over time.
---

# Self-Improving Agent

A continuous learning agent system for OpenClaw that learns from:
- ✅ **Interactions** - Learn from every conversation
- ✅ **Errors** - Learn from mistakes to avoid them
- ✅ **Recoveries** - Learn what works to recover successfully

---

## ✨ Features

- 🧠 **Continuous Learning** - Learns from every interaction
- ❌ **Error Learning** - Learns from mistakes to avoid repetition
- ✅ *

Ssd 3

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The team-sharing example explicitly recommends emailing exported learnings, which operationalizes disclosure of memory contents outside the system boundary. Since these learnings are derived from prior user interactions and may contain secrets or private information, suggesting broad sharing via email materially increases the likelihood of accidental exfiltration.

Content

No source excerpt is available for this finding.

Ssd 3

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The learning pipeline directs the system to mine session logs and store extracted content without any restriction on sensitive data classes. That makes it likely that secrets, private conversations, or confidential workspace data could be summarized into the memory store and later re-surfaced through review, export, or auto-application.

Content

No source excerpt is available for this finding.

Context Leakage

High
Category
Data Exfiltration
Confidence
98% confidence
Finding

The _extract_context method returns traceback.format_exc(), which can capture full stack traces and surrounding error context, potentially exposing secrets, filesystem layout, internal prompts, API keys embedded in exceptions, and user data. Because this skill is designed for continuous learning from failures, the leakage risk is amplified: the system will repeatedly collect and persist rich diagnostic context whenever errors occur.

Content

Scanner excerpt · hooks/error_learning.py (reported line 66)May include surrounding context.

python
print(f"✅ Saved recovery learning")
    
    def _extract_context(self, error):
        """Extract context from error."""
        import traceback
        return {
            'traceback': traceback.format_exc()

Context Leakage

High
Category
Data Exfiltration
Confidence
88% confidence
Finding

The context extraction logic copies timestamp, operation, and duration from incoming metrics into a persistent file, and the broader metric object may originate from agent activity that reflects user prompts, task names, or operational metadata. In a self-improving agent, this increases risk because longitudinal storage of execution context can reveal sensitive workflows, user behavior, or internal system details even if the code does not explicitly label them as secrets.

Content

Scanner excerpt · hooks/performance_learning.py (reported line 55)May include surrounding context.

python
return metric if isinstance(metric, (int, float)) else 0
    
    def _extract_context(self, metric):
        """Extract context from metric object."""
        if isinstance(metric, dict):
            return {
                'timestamp': metric.get('timestamp'),

Context Leakage

High
Category
Data Exfiltration
Confidence
88% confidence
Finding

This call causes session-derived information to be recorded persistently, creating a context leakage path from in-memory session state to disk. In a self-improving agent, the danger is elevated because future enhancements to pattern extraction are explicitly anticipated, increasing the likelihood that prompts, outputs, errors, or other sensitive context will later be captured without adequate controls.

Content

Scanner excerpt · hooks/session_learning.py (reported line 37)May include surrounding context.

python
'success_patterns': self._extract_success_patterns(session)
        }
        
        # Log the session
        self._log_session(session_data)
        
        print(f"✅ Saved session learning")

Context Leakage

High
Category
Data Exfiltration
Confidence
93% confidence
Finding

The logging function appends each session record to a cumulative JSON store with no filtering, classification, or retention controls. This creates a durable repository of session metadata that could be exposed through local compromise, backup leakage, multi-tenant workspace access, or later code changes that add more sensitive fields.

Content

Scanner excerpt · hooks/session_learning.py (reported line 72)May include surrounding context.

python
return patterns
    
    def _log_session(self, session_data):
        """Log session to file."""
        sessions = self._load_sessions()
        sessions.append(session_data)
        self._save_sessions(sessions)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The code imports and executes every Python file found in a workspace-controlled hooks directory via importlib and then calls exported hook functions. This creates arbitrary code execution from local content with no trust boundary, signing, allowlist, sandboxing, or user confirmation, which is especially dangerous because the workspace may be writable by other components or influenced by untrusted data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The README advertises '自动改进' and automatic application of improvements without warning that the agent may change its own behavior or persist learned data. In a self-improving agent context, undocumented automatic behavior changes can lead users to run a tool that mutates future execution patterns or stored state without informed consent, increasing the risk of unsafe or unexpected actions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The sample configuration sets AUTO_APPLY=true without any adjacent warning, normalizing unattended modification of agent behavior as the default documented setup. For a system designed to learn from interactions and errors, this makes the skill more dangerous because users may unknowingly enable self-modifying behavior in their workspace from the outset.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The README states that learning is enabled by default and that the system automatically learns from sessions, errors, recoveries, and performance events, but it does not clearly warn users that potentially sensitive conversational, operational, or traceback data may be collected and persisted. In a self-improving agent skill, this is more dangerous because the feature is core behavior and likely to run continuously, increasing the chance that secrets, personal data, or internal system details are stored without informed consent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The export command is documented as writing all learnings to a markdown file, but the README does not warn that those learnings may include sensitive session details, error messages, tracebacks, recovery history, or performance context. Exporting into a broadly readable format increases disclosure risk because users may share, commit, or upload the file without realizing it contains accumulated sensitive data.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill describes persistent learning artifacts and hook-based behavior that semantically requires reading and writing local files, but it does not declare any explicit tool scope or permission boundaries. In an agent environment, undeclared file access increases the chance of overbroad execution, unclear operator consent, and misuse of workspace or host data beyond what users expect.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill advertises automatic learning by default and implies storing information derived from user interactions, but it provides no privacy warning, consent flow, retention limit, or sensitivity exclusions. This creates a realistic risk that conversations, prompts, secrets, or personal data will be captured and persisted without the user's informed awareness.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Learning from every conversation semantically implies broad retention of user-provided content and inferred preferences, with no stated minimization boundaries. In this context, the danger is not just storage but long-term accumulation of sensitive personal, business, or security-relevant information that can later influence behavior or be exposed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

Automatic post-session, error, and recovery learning implies processing of logs, stack traces, and interaction history, all of which commonly contain credentials, tokens, file paths, user content, or internal system details. Without warnings and safeguards, the feature can silently convert transient sensitive data into retained artifacts that are easier to leak or misuse.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The documented learning files explicitly store error messages, tracebacks, and recovery/session data, but there is no warning that these files may contain sensitive conversational, operational, or diagnostic content. Persisting such material in plain project files raises the risk of accidental disclosure through backups, source control, file sharing, or later agent access.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill explicitly says it learns from conversation patterns and user preferences and stores the results in a session file, which creates a clear semantic data-retention risk. User preferences and conversation-derived patterns can reveal sensitive habits, identity attributes, proprietary workflows, or hidden instructions, making the stored file a high-value target even if raw transcripts are not saved.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The guide promotes continuous learning from every interaction and storage of session-derived data, but it does not warn users that prompts, outputs, and possibly sensitive user content may be retained and reprocessed. In a self-improving agent context, silent collection and retention increases privacy risk and can lead to unintended persistence of secrets, personal data, or internal business information.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The documentation describes automatically applying learned improvements and hooks without requiring human review or warning that behavior may change between runs. For an agent system, this can cause unvetted changes to decision-making, tool usage, or data handling, creating a path for prompt-derived or poisoned learnings to alter runtime behavior unexpectedly.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The guide instructs the agent to analyze session logs, extract learnings, and store them in structured files, but it provides no minimization, redaction, or sensitivity filtering guidance. Because learnings are derived from prior interactions, this can capture and persist user-provided secrets, regulated data, or proprietary content in a reusable memory store.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The export workflow encourages packaging accumulated learnings into markdown or JSON files for sharing, without warning that those files may contain sensitive information derived from past sessions. Export transforms retained interaction-derived memory into an easily transferable artifact, increasing disclosure risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The documentation promotes continuous learning and automatic application of improvements without clearly warning users that interaction-derived data will be stored and that future agent behavior may be modified automatically. In a self-modifying agent context, that omission can lead to silent retention of sensitive data and unreviewed behavior changes that users did not meaningfully consent to.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The guide frames learning from every interaction and sharing learnings as a normal feature, which creates a natural-language pathway for persistent retention and later disclosure of user-provided content. In an agent skill, this is dangerous because users may not expect prompts, errors, and behavioral traces to be converted into durable artifacts that can influence future runs or be shared onward.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

The feature set explicitly emphasizes shareable persistent learnings, indicating deliberate session persistence across runs. In this skill context, persistence is more dangerous because the stored material is derived from interactive sessions and is intended to influence future behavior, increasing both confidentiality and integrity risks.

Content

Scanner excerpt · USAGE.md (reported line 44)May include surrounding context.

md
- ✅ **Get Smarter Over Time** - Improves with every use
- ✅ **No Manual Configuration** - Fully automated
- ✅ **Transparent** - All learnings are visible and reviewable
- ✅ **Customizable** - Create custom hooks and categories
- ✅ **Shareable** - Export and share learnings with team

---

Static analysis

No suspicious patterns detected.