Back to skill

Security audit

OpenClaw Healthcheck Cron

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed scheduled OpenClaw health-check skill, with a few hardening items users should configure before enabling it.

Install only if you want an automated local OpenClaw health check. Before enabling the cron job, set the correct timezone, run it under a low-privilege user, and set HEALTHCHECK_OUTPUT_DIR to a private directory such as a per-user state folder instead of the shared /tmp default.

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/healthcheck.sh:4
Finding

Predictable Temporary Paths Allow Symlink-Based File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/healthcheck.sh, lines 4-12 and 35-54
Vulnerability Type: Unsafe temporary-file handling and symbolic-link following
Risk Level: Medium

Vulnerable Code

bash
OUT_ROOT="${HEALTHCHECK_OUTPUT_DIR:-/tmp/openclaw-healthcheck}"
EXCLUDE_RAW="${HEALTHCHECK_EXCLUDE:-small model,sandbox,groupPolicy}"
TS="$(date +%H%M%S)"
DAY="$(date +%F)"
OUT_DIR="${OUT_ROOT}/${DAY}/${TS}"
mkdir -p "$OUT_DIR"

LOG="$OUT_DIR/run.log"
SUMMARY_JSON="$OUT_DIR/summary.json"

The files are subsequently opened using ordinary shell redirections:

bash
{
  echo "[healthcheck] started: $(date -Is)"
  echo "[healthcheck] out_dir: $OUT_DIR"
  echo "[healthcheck] exclude: $EXCLUDE_RAW"
} > "$LOG"

cat > "$SUMMARY_JSON" <<EOF
{
  "verdict": "$verdict",
  "passed": $passed,
  "warn": $warn,
  "fail": $fail,
  "artifact_path": "$OUT_DIR",
  "issues": [$(printf '"%s",' "${issues[@]:-}" | sed 's/,$//')]
}
EOF

Technical Analysis

The default output root is a fixed path under the shared /tmp namespace. Subdirectories are derived only from the current date and second, making the final paths predictable, especially because the accompanying cron example specifies known execution times.

mkdir -p does not establish exclusive ownership of an already existing directory and can traverse attacker-created directory structures. The later > "$LOG" and > "$SUMMARY_JSON" redirections follow symbolic links and truncate their targets. The script does not verify directory ownership, reject symbolic links, use an atomically created private directory, or open files with no-follow semantics.

Consequently, another local user who can write under /tmp may pre-create the expected directory and place run.log or summary.json symbolic links pointing to files writable by the account running the health check.

Attack Path

  1. A local attacke ...[truncated 1725 chars]
Remediation
View remediation

Remediation Suggestions

  • Create the output root as a private directory with restrictive permissions before use:

    bash
    umask 077
    OUT_ROOT="${HEALTHCHECK_OUTPUT_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/openclaw-healthcheck}"
    install -d -m 700 -- "$OUT_ROOT"
    
  • Prefer a trusted per-user state directory instead of a shared /tmp location.

  • If temporary storage is required, atomically create an unpredictable directory with mktemp -d:

    bash
    umask 077
    BASE="${HEALTHCHECK_OUTPUT_DIR:-/tmp/openclaw-healthcheck}"
    install -d -m 700 -- "$BASE"
    OUT_DIR="$(mktemp -d "$BASE/healthcheck.XXXXXXXX")"
    
  • Before writing, verify that the output directory is owned by the effective user and is not a symbolic link.

  • Create output files atomically and reject existing paths. Where available, use a helper that opens files with O_CREAT | O_EXCL | O_NOFOLLOW.

  • Run the scheduled job with a dedicated, minimally privileged account so that any filesystem overwrite is limited in scope.

  • Consider retaining date-based organization only after first creating a private, unpredictable directory; do not rely on timestamps as a security boundary.

Vulnerability Patterns
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • 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 (4)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The declared description promises a broader automation workflow: a reusable OpenClaw deep healthcheck with cron-based scheduling, standardized audits, sanitization for sharing, and packaging for reuse. The supplied code chunk only implements a simple shell script that checks whether openclaw exists and whether two status commands succeed, then records results locally. While this partially aligns with the general theme of a healthcheck, several core declared capabilities are absent, especially cron setup, sanitization, and reusable packaging. Therefore the description materially overstates what this code actually does.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- `SKILL.md`

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

The comment at L14 states 'Keep this script read-only,' which contradicts the script's actual behavior. The script creates an output directory (L09) and writes both a log file and a JSON summary (L39, L53), so the documentation actively misrepresents its side effects.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

Line L06 defaults the schedule timezone to "America/New_York" when the environment variable is unset. This imposes a specific locale by default in a natural-language/config value without any visible user choice or explanation that the skill is region-specific.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.