Back to skill

Security audit

Agent Team Orchestration

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent multi-agent setup skill, but its setup script can overwrite or repoint OpenClaw workspace files in risky ways.

Review or patch scripts/setup-team.sh before running it. Use only simple trusted agent IDs, avoid running it against existing important OpenClaw workspaces without backups, and prefer adding validation plus explicit overwrite confirmation for TOOLS.md, OUTPUT, and KNOWLEDGE paths.

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
scripts/setup-team.sh:12
Finding

Unvalidated Agent IDs Allow Path Traversal and Workspace File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/setup-team.sh, lines 12–15 and 34–45
Vulnerability Type: Path traversal, unsafe file overwrite, and instruction-file injection
Risk Level: Medium

Vulnerable Code

bash
WRITER_ID=$1
shift
OTHER_ROLES=("$@")

BASE_DIR="$HOME/.openclaw"
WRITER_WS="$BASE_DIR/workspace-$WRITER_ID"
bash
for role in "${OTHER_ROLES[@]}"; do
  echo "=== Creating shell workspace: $role ==="
  SHELL_WS="$BASE_DIR/workspace-$role"
  
  mkdir -p "$SHELL_WS"
  
  # Create absolute path symlinks
  ln -sf "$WRITER_WS/OUTPUT" "$SHELL_WS/OUTPUT"
  ln -sf "$WRITER_WS/KNOWLEDGE" "$SHELL_WS/KNOWLEDGE"
  
  cat > "$SHELL_WS/TOOLS.md" << EOF
# TOOLS.md - $role

Technical Analysis

The script incorporates the user-supplied writer and role IDs directly into filesystem paths without validating their syntax or confirming that the resolved destinations remain beneath $HOME/.openclaw.

Although the variables are quoted, quoting only prevents shell word splitting and wildcard expansion. It does not prevent path traversal. An ID containing / and .. path components can make WRITER_WS or SHELL_WS resolve outside the intended OpenClaw workspace hierarchy.

The script performs security-sensitive operations at the resulting locations:

  • mkdir -p creates directories.
  • ln -sf replaces OUTPUT and KNOWLEDGE entries with symbolic links.
  • cat > "$SHELL_WS/TOOLS.md" truncates and overwrites a file. If the destination is an existing symbolic link, normal shell redirection can follow it.
  • The role value is embedded in an unquoted here-document, allowing newline-containing IDs to inject attacker-controlled text into the generated Agent instruction file.

Exploitation requires the attacker to control or influence arguments passed to the setup script. The resulting operations remain subject to the invoking user's filesystem permissions.

Attack Path

  1. An attacker convinces a user or automation process to invoke ...[truncated 1453 chars]
Remediation
View remediation

Remediation Suggestions

  1. Apply a strict allowlist to every agent ID before using it:
bash
validate_id() {
  local id=$1

  if [[ ! "$id" =~ ^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$ ]]; then
    printf 'Invalid agent ID: %q\n' "$id" >&2
    exit 1
  fi
}

validate_id "$WRITER_ID"
for role in "${OTHER_ROLES[@]}"; do
  validate_id "$role"
done

This rejects path separators, traversal components, whitespace, control characters, and newline-based instruction injection.

  1. Canonicalize and enforce path containment. Resolve the OpenClaw base directory and each destination, then verify that every destination begins with the canonical base path followed by /. Do not rely only on string concatenation.

  2. Reject unexpected existing files and symbolic links. Before writing TOOLS.md or replacing OUTPUT and KNOWLEDGE, use lstat-equivalent checks such as [[ -L ... ]] and [[ -e ... ]]. Abort unless overwrite behavior was explicitly requested and validated.

  3. Avoid following a pre-existing TOOLS.md symlink. Create a temporary regular file securely within the validated workspace, verify the final destination is not a symlink, and atomically rename the file into place.

  4. Use fixed templates for generated instructions. Do not interpolate untrusted identifiers into instruction content. If an identifier must be displayed, validate it first and render it as inert data.

  5. Use safe, idempotent link handling. Confirm that existing links already point to the expected writer directories; otherwise stop and require explicit user confirmation rather than unconditionally using ln -sf.

  6. Add negative security tests covering IDs containing ../, absolute-path fragments, slashes, backslashes, spaces, shell metacharacters, newline characters, and control characters.

Vulnerability Patterns
  • Rogue AgentSelf-Modification, Session Persistence
  • 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 (6)

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 · references/architecture.md (reported line 9)May include surrounding context.

md
Five design axioms:

1. **File system is the state center** — The writer's `OUTPUT/` is the single source of truth. All other roles read/write through symlinks. No API, no database, no message queue.
2. **AGENTS.md is the role definition** — Each role's responsibilities, standards, and domain knowledge live in its own AGENTS.md. Loaded automatically at spawn. No runtime configuration needed.
3. **Flow is code** — The orchestrator (main agent) is the only dispatcher. Sub-agents cannot spawn each other. Flow is controllable and predictable.
4. **Scoring is the quality gate** — The score threshold (e.g. 8.5/10) is a business bar, not a technical bar. It ensures output is shippable.

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 · references/build-guide.md (reported line 18)May include surrounding context.

  1. Threshold (recommended: 8.0-8.5)
  2. Max fix rounds (recommended: 3)

Phase 2: Create Writer Workspace

bash
mkdir -p ~/.openclaw/workspace-{writer}/OUTPUT

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This markdown workflow directs multiple agents to create, review, score, and modify files in OUTPUT/{project}/, and L95-L98 explicitly says not to bother the human about file operations. Because the skill description omits any warning to the user that it will autonomously read and write project files, the file-handling behavior lacks user disclosure.

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 · scripts/setup-team.sh (reported line 20)May include surrounding context.

sh
WRITER_WS="$BASE_DIR/workspace-$WRITER_ID"

echo "=== Creating writer workspace: $WRITER_ID ==="
mkdir -p "$WRITER_WS/OUTPUT" "$WRITER_WS/KNOWLEDGE"

cat > "$WRITER_WS/TOOLS.md" << 'EOF'
# TOOLS.md - Writer

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code creates directories under ~/.openclaw and then writes a TOOLS.md file via shell redirection. Although the script name suggests setup behavior, there is no explicit warning in comments or user-facing output that it will modify files in the user's home directory before doing so.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script uses ln -sf to forcefully replace OUTPUT and KNOWLEDGE links in each role workspace and writes TOOLS.md without checking whether those paths already exist. In a shared or previously used environment, this can silently repoint collaborators to different data or destroy expected workspace structure, causing integrity issues and accidental data exposure across agent roles.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.