Back to skill

Security audit

OpenClaw Sacred Rules

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly about OpenClaw recovery, but it includes unsafe auth-state handling that users should review before installing.

Install only if you understand and accept that this skill can copy and modify sensitive OpenClaw authentication files. Do not run reset_cooldowns.sh as-is on a shared or privileged machine, and prefer fixing the hard-coded path, the fixed /tmp file, and the practice of sourcing ~/.openclaw/.env before using the scripts.

Vulnerability Patterns
  • 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
  • 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
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/auth_checker.sh:50
Finding
Predictable Temporary File Allows Symlink-Based File Clobbering<![CDATA[ ## Vulnerability Details **File Location**: `scripts/auth_checker.sh`, lines 50-68 **Vulnerability Type**: Predictable temporary file and unsafe symbolic-link handling **Risk Level**: High ### Vulnerable Code ```bash if source "$HOME/.openclaw/.env" && openclaw status > /tmp/openclaw_status.txt 2>&1; then echo "✅ OpenClaw status command succeeded" # Check for auth-related errors in output (without showing sensitive info) if grep -iq "auth" /tmp/openclaw_status.txt; then echo "ℹ️ Auth information found in status" fi if grep -iq "error\|fail\|unavailable" /tmp/openclaw_status.txt; then echo "⚠️ Potential issues detected in status" echo " Run 'openclaw status' manually to see details" fi else echo "❌ OpenClaw status command failed" echo " This suggests auth or gateway issues" echo " Check gateway is running: openclaw gateway status" fi # Clean up temp file rm -f /tmp/openclaw_status.txt ``` ### Technical Analysis The script writes OpenClaw status output to the fixed, globally predictable path `/tmp/openclaw_status.txt`. Shell redirection opens this path with truncation and follows symbolic links. The script neither creates the file securely nor verifies its ownership, type, or permissions before writing. On a multi-user system, another local user can create that path in advance as a symbolic link to a file writable by the victim. When the victim runs the checker, the shell follows the link and truncates or overwrites the target using the victim's privileges. The fixed filename also permits concurrent executions to read, overwrite, or delete each other's output. Depending on the process umask, status output containing authentication-related or operational information may be readable by other local users before cleanup. ### Attack Path 1. A local attacker identifies a file that the victim can write and whose corruption would affect the victim. 2. The attacker creates ...[truncated 1233 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Create a unique temporary file securely and ensure it is deleted on every exit path: ```bash umask 077 STATUS_FILE=$(mktemp "${TMPDIR:-/tmp}/openclaw-status.XXXXXX") || { echo "Failed to create temporary file" >&2 exit 1 } trap 'rm -f -- "$STATUS_FILE"' EXIT if source "$HOME/.openclaw/.env" && openclaw status > "$STATUS_FILE" 2>&1; then if grep -iq "auth" "$STATUS_FILE"; then echo "Auth information found in status" fi if grep -Eiq "error|fail|unavailable" "$STATUS_FILE"; then echo "Potential issues detected in status" fi fi ``` Additional hardening measures: 1. Do not use a constant filename in a shared temporary directory. 2. Set `umask 077` before creating files that can contain operational or authentication-related information. 3. Use an `EXIT` trap so cleanup occurs after errors and signals. 4. Quote the generated filename and use `rm -f --` to prevent argument interpretation. 5. Avoid elevated execution; explicitly document that this diagnostic script should run as the OpenClaw account. 6. If persistent output is unnecessary, consider capturing output in a shell variable rather than writing it to disk. ]]>

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/reset_cooldowns.sh:10
Finding
Hard-Coded Account Path Can Modify Another User's Authentication State<![CDATA[ ## Vulnerability Details **File Location**: `scripts/reset_cooldowns.sh`, lines 10-57 **Vulnerability Type**: Cross-account credential-state access caused by inconsistent file paths **Risk Level**: High ### Vulnerable Code ```bash AUTH_FILE="$HOME/.openclaw/agents/main/agent/auth-profiles.json" ``` ```bash # Check if file exists if [[ ! -f "$AUTH_FILE" ]]; then echo "❌ Auth file not found: $AUTH_FILE" exit 1 fi echo "✅ Auth file found: $AUTH_FILE" # Backup before modifying BACKUP_DIR="$HOME/openclaw-backups/cooldown-reset-$(date +%Y%m%d-%H%M%S)" mkdir -p "$BACKUP_DIR" cp "$AUTH_FILE" "$BACKUP_DIR/" echo "📦 Backed up auth file to: $BACKUP_DIR" # Reset cooldowns using Python python3 << 'EOF' import json auth_file = '/Users/admin/.openclaw/agents/main/agent/auth-profiles.json' with open(auth_file, 'r') as f: data = json.load(f) reset_count = 0 # Clear all cooldowns and error states for key in data.get('usageStats', {}): profile = data['usageStats'][key] if 'cooldownUntil' in profile: del profile['cooldownUntil'] reset_count += 1 print(f" ✓ Cleared cooldown from {key}") if 'errorCount' in profile: profile['errorCount'] = 0 if 'lastFailureAt' in profile: del profile['lastFailureAt'] if 'failureCounts' in profile: profile['failureCounts'] = {} with open(auth_file, 'w') as f: json.dump(data, f, indent=2) ``` ### Technical Analysis The shell portion derives the authentication profile from the invoking user's `$HOME`, checks that file, and backs it up. The embedded Python code ignores the validated `AUTH_FILE` value and instead reads and rewrites the fixed path: ```text /Users/admin/.openclaw/agents/main/agent/auth-profiles.json ``` Consequently, the file validated and backed up may differ from the file modified. If the script is run by a user whose home directory is not `/Users/admin`, or is invoked through privileged automation, the Python ...[truncated 2690 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Use one validated path throughout the shell and Python portions. Pass the shell path as an explicit Python argument: ```bash AUTH_FILE="$HOME/.openclaw/agents/main/agent/auth-profiles.json" if [[ ! -f "$AUTH_FILE" ]]; then echo "Auth file not found: $AUTH_FILE" >&2 exit 1 fi python3 - "$AUTH_FILE" <<'EOF' import json import os import stat import sys import tempfile auth_file = os.path.realpath(sys.argv[1]) expected_root = os.path.realpath( os.path.join(os.path.expanduser("~"), ".openclaw") ) if os.path.commonpath([auth_file, expected_root]) != expected_root: raise SystemExit("Refusing to modify a file outside the current user's OpenClaw directory") st = os.stat(auth_file) if st.st_uid != os.getuid(): raise SystemExit("Refusing to modify an auth file not owned by the current user") with open(auth_file, "r", encoding="utf-8") as f: data = json.load(f) for profile in data.get("usageStats", {}).values(): profile.pop("cooldownUntil", None) profile["errorCount"] = 0 profile.pop("lastFailureAt", None) profile["failureCounts"] = {} directory = os.path.dirname(auth_file) fd, temporary_path = tempfile.mkstemp(prefix=".auth-profiles.", dir=directory) try: with os.fdopen(fd, "w", encoding="utf-8") as f: json.dump(data, f, indent=2) f.flush() os.fsync(f.fileno()) os.chmod(temporary_path, stat.S_IMODE(st.st_mode)) os.replace(temporary_path, auth_file) finally: if os.path.exists(temporary_path): os.unlink(temporary_path) EOF ``` Additional hardening measures: 1. Remove `/Users/admin` from the script entirely. 2. Verify that the target is owned by the invoking user and is a regular file, not a symbolic link. 3. Ensure the actual target is backed up immediately before modification. 4. Validate the backup as JSON and restrict its directory and file permissions to the owner. 5. Use an atomic temporary-file write followed by `os.replace()` to prevent ...[truncated 310 chars]
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (36)

Credential Access

High
Category
Privilege Escalation
Content
**Recovery**:
1. Always prefix with environment:
   ```bash
   source ~/.openclaw/.env && openclaw auth <command>
   ```
2. Verify .env file exists and has correct permissions:
   ```bash
Confidence
88% confidence
Finding
The guide instructs sourcing ~/.openclaw/.env directly into the shell before running auth commands. Sourcing a local file executes shell content rather than merely loading variables, so if the file is tampered with, recovery instructions become an arbitrary command execution path in a privileged operational workflow.

Credential Access

High
Category
Privilege Escalation
Content
```bash
   ls -la ~/.openclaw/.env
   ```
3. If .env is missing, recreate with gateway password

## Rule 7 Violation: Read auth-profiles.json Directly
Confidence
85% confidence
Finding
Telling users to recreate a missing .env with the gateway password encourages manual secret handling outside a controlled secret-management path. This increases risk of weak storage practices, accidental disclosure in shell history or editors, and inconsistent permissions during incident recovery.

Credential Access

High
Category
Privilege Escalation
Content
3. Restart gateway
4. If no backup, regenerate auth profiles:
   ```bash
   source ~/.openclaw/.env && openclaw auth regenerate
   ```

## Rule 9 Violation: Stale In-Memory Cooldown (NEW!)
Confidence
88% confidence
Finding
Again, the document recommends sourcing the .env file before an auth regeneration command. Because sourcing executes shell syntax, a compromised or malformed environment file can trigger command execution during a sensitive recovery step and expand the blast radius of an auth incident.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔐 OpenClaw Auth Status Check"
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
    exit 1
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
    exit 1
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
    exit 1
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "==============================="

# Check if .env file exists (required for auth commands)
if [[ ! -f "$HOME/.openclaw/.env" ]]; then
    echo "❌ Missing .env file at ~/.openclaw/.env"
    echo "   This file should contain gateway passwords and API keys"
    exit 1
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo "🔍 Running OpenClaw status check..."

# Source environment and run status
if source "$HOME/.openclaw/.env" && openclaw status > /tmp/openclaw_status.txt 2>&1; then
    echo "✅ OpenClaw status command succeeded"
    
    # Check for auth-related errors in output (without showing sensitive info)
Confidence
98% confidence
Finding
Sourcing ~/.openclaw/.env imports secrets into the shell and executes any shell code embedded in that file. In a skill context, where local configuration may be attacker-influenced or less trusted than assumed, this creates a high-risk path to credential exposure and arbitrary code execution.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
fi

# Clean up temp file
rm -f /tmp/openclaw_status.txt

echo ""
echo "💡 If experiencing auth issues:"
Confidence
95% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Credential Access

High
Category
Privilege Escalation
Content
echo "💡 If experiencing auth issues:"
echo "   1. Check gateway is running: openclaw gateway status"
echo "   2. Verify .env file has correct keys"
echo "   3. Try: source ~/.openclaw/.env && openclaw auth <provider>"
echo "   4. If all else fails: check MEMORY.md for Rule #7"

echo ""
Confidence
93% confidence
Finding
The script recommends 'source ~/.openclaw/.env && openclaw auth <provider>', which normalizes an unsafe practice of executing a secrets file as shell code. This can train users into running attacker-modified configuration and unnecessarily loading secrets into their shell session.

File System Enumeration

Medium
Category
Data Exfiltration
Content
**Recovery**:
1. List recent config changes:
   ```bash
   ls -la ~/.openclaw/openclaw.json
   ls -la ~/.openclaw/.env
   ls -la ~/.openclaw/agents/main/agent/auth-profiles.json
   ```
Confidence
60% confidence
Finding
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

File System Enumeration

Medium
Category
Data Exfiltration
Content
**Recovery**:
1. List recent config changes:
   ```bash
   ls -la ~/.openclaw/openclaw.json
   ls -la ~/.openclaw/.env
   ls -la ~/.openclaw/agents/main/agent/auth-profiles.json
   ```
Confidence
60% confidence
Finding
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

File System Enumeration

Medium
Category
Data Exfiltration
Content
**Recovery**:
1. List recent config changes:
   ```bash
   ls -la ~/.openclaw/openclaw.json
   ls -la ~/.openclaw/.env
   ls -la ~/.openclaw/agents/main/agent/auth-profiles.json
   ```
Confidence
60% confidence
Finding
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

File System Enumeration

Medium
Category
Data Exfiltration
Content
**Recovery**:
1. List recent config changes:
   ```bash
   ls -la ~/.openclaw/openclaw.json
   ls -la ~/.openclaw/.env
   ls -la ~/.openclaw/agents/main/agent/auth-profiles.json
   ```
Confidence
60% confidence
Finding
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

File System Enumeration

Medium
Category
Data Exfiltration
Content
**Recovery**:
1. List recent config changes:
   ```bash
   ls -la ~/.openclaw/openclaw.json
   ls -la ~/.openclaw/.env
   ls -la ~/.openclaw/agents/main/agent/auth-profiles.json
   ```
Confidence
60% confidence
Finding
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Static analysis

No suspicious patterns detected.