Back to skill

Security audit

Agent Forge

Security checks for vulnerabilities and agentic risk

Overview

This skill has a coherent agent-creation purpose, but it also makes persistent, broad OpenClaw configuration changes and ships unsafe helper scripts that can affect more than the intended agent.

Review before installing. Use only with trusted users and agent names, require a visible change plan before deployment, avoid sessions.visibility all unless truly needed, and do not run remove-agent.sh with untrusted or unusual agent IDs until validation is added.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/remove-agent.sh:32
Finding
Destructive Path Traversal in Agent Removal<![CDATA[ ## Vulnerability Details **File Location**: `scripts/remove-agent.sh`, lines 32–43 and 67–83 **Vulnerability Type**: Path traversal leading to arbitrary recursive deletion **Risk Level**: High ### Vulnerable Code ```bash AGENT_ID="${1:-}" FORCE_FLAG="" if [ "$2" = "--force" ]; then FORCE_FLAG="--force" fi if [ -z "$AGENT_ID" ]; then echo -e "${RED}Error: Missing agent-id${NC}" exit 1 fi OPENCLAW_HOME="${OPENCLAW_HOME:-$HOME/.openclaw}" AGENTS_DIR="$OPENCLAW_HOME/agents" WORKSPACE_DIR="$OPENCLAW_HOME/workspace" AGENT_WORKSPACE="$WORKSPACE_DIR/workspace-$AGENT_ID" ``` ```bash # Step 2: Remove agent directory echo -e "${BLUE}2. Removing agent directory...${NC}" if [ -d "$AGENTS_DIR/$AGENT_ID" ]; then rm -rf "$AGENTS_DIR/$AGENT_ID" echo " Removed: $AGENTS_DIR/$AGENT_ID" fi # Step 3: Remove workspace directory echo -e "${BLUE}3. Removing workspace...${NC}" if [ -d "$AGENT_WORKSPACE" ]; then rm -rf "$AGENT_WORKSPACE" echo " Removed: $AGENT_WORKSPACE" fi ``` ### Technical Analysis `AGENT_ID` is validated only for being nonempty. It is then appended directly to filesystem paths passed to `rm -rf`. Shell quoting prevents word splitting and glob expansion, but it does not prevent path traversal through components such as `../`. The `-d` checks do not provide a security boundary. If a traversal-derived path resolves to an existing directory, the check succeeds and the directory is recursively deleted. The optional `--force` argument removes the interactive confirmation barrier. ### Attack Path 1. An attacker, malicious prompt, or compromised agent causes the removal script to be invoked with an identifier containing traversal components. 2. The script constructs deletion targets such as: ```text $OPENCLAW_HOME/agents/../../../target ``` 3. Filesystem path resolution moves outside the intended `agents` directory. 4. The `-d` check succeeds if the resolved target exists. 5. `rm -rf` recursively deletes the resolved ...[truncated 795 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Enforce a strict agent identifier format before constructing paths: ```bash if [[ ! "$AGENT_ID" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]]; then echo "Invalid agent ID" >&2 exit 1 fi ``` 2. Canonicalize both the allowed root and deletion target using `realpath`. 3. Verify that each canonical target is a strict descendant of its expected root before deletion. 4. Explicitly reject empty targets, root directories, `.` and `..` components, path separators, and symlink-based escapes. 5. Refuse to remove symlink targets unless symlink behavior is deliberately supported and securely implemented. 6. Avoid allowing automated agents to use `--force`; require explicit user approval for destructive operations. 7. Display the canonical deletion paths during confirmation. 8. Add tests covering traversal identifiers, absolute-looking inputs, symlinks, empty values, and valid hyphenated identifiers. ]]>

T02 · Agent Memory Poisoning

Error
Location
scripts/deploy-agent.sh:21
Finding
Persistent Agent Instruction and Configuration Injection<![CDATA[ ## Vulnerability Details **File Location**: `scripts/deploy-agent.sh`, lines 21–27, 68–94, 106–114, and 130–141 **Vulnerability Type**: Unsanitized input persisted into agent instructions, registry data, paths, and JSON **Risk Level**: High ### Vulnerable Code ```bash AGENT_ID="${1:-}" MODEL="${2:-minimax-portal/MiniMax-M2.5}" ROLE="${3:-}" TOOLS="${4:-read,write}" CHANNELS="${5:-telegram}" SANDBOX="${6:-all}" PERSONALITY="${7:-Efficient Machine}" ``` ```bash cat > "$AGENT_WORKSPACE/HEARTBEAT.md" << EOF # HEARTBEAT.md - ${AGENT_ID} ## Patrol Interval: 30 minutes ## Focus - Execute ${ROLE} tasks - Report blockers to Main Agent immediately - Log revenue events to MEMORY.md ## Status Last check: Never EOF cat > "$AGENT_WORKSPACE/MEMORY.md" << EOF # MEMORY.md - ${AGENT_ID} _Last updated: $(date +%Y-%m-%d)_ ## Role ${ROLE} ## Key Decisions _(populated during operation)_ ## Revenue Events _(populated during operation)_ EOF cat > "$AGENT_WORKSPACE/TOOLS.md" << EOF # TOOLS.md - ${AGENT_ID} ## Enabled Tools ${TOOLS} ## Sandbox Level ${SANDBOX} ## Revenue Notes _(track what tools drive ROI here)_ EOF ``` ```bash AGENT_ENTRY="### ${AGENT_ID} - **ID:** ${AGENT_ID} - **Model:** ${MODEL} - **Role:** ${ROLE} - **Channels:** ${CHANNELS} - **Tools:** ${TOOLS} - **Sandbox:** ${SANDBOX} - **Workspace:** ${AGENT_WORKSPACE}/ " echo "$AGENT_ENTRY" >> "$MAIN_AGENTS_FILE" ``` ```bash cat > "$AGENTS_DIR/$AGENT_ID/agent/config.json" << EOF { "agent_id": "${AGENT_ID}", "model": "${MODEL}", "role": "${ROLE}", "tools": "${TOOLS}", "channels": "${CHANNELS}", "sandbox": "${SANDBOX}", "personality": "${PERSONALITY}", "workspace": "${AGENT_WORKSPACE}", "created_at": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" } EOF ``` ### Technical Analysis Interview-derived values are inserted without structural validation or context-appropriate escaping into: - Persistent agent instruction files. - The main agent’s `AGENTS.md` registry. - Agent filesystem paths. - A JS ...[truncated 2243 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate `AGENT_ID` using a strict allowlist such as: ```text ^[a-z0-9]+(-[a-z0-9]+)*$ ``` 2. Apply explicit length limits and reject path separators, traversal components, control characters, and unexpected newlines in every field. 3. Generate JSON with a proper serializer such as `jq`, Python’s `json` module, or an equivalent typed configuration API. 4. Treat interview responses as untrusted data rather than executable agent instructions. 5. Store user-provided values in clearly delimited data sections and ensure startup instructions explicitly state that quoted interview data is not authoritative policy. 6. Escape Markdown metacharacters or encode structured values before inserting them into instruction files. 7. Separate immutable system-authored instructions from user-controlled descriptive metadata. 8. Canonicalize all generated paths and verify that they remain beneath the intended OpenClaw roots. 9. Show the user a complete diff of persistent files and configuration changes before writing them. 10. Validate generated Markdown and parse the generated JSON before deployment is considered successful. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:155
Finding
Global Cross-Agent Session Visibility Exceeds Least Privilege<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 155–179 and 218 **Vulnerability Type**: Excessive cross-agent access configuration **Risk Level**: Medium ### Vulnerable Code ```markdown ### Step 10: Gateway Config 自动更新 文件写入完成后,立即调用 `gateway config.patch` 更新: 1. **`agents.list[main].subagents.allowAgents`** — 追加新 agent ID 2. **`tools.agentToAgent.allow`** — 追加新 agent ID 3. **`tools.sessions.visibility`** — 确保为 `"all"` 示例 patch(以 `new-agent` 为例): ```json { "agents": { "list": [ { "id": "main", "subagents": { "allowAgents": ["executor", "research-master", "content-master", "new-agent"] } } ] }, "tools": { "sessions": { "visibility": "all" }, "agentToAgent": { "enabled": true, "allow": ["main", "content-master", "research-master", "new-agent"] } } } ``` ``` The required completion summary also mandates: ```markdown - sessions.visibility: all ``` ### Technical Analysis The Skill directs the deploying agent to set session visibility globally to `all` and to expand inter-agent allowlists automatically. This is broader than the minimum access required merely to create an isolated agent. Agent creation may require communication between the main agent and the new agent, but it does not inherently require every session to be visible. Global visibility weakens isolation and increases the consequences of a compromised, malicious, or incorrectly configured agent. The configuration change is persistent and is applied through `gateway config.patch`, affecting the broader OpenClaw environment rather than only the generated workspace. ### Attack Path 1. A new agent is deployed through the Skill. 2. The workflow patches gateway configuration so session visibility becomes `all`. 3. The new identifier is added to subagent and agent-to-agent allowlists. 4. The new agent, or an attacker who compromises it, uses session discovery capabilities to identify active ses ...[truncated 1064 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not set `tools.sessions.visibility` to `all` by default. 2. Use the narrowest session visibility mode supported by OpenClaw. 3. Limit cross-agent communication to the main agent and the specific newly created agent. 4. Maintain per-agent allowlists based on the declared role rather than appending every generated agent to broad global lists. 5. Require explicit user confirmation before applying gateway-level access-control changes. 6. Present the exact current and proposed allowlists as a configuration diff. 7. Separate agent scaffold creation from privilege assignment so deployment can complete without automatically granting communication access. 8. Periodically remove stale agents from all allowlists and bindings. 9. Deny session enumeration and messaging tools unless they are necessary for the agent’s declared function. 10. Add a post-deployment verification that confirms no unrelated sessions or agents became accessible. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (7)

Tool Parameter Abuse

High
Category
Tool Misuse
Content
# Step 2: Remove agent directory
echo -e "${BLUE}2. Removing agent directory...${NC}"
if [ -d "$AGENTS_DIR/$AGENT_ID" ]; then
    rm -rf "$AGENTS_DIR/$AGENT_ID"
    echo "  Removed: $AGENTS_DIR/$AGENT_ID"
else
    echo "  Directory not found: $AGENTS_DIR/$AGENT_ID"
Confidence
95% confidence
Finding
The script passes a user-controlled AGENT_ID into 'rm -rf' path construction without validating that the value is a safe agent identifier. An attacker or mistaken user could supply path traversal sequences such as '../' and cause deletion outside the intended agents directory, especially because the script also builds a second workspace deletion path from the same input.

Session Persistence

Medium
Category
Rogue Agent
Content
---
name: agent-forge
description: Create independent OpenClaw agents via interviews. Use when: (1) creating dedicated agent with isolated workspace, (2) generating personality files (SOUL/AGENTS/USER/HEARTBEAT), (3) configuring channel bindings, (4) setting up tool permissions. Updates AGENTS.md team registry. ALWAYS interview requirements, verify configs, test before deploy.
---

## 触发方式
Confidence
84% confidence
Finding
The skill is explicitly designed to create independent agents, generate persistent workspace files, and update a team registry, which establishes durable state across sessions. In context this persistence is intentional, but it still increases risk because it can leave behind autonomous components, configuration changes, and communication paths that persist beyond the initiating conversation.

Natural-Language Policy Violations

Medium
Confidence
89% confidence
Finding
The trigger section and much of the workflow are written as prescriptive Chinese-language instructions, with no indication that users may choose another language. Under the stated policy, requiring a specific language without user opt-in is a natural-language policy concern unless the locale constraint is documented and justified.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger phrases are broad enough to activate on ordinary requests like 'create an agent', which can cause the skill to run when the user did not explicitly intend to invoke it. In this skill, unintended activation is risky because the workflow proceeds toward filesystem writes, scaffold creation, and later configuration changes that affect agent permissions and inter-agent communication.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The skill instructs automatic creation of files and patching of gateway configuration, including expanding allowlists for subagents and agent-to-agent messaging, without requiring a clear pre-change warning and explicit user authorization at the point of modification. This can silently broaden trust boundaries and persistence in the local environment, making accidental or abusive privilege expansion more likely.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The script generates a default USER.md containing a hard-coded honorific ('主人') without user selection or consent. This can create inappropriate, coercive, or culturally loaded agent behavior defaults that propagate into downstream prompts and interactions, causing harmful or unexpected conduct in deployed agents.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
echo ""
    echo "Example:"
    echo "  bash remove-agent.sh sales-bot"
    echo "  bash remove-agent.sh sales-bot --force  # Skip confirmation"
    exit 1
fi
Confidence
85% 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.

Static analysis

No suspicious patterns detected.