safe-exec for Openclaw

A security wrapper that protects AI agents from prompt injection by isolating untrusted shell command outputs using UUID-based boundaries.

jmceleney
v1.0.0
Feb 5, 2026
1
2.4k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install openclaw-safe-exec

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install openclaw-safe-exec using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is safe-exec?

safe-exec is a critical security utility designed for LLM agents that interact with shell environments. It addresses a significant vulnerability: prompt injection via external data. When an agent executes a command that fetches remote data or reads untrusted files, an attacker can embed malicious instructions in that output. By using Openclaw Skills like this one, developers can ensure that the agent treats command output strictly as data, not as a source of new instructions.

The tool functions by encapsulating the standard output and error streams within cryptographically random UUID boundaries. These boundaries are unique to every execution, making it impossible for an attacker to guess or forge the closing tags. This ensures that the LLM can distinguish between the agent's internal control flow and the raw data returned by a command, reinforcing the security posture of Openclaw Skills.

safe-exec Use Cases

  • Executing external API calls via curl or wget where responses are untrusted.
  • Fetching remote data through scripts or CLI tools like the GitHub CLI or AWS CLI.
  • Reading user-generated files or logs that might contain malicious injection payloads.
  • Any scenario where command output is processed by an LLM and could influence future agent actions.

How safe-exec Works

  1. The script generates a unique, cryptographically random UUID for the specific execution.
  2. It outputs a security preamble to the LLM, explaining the rules and providing the specific UUID for the current block.
  3. It opens security boundaries for STDOUT and STDERR using the generated UUID tags.
  4. The requested command is executed, and its output is streamed naturally into the designated boundaries.
  5. Once the command finishes, the boundaries are closed using the same unique UUID.
  6. The script reports the final exit code within its own UUID-protected block to prevent status spoofing for Openclaw Skills workflow integrity.

safe-exec Setup

To install this tool, copy the script to your local path and ensure it has execution permissions:

# Copy to PATH
cp scripts/safe-exec.sh ~/.local/bin/safe-exec

# Grant execution permissions
chmod +x ~/.local/bin/safe-exec

safe-exec Data Schema & Taxonomy

The tool uses a structured tagging system to help the LLM identify data boundaries. The following table describes the structure used within Openclaw Skills:

Component Tag Format Purpose
Block ID Block ID: [UUID] Identifies the unique session ID
STDOUT Open <<<STDOUT:[UUID]>>> Marks the start of command output
STDOUT Close <<<END_STDOUT:[UUID]>>> Marks the end of command output
EXIT Open <<<EXIT:[UUID]>>> Marks the start of the exit code
EXIT Close <<<END_EXIT:[UUID]>>> Marks the end of the exit code

safe-exec Advanced Features

  • Unguessable UUIDs: Uses 2^122 possibilities to ensure attackers cannot predict boundary markers.
  • Per-execution Freshness: Generates a brand new UUID for every command, preventing cross-contamination.
  • Rule Precedence: The security preamble is displayed before untrusted data, ensuring the LLM understands the constraints first.
  • Stream-compatible: Does not buffer output, allowing the agent to see data in real-time while maintaining the security context of Openclaw Skills.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*