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

Content
View full analysis
/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
View remediation
&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

Content
View full analysis
Remediation
View remediation
&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
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.

Content

Scanner excerpt · references/recovery.md (reported line 109)May include surrounding context.

Recovery:

  1. Always prefix with environment:
    bash
    source ~/.openclaw/.env && openclaw auth <command>
    
  2. Verify .env file exists and has correct permissions:
    bash

Credential Access

High
Category
Privilege Escalation
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.

Content

Scanner excerpt · references/recovery.md (reported line 115)May include surrounding context.

bash
   ls -la ~/.openclaw/.env
  1. If .env is missing, recreate with gateway password

Rule 7 Violation: Read auth-profiles.json Directly

Credential Access

High
Category
Privilege Escalation
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.

Content

Scanner excerpt · references/recovery.md (reported line 130)May include surrounding context.

  1. Restart gateway
  2. If no backup, regenerate auth profiles:
    bash
    source ~/.openclaw/.env && openclaw auth regenerate
    

Rule 9 Violation: Stale In-Memory Cooldown (NEW!)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 34)May include surrounding context.

md
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · references/recovery.md (reported line 95)May include surrounding context.

md
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · references/recovery.md (reported line 111)May include surrounding context.

md
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · references/recovery.md (reported line 113)May include surrounding context.

md
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/auth_checker.sh (reported line 10)May include surrounding context.

sh
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/auth_checker.sh (reported line 12)May include surrounding context.

sh
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/auth_checker.sh (reported line 75)May include surrounding context.

sh
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/safe_backup.sh (reported line 66)May include surrounding context.

sh
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/safe_backup.sh (reported line 68)May include surrounding context.

sh
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/safe_backup.sh (reported line 70)May include surrounding context.

sh
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"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/auth_checker.sh (reported line 11)May include surrounding context.

sh
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

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/auth_checker.sh (reported line 12)May include surrounding context.

sh
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

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/safe_backup.sh (reported line 20)May include surrounding context.

sh
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

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/safe_backup.sh (reported line 67)May include surrounding context.

sh
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

Credential Access

High
Category
Privilege Escalation
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.

Content

Scanner excerpt · scripts/auth_checker.sh (reported line 50)May include surrounding context.

sh
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)

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · scripts/auth_checker.sh (reported line 70)May include surrounding context.

sh
fi

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

echo ""
echo "💡 If experiencing auth issues:"

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

The script recommends 'source ~/.openclaw/.env && openclaw auth ', 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.

Content

Scanner excerpt · scripts/auth_checker.sh (reported line 76)May include surrounding context.

sh
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 ""

File System Enumeration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Content

Scanner excerpt · references/recovery.md (reported line 94)May include surrounding context.

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
    

File System Enumeration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Content

Scanner excerpt · references/recovery.md (reported line 95)May include surrounding context.

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
    

File System Enumeration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Content

Scanner excerpt · references/recovery.md (reported line 96)May include surrounding context.

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
    

File System Enumeration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Content

Scanner excerpt · references/recovery.md (reported line 113)May include surrounding context.

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
    

File System Enumeration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Content

Scanner excerpt · references/recovery.md (reported line 176)May include surrounding context.

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
    

Static analysis

No suspicious patterns detected.