Back to skill

Security audit

Agent Failure Loop

Security checks for vulnerabilities and agentic risk

Overview

This skill is transparent about its goal, but it can automatically and repeatedly change persistent agent instruction files using unvalidated failure-log content.

Install only if you are comfortable with a tool that can change future agent instructions. Run promotion in dry-run mode, inspect diffs manually, restrict targets to project-owned instruction files, avoid scheduled auto-promotion, and keep failure logs free of secrets, personal data, proprietary paths, and confidential prompts.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • 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
  • 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)

T02 · Agent Memory Poisoning

Error
Location
scripts/sync-learnings.py:273
Finding

Untrusted failure lessons are promoted into persistent agent instruction files

Content
View full analysis

Vulnerability Details

File Location: scripts/sync-learnings.py:273-286; scripts/auto-promote.py:41-68, 107-118, 158-208, 257-292; SKILL.md:446-455
Vulnerability Type: Persistent agent memory poisoning through unvalidated rule promotion
Risk Level: High

Vulnerable Code

scripts/sync-learnings.py:273-286 converts the lesson from a failure record directly into a proposed rule:

python
# 4. promotable.json — 승격 후보 목록 (auto-promote.py 입력)
promotable_path = learnings_dir / "promotable.json"
promotable = []
for key, pat in analysis["repeated_patterns"].items():
    promotable.append({
        "pattern_key": key,
        "type": pat["type"],
        "count": pat["count"],
        "title": pat["titles"][0],
        "cause": pat["cause"],
        "lesson": pat["lesson"],
        "first_seen": pat["dates"][0],
        "last_seen": pat["dates"][-1],
        "suggested_rule": pat["lesson"],
    })

scripts/auto-promote.py:41-68 interpolates the proposed rule and other record fields without validation or escaping:

python
def format_agents_md_row(item: dict, today: str) -> str:
    """AGENTS.md 자가 개선 규칙 테이블 행 포맷."""
    rule = item["suggested_rule"]
    type_code = item["type"]
    count = item["count"]
    title = item["title"]
    return f"| {today} | {rule} | [{type_code}] {count}회 반복 — {title} |"


def format_claude_md_rule(item: dict) -> str:
    """CLAUDE.md 규칙 포맷 (Claude Code 호환)."""
    return f"- **{item['type']}**: {item['suggested_rule']} (반복 {item['count']}회, 원인: {item['cause']})"


def format_cursorrules(item: dict) -> str:
    """.cursorrules 포맷 (Cursor IDE 호환)."""
    return f"- {item['suggested_rule']}"


def format_plain(item: dict, today: str) -> str:
    """범용 마크다운 규칙."""
    return (
        f"### [{item['type']}] {item['title']}\n"
        f"- **Rule:** {item['suggested_rule']}\n"
        f"- **Count:** {item['count']}회\n"
      
...[truncated 4196 chars]
Remediation
View remediation

Remediation Suggestions

  1. Change automatic promotion into proposal generation. Never modify authoritative agent instruction files without explicit human approval.
  2. Store candidates in a separate review file that agents do not interpret as instructions.
  3. Record provenance for every failure entry, including creator, source session, timestamp, and approval status.
  4. Validate candidate JSON against a strict schema. Enforce expected types, length limits, permitted failure types, and safe character sets.
  5. Apply a security policy to reject proposed rules that request secret access, network communication, command execution, permission changes, disabling safeguards, or changes to higher-priority instructions.
  6. Escape Markdown table delimiters, headings, HTML, links, and multiline instruction content before rendering.
  7. Restrict promotion targets to a canonical allowlist under the intended workspace. Resolve paths and reject absolute paths, parent traversal, symbolic-link escapes, and unexpected file types.
  8. Require atomic writes with backups and produce a reviewable diff before replacement.
  9. Separate candidate authors from approvers where the environment supports multiple identities.
  10. Treat .learnings/promotable.json as untrusted input even when generated locally; verify its integrity and permissions before use.

T06 · System Persistence

Warning
Location
SKILL.md:584
Finding

Scheduled unattended execution persistently mutates agent control files

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:584-602
Vulnerability Type: Scheduled persistent execution of automatic rule promotion
Risk Level: Medium

Vulnerable Configuration

SKILL.md:584-594 documents a daily OpenClaw schedule that runs both analysis and promotion:

yaml
name: daily-reflection
schedule: "0 23 * * *"
message: |
  Time for daily reflection.
  1. Run python3 scripts/sync-learnings.py
  2. Run python3 scripts/auto-promote.py
  3. Summarize today's failure patterns
  4. Report any newly promoted rules

SKILL.md:598-602 provides an operating-system crontab entry:

bash
# Run daily at 23:00
0 23 * * * cd /path/to/workspace && python3 scripts/sync-learnings.py && python3 scripts/auto-promote.py >> /tmp/failure-loop.log 2>&1

Technical Analysis

The scheduled configuration is disclosed, manually installed, and related to the Skill's declared automatic learning functionality. It is not a hidden service or covert backdoor. Nevertheless, scheduling auto-promote.py creates a cross-session persistence mechanism that repeatedly mutates authoritative agent instruction files without requiring an operator to inspect the proposed changes.

Periodic analysis is reasonably connected to the declared functionality, but periodic automatic promotion is not necessary to perform failure classification or generate reports. Combining both operations in one unattended command exceeds a least-privilege design because the scheduled process receives ongoing write authority over agent control files.

The command uses a placeholder workspace path and a relative script path. If an operator substitutes a directory that can be modified by less-trusted users, replacement of the scripts or input files can affect later cron executions. Output is also appended to a predictable shared /tmp/failure-loop.log path rather than a private application log directory.

Attack Path

  1. A use ...[truncated 1529 chars]
Remediation
View remediation

Remediation Suggestions

  1. Schedule only sync-learnings.py or an equivalent proposal-only analysis operation. Do not schedule automatic modification of agent instruction files.
  2. Require an authenticated, explicit approval step before invoking auto-promote.py.
  3. Run the scheduled task under a dedicated least-privileged account with write access only to the analysis output directory.
  4. Use absolute, canonical paths for the Python interpreter, scripts, workspace, input directory, and output directory.
  5. Ensure the script directory and scheduled configuration are not writable by less-trusted users.
  6. Move logs to a private application directory with restrictive permissions rather than a predictable shared /tmp path.
  7. Add file locking so overlapping runs cannot corrupt learning or promotion state.
  8. Verify ownership, permissions, symbolic links, and target paths before every scheduled write.
  9. Document safe removal and disablement procedures for both OpenClaw schedules and operating-system crontab entries.
  10. Make scheduled execution opt-in and clearly warn that automatic promotion modifies persistent agent behavior across sessions.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (16)

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

The declared description presents a full automated pipeline that detects failures, classifies them, tracks repeats, generates rules, and promotes them when repeated three times. The supplied code chunk is materially narrower: it assumes another process has already created .learnings/promotable.json with pattern_key, count, title, cause, and suggested_rule fields. Its primary function is to promote those existing candidates into AGENTS.md/CLAUDE.md/.cursorrules/plain files and log which ones were promoted. The 'three times' threshold is approximately represented by the default min-count of 3, but it is configurable and not hardcoded. Therefore the code does not match the broad declared end-to-end capability; it implements only one downstream subcomponent of that system.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The code accurately covers part of the description: it parses failure records, classifies them, tracks recurrence, and identifies patterns that repeat three or more times. However, the declared purpose overstates the behavior by describing a complete automatic self-improvement loop with rule creation and promotion to AGENTS.md/CLAUDE.md. This script only analyzes and structures failure data into .learnings and emits promotable.json as input for another tool. Its own output message explicitly says to run auto-promote.py separately, confirming promotion is not performed here. Therefore the description does not accurately represent the supplied code chunk.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill describes capabilities that read environment variables, read/write files, and modify persistent rule files, but it does not declare an explicit tool scope such as permissions or allowed-tools. That omission weakens reviewability and can cause an agent runtime to grant broader capabilities than users expect, especially because the skill is designed to persistently change AGENTS.md/CLAUDE.md.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill promotes automatic modification of AGENTS.md/CLAUDE.md and similar user-controlled instruction files without a strong warning or explicit consent gate. Because these files influence future agent behavior, silent mutation creates a persistence and policy-tampering risk: an unsafe or simply incorrect rule can become durable across sessions and workflows.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The pre-task lookup instructs the agent to retrieve and reference prior failure records before starting new work, which can surface sensitive details from unrelated earlier tasks. In multi-project or multi-user environments, this creates cross-task data leakage and may cause confidential information to be reintroduced into a new context without need-to-know.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
75% 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 · SKILL.md (reported line 330)May include surrounding context.

md
- **Type:** RETRY_EXCEEDED
- **Situation:** Repeated 401 error on GitHub API calls
- **Cause:** Retried 5 times with the same token without checking expiration
- **Lesson:** On auth error, immediately verify token validity. No blind retrying
- **Cumulative:** 1st occurrence

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
75% 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 · SKILL.md (reported line 491)May include surrounding context.

md
- **Type:** RETRY_EXCEEDED
- **Situation:** Repeated 401 error on GitHub API calls
- **Cause:** Retried 5 times with the same token without checking expiration
- **Lesson:** On auth error, immediately verify token validity. No blind retrying
- **Cumulative:** 1st occurrence

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
75% 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 · SKILL.md (reported line 501)May include surrounding context.

md
- **Type:** RETRY_EXCEEDED
- **Situation:** Repeated 401 error on GitHub API calls
- **Cause:** Retried 5 times with the same token without checking expiration
- **Lesson:** On auth error, immediately verify token validity. No blind retrying
- **Cumulative:** 1st occurrence

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
75% 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 · SKILL.md (reported line 519)May include surrounding context.

md
- **Type:** RETRY_EXCEEDED
- **Situation:** Repeated 401 error on GitHub API calls
- **Cause:** Retried 5 times with the same token without checking expiration
- **Lesson:** On auth error, immediately verify token validity. No blind retrying
- **Cumulative:** 1st occurrence

Ssd 3

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The mandated failure logging format stores free-form task situations, user corrections, causes, and lessons in persistent markdown files. Those fields can easily capture secrets, proprietary file paths, API details, personal data, or confidential prompts, creating a durable data retention and leakage surface if the workspace is shared, committed, searched, or reused by later tasks.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

Step 1: Install (30 Seconds)

bash
# Copy skill + create directory
cp -r agent-failure-loop/ ~/.agents/skills/agent-failure-loop/
mkdir -p memory/failures

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

weekly-skill-review Integration

Register repeated tasks as skill candidates during weekly review:

yaml
name: weekly-skill-review

Tainted flow: 'new_content' from pathlib.Path.read_text (line 198, file read) → pathlib.Path.write_text (file write)

Medium
Category
Data Flow
Confidence
91% confidence
Finding

The script reads untrusted data from both the target file and .learnings/promotable.json, then writes synthesized content back to an attacker-controlled path without validation, backup, or content sanitization. In this skill’s context, the whole purpose is to auto-promote generated rules into AGENTS.md/CLAUDE.md or any path supplied via CLI/environment, so poisoned learning data or a malicious target path can persistently modify agent instruction files and influence future agent behavior.

Content

Scanner excerpt · scripts/auto-promote.py (reported line 206)May include surrounding context.

python
print(rules_text[:500])
        return True

    target_path.write_text(new_content, encoding="utf-8")
    print(f"[OK] Updated: {target_path}")
    return True

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
72% confidence
Finding

The file consistently presents commands, examples, rule templates, and expected agent interactions in English, including prescribed user-correction phrases such as "No" and "redo." For a cross-platform, any-agent skill, this natural-language guidance effectively assumes one language without documenting opt-in or alternatives.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The documentation instructs users to place a .failure-loop.json file at the project root to manage configuration, but the note at L786 states that current scripts do not support .failure-loop.json and only support environment variables and CLI arguments. This is an active contradiction within the skill documentation about what the current implementation does.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring and user-facing descriptions are written only in Korean, and later user-facing status/help strings in the script follow the same fixed locale. This imposes a specific language/locale without any opt-in or alternative, which matches the natural-language policy violation criterion for forced language choice.

Content

No source excerpt is available for this finding.