Back to skill

Security audit

AICP Protocol

Security checks for vulnerabilities and agentic risk

Overview

This skill is a small AICP serialization/parsing utility with a real protocol-integrity weakness, but it does not install persistence, access secrets, transmit data, or execute agent actions by itself.

Reasonable to install for experimentation or trusted local use. Do not use it as an authenticated or security-sensitive agent-control protocol until it validates or encodes fields, rejects structural delimiters, and has adversarial parsing tests; downstream agents should not treat parsed operations as trusted authority without separate authorization.

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

Warning
Location
protocol.py:19
Finding

AICP Wire-Format Injection Through Unescaped Input

Content
View full analysis

Vulnerability Details

File Location: protocol.py, lines 19–28 and 41–49; exposed to CLI-controlled input through openclaw_aicp.py, lines 127–148
Vulnerability Type: AICP protocol structural injection
Risk Level: Medium

Vulnerable Code

python
def to_wire(self, glossary: Dict[str, str]) -> str:
    """Convert to compact wire format."""
    parts = [f"op:{self.op}", f"ref:{self.ref}"]
    for key, val in self.fields.items():
        # Use glossary abbreviation if exists
        for abbr, full in glossary.items():
            if val == full:
                val = abbr
                break
        parts.append(f"{key}={val}")
    return " ".join(parts)
python
def to_wire(self) -> str:
    """Serialize to wire format."""
    lines = [f"VER:{self.version}", f"SID:{self.session_id}"]
    if self.glossary:
        gloss_str = " ".join(f"{k}={v}" for k, v in self.glossary.items())
        lines.append(f"GLOSS: {gloss_str}")
    for msg in self.messages:
        lines.append("MSG:")
        lines.append(f"{msg.to_wire(self.glossary)}")
    return "\n".join(lines)

The CLI passes user-controlled values into this serializer:

python
p_spawn.add_argument("--task", required=True, help="Task description")
p_spawn.add_argument("--type", default="general", help="Task type (image/code/data/llm/aicp)")
p_spawn.add_argument("--priority", default="normal", help="Priority (CRIT/WARN/INFO)")

# ...

result = aicp.spawn_subagent(
    task_type=args.type,
    params={"task": args.task, "pri": args.priority.upper()[:4]}
)

Technical Analysis

The serializer directly interpolates operation names, references, field keys and values, glossary entries, versions, and session identifiers into a whitespace- and newline-delimited protocol. It performs no escaping, encoding, or grammar validation.

An attacker-controlled value can consequently include delimiters such as line breaks, spaces, :, and =. In particular, a newline followed by struc ...[truncated 2043 chars]

Remediation
View remediation

Remediation Suggestions

  1. Define a strict, documented grammar for every protocol component, including operation names, references, field names, field values, session identifiers, versions, and glossary aliases.
  2. Validate operation names against an explicit allowlist such as upd, create, del, qry, ack, and notify.
  3. Reject carriage returns and line feeds in all scalar values unless the protocol introduces an unambiguous encoding for them.
  4. Restrict identifiers and field names to a conservative character set and maximum length, for example an anchored ASCII alphanumeric pattern with explicitly permitted punctuation.
  5. Encode arbitrary field values using a robust representation such as JSON string escaping, percent encoding, Base64 with explicit markers, or length-prefixed fields. Apply matching decoding in parse_wire().
  6. Do not rely on whitespace splitting for arbitrary values. Use a real tokenizer or a serialization format capable of preserving spaces and delimiters.
  7. Make parsing fail closed: reject malformed records, unknown operations, invalid keys, unexpected structural lines, duplicate headers, and incomplete messages rather than accepting partial data.
  8. Apply resource limits to input size, number of lines, glossary entries, messages, and field lengths.
  9. Add adversarial round-trip tests covering spaces, tabs, carriage returns, newlines, colons, equals signs, duplicate headers, forged MSG: blocks, and malformed message bodies.
  10. Validate input both at CLI boundaries and inside the serializer so direct library callers receive the same protection.
Vulnerability Patterns
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • 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 (2)

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The module docstring and CLI usage describe operational subagent actions such as spawn, status, and complete, implying real subagent communication. In the implementation, the methods only create AgentCommunicator objects, build payload strings, store them in memory, and return or print those payloads; no transport or dispatch occurs in this file.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The docstring explicitly states 'Returns the wire payload that would be sent to subagent.' However, the function returns a structured dict containing session_id, wire_payload, token counts, and savings_percent, which contradicts the documented return behavior.

Content

No source excerpt is available for this finding.