Back to skill

Security audit

super-agent-loop

Security checks for vulnerabilities and agentic risk

Overview

This skill is not proven malicious, but it can run commands from task files without enough warning or safeguards.

Install only if you are comfortable treating loop JSON files as executable scripts. Do not run loop definitions from untrusted sources, review every run command first, use a sandbox or low-privilege workspace, and avoid passing sensitive output directories or skill directories to the learner helper.

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
scripts/loop.py:67
Finding

Arbitrary Command Execution Through Untrusted Loop Definitions

Content
View full analysis

Vulnerability Details

File Location: scripts/loop.py, lines 67–79
Vulnerability Type: OS command injection through shell execution
Risk Level: High

Vulnerable Code

python
def execute(step):
    if not step.get("run"):
        # No run field: treat as an external/manual delegation
        return True, "(delegated / no run command)"
    try:
        r = subprocess.run(step["run"], shell=True, capture_output=True,
                           encoding="utf-8", errors="replace", timeout=60)
        out = (r.stdout or "") + (r.stderr or "")
        return (r.returncode == 0), out.strip()
    except Exception as e:
        return False, f"exec-error: {e}"

Technical Analysis

The run value is loaded from a caller-supplied JSON loop definition and passed directly to subprocess.run with shell=True. No command allowlist, argument separation, escaping, approval gate, or execution sandbox is applied.

Consequently, the shell interprets metacharacters and compound expressions in the JSON value, including command separators, pipelines, substitutions, and redirections. The adjacent accept check only examines command output after execution and therefore does not restrict what the command can do. The 60-second timeout limits duration but does not prevent immediate harmful actions or terminate descendant processes reliably in every case.

Attack Path

  1. An attacker supplies or modifies a loop definition consumed by python scripts/loop.py run <loop.json>.

  2. The attacker places an arbitrary shell payload in a step's run property, for example:

    json
    {
      "goal": "process task",
      "steps": [
        {
          "id": "task",
          "desc": "apparently legitimate operation",
          "run": "echo ACCEPTED; attacker_command",
          "accept": "ACCEPTED"
        }
      ]
    }
    
  3. load_loop() deserializes the JSON, and run_loop() for ...[truncated 1173 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove shell=True and represent commands as argument arrays:

    python
    import shlex
    import subprocess
    
    command = step["run"]
    argv = command if isinstance(command, list) else shlex.split(command)
    result = subprocess.run(
        argv,
        shell=False,
        capture_output=True,
        encoding="utf-8",
        errors="replace",
        timeout=60,
        check=False,
    )
    

    Prefer requiring a JSON array rather than parsing a command string, because an explicit array avoids ambiguous quoting.

  2. Treat loop definitions as executable policy, not ordinary data. Only accept definitions from trusted, integrity-protected sources, and require explicit user confirmation before executing each command from externally generated content.

  3. Validate the executable and arguments against a narrow allowlist appropriate to the intended workflow. Reject shell syntax, unexpected executables, dangerous flags, absolute paths where unnecessary, and unapproved environment manipulation.

  4. Execute approved commands in a restricted environment using a dedicated low-privilege account or sandbox. Limit filesystem mounts, network access, environment variables, process creation, and access to credentials.

  5. Use a controlled working directory and a minimal environment rather than inheriting all process state. Add output-size limits and terminate the full process group on timeout.

  6. Keep accept strictly as an output validation mechanism; do not treat it as a security boundary. Add provenance logging for the definition, executable, arguments, working directory, and authorization decision.

  7. If arbitrary shell workflows are an intentional feature, clearly document that loop files are executable and must never be run from untrusted sources.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (18)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

A second behavior mismatch indicates the skill can run arbitrary shell commands while claiming a bounded orchestration role, and that critical safety properties like true ready-node selection, replanning, and stuck-task handling are absent. In context, this makes the skill more dangerous because users may embed it into autonomous pipelines expecting safe gating, but instead expose their environment to command execution without the advertised control mechanisms.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

A second behavior mismatch indicates the skill can run arbitrary shell commands while claiming a bounded orchestration role, and that critical safety properties like true ready-node selection, replanning, and stuck-task handling are absent. In context, this makes the skill more dangerous because users may embed it into autonomous pipelines expecting safe gating, but instead expose their environment to command execution without the advertised control mechanisms.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The orchestrator is effectively a general-purpose command runner because loop definitions can specify arbitrary run strings that are executed directly. In the context of an agent skill, this materially expands capability beyond passive orchestration and makes the skill dangerous if fed malicious or user-supplied loop.json content.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

This is a classic tool-parameter abuse pattern: the program forwards attacker- or user-controlled input directly into subprocess.run with shell=True. In an autonomous loop engine, that means a crafted loop.json can execute destructive commands, exfiltrate local data, or install persistence, making the surrounding skill context especially risky.

Content

Scanner excerpt · scripts/loop.py (reported line 71)May include surrounding context.

python
return True, "(delegated / no run command)"
    try:
        # 用 utf-8 + errors=replace 防御 Windows 控制台非 UTF-8 代码页导致的崩溃
        r = subprocess.run(step["run"], shell=True, capture_output=True,
                           encoding="utf-8", errors="replace", timeout=60)
        out = (r.stdout or "") + (r.stderr or "")
        return (r.returncode == 0), out.strip()

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill advertises executable usage via python scripts/super_agent.py and the findings indicate shell and file-write capabilities, but it declares no permissions or allowed-tools scope. That creates an undeclared execution surface where a caller may grant broader access than intended, increasing the risk of arbitrary command execution or unintended filesystem modification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The natural-language content in the description and body of the skill is exclusively Chinese, including the usage guidance and operational notes. Under the stated policy, forcing a specific language without user 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
96% confidence
Finding

This code file contains natural-language documentation and CLI messages entirely in Chinese, establishing a fixed language experience for users. The policy explicitly flags language or locale constraints when the skill forces a specific language without user opt-in, and no alternative language selection or justification is provided here.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest describes a closed-loop orchestrator focused on planning, execution, self-verification, reflection, and memory within the super-agent flow. This file instead implements a generic cross-skill CLI utility that initializes and writes learned_patterns.json, records user preferences, and advises updating another file (SKILL.md) for any provided skill directory, which is a broader maintenance/telemetry function than the orchestrator description claims.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The code accepts an arbitrary path or skill name, resolves it, and then later writes learned_patterns.json to that location without validating that the target stays within an approved skills root. In an agent context, this broad write capability can be abused to modify unintended directories or files reachable through symlinks, making the generic learner more powerful than necessary for its stated orchestration role.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The docstring, usage text, and user-facing status messages are written in Chinese throughout the file, which imposes a specific language on users without opt-in. This matches the policy category for language or locale constraints that are forced rather than offered as a choice.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The module documentation says '失败步骤回到 pending 重试(最多 max_iter 轮)', implying automatic replanning/retry behavior. However, in the main loop failed steps are set to failed and subsequent iterations only process pending steps, so no retry actually occurs.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
98% confidence
Finding

The code executes step["run"] via subprocess.run(..., shell=True), so any content in the loop definition is treated as a shell command. If the loop definition is attacker-controlled or untrusted, this enables arbitrary command execution on the host with the privileges of the process.

Content

Scanner excerpt · scripts/loop.py (reported line 71)May include surrounding context.

python
return True, "(delegated / no run command)"
    try:
        # 用 utf-8 + errors=replace 防御 Windows 控制台非 UTF-8 代码页导致的崩溃
        r = subprocess.run(step["run"], shell=True, capture_output=True,
                           encoding="utf-8", errors="replace", timeout=60)
        out = (r.stdout or "") + (r.stderr or "")
        return (r.returncode == 0), out.strip()

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill executes shell commands from the loop definition without any user-facing warning, consent gate, or confirmation step. That increases the likelihood of unsafe execution of hidden or surprising commands, especially in an agent context where users may assume higher-level orchestration rather than raw command execution.

Content

No source excerpt is available for this finding.

Tainted flow: 'mem' from open (line 245, file read) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/loop.py (reported line 123)May include surrounding context.

python
except Exception:
            data = []
    data.append(episode)
    json.dump(data, open(mem, "w", encoding="utf-8"), ensure_ascii=False, indent=2)
    return mem

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The module advertises a robust closed-loop orchestrator but actually executes pre-supplied Python callables from in-memory step objects, while the JSON graph interface cannot safely represent those callables. This discrepancy can cause integrators to assume the component enforces planning, validation, and safe graph execution when it does not, leading to unsafe use of untrusted task definitions or insecure wrapper code that reconstructs executable actions dynamically.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code file's primary natural-language documentation is entirely in Chinese and presents the skill as operating in that language, with no indication that users may opt into another language or locale. The policy requires flagging language or locale constraints when a specific language is imposed without user choice or documented justification.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The docstring describes a reflection phase that detects failures or deadlocks, diagnoses root causes, and suggests retries or bypasses. In code, report() merely returns failed or blocked as root_cause plus a fixed advice string, and run() has no distinct stall/deadlock analysis beyond marking leftover nodes as blocked.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The skill persists memory.json containing episode context and step results, and later writes summary.json, which affects user data on disk. The code creates these files automatically when out_dir is set, but does not provide a direct user-facing notice at write time about what data is being stored.

Content

No source excerpt is available for this finding.