Back to skill

Security audit

Cyber Security Engineer

Security checks for vulnerabilities and agentic risk

Overview

This skill has a coherent security-governance purpose, but its sudo interception design creates serious review concerns around persistent PATH changes, caller-controlled guard paths, and approval bypasses.

Install only after review. The port, egress, and compliance-reporting pieces are aligned with the stated purpose, but do not enable the sudo runtime hook until the shim stops trusting caller-controlled paths, policy files are mandatory and fail closed, approval-state mutation is protected, and the LaunchAgent PATH change has explicit confirmation and rollback.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • System PersistenceInstalls backdoors, hooks, services, or scheduled tasks that survive the run
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • 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
Findings (5)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/root_session_guard.py:278
Finding
Privileged Approval State Can Be Forged Through the Public State Helper<![CDATA[ ## Vulnerability Details **File Location**: `scripts/root_session_guard.py:278-349` **Vulnerability Type**: Unauthenticated privileged-approval state mutation **Risk Level**: High ### Vulnerable Code ```python def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser(description="OpenClaw root/elevated session guard") parser.add_argument( "--state-file", default=str(STATE_PATH), help="Path to session state JSON file", ) parser.add_argument( "--timeout-minutes", type=int, default=DEFAULT_TIMEOUT_MINUTES, help="Idle timeout for elevated mode", ) sub = parser.add_subparsers(dest="command", required=True) sub.add_parser("preflight", help="Check timeout and approval requirement") authz = sub.add_parser( "authorize", help="Authorize a specific argv against the current elevated allowlist", ) authz.add_argument( "--argv-json", required=True, help='Command argv as JSON array, e.g. ["launchctl","print","..."]', ) authz.add_argument("--session-id", help="Task session id to scope approvals") approve = sub.add_parser( "approve", help="Approve a specific argv for elevated execution (adds to allowlist)", ) approve.add_argument("--reason", required=True, help="Approval reason") approve.add_argument( "--argv-json", required=True, help='Command argv as JSON array, e.g. ["launchctl","print","..."]', ) approve.add_argument("--session-id", help="Task session id to scope approvals") sub.add_parser("elevated-used", help="Mark elevated mode as used now") sub.add_parser("normal-used", help="Mark normal mode activity now") sub.add_parser("drop", help="Drop to normal mode") sub.add_parser("status", help="Print current state and timeout info") return parser.parse_args() def main() -> int: args = parse_args() state_file = Path( ...[truncated 3098 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Remove the directly callable `approve` state mutation operation from the public helper interface. - Keep approval and state mutation in one trusted process so another local process cannot invoke the mutation independently. - Alternatively, require a short-lived, single-use, cryptographically authenticated approval capability generated only after interactive consent. - Bind the capability to the canonical argv, session ID, user identity, expiration time, and nonce. - Verify state-file ownership and permissions before every read and write, and reject symlinks or unexpected file types. - Use atomic state updates with restrictive permissions such as mode `0600`. - Make task-session scoping mandatory rather than optional. - Add regression tests proving that direct invocation of the helper cannot create an accepted approval. ]]>

T07 · Tool Hijacking and Spoofing

Error
Location
scripts/install-openclaw-runtime-hook.sh:102
Finding
Sudo Shim Executes Caller-Controlled Python and Guard Implementations<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install-openclaw-runtime-hook.sh:102-129` **Vulnerability Type**: Environment-controlled security-tool replacement **Risk Level**: Critical ### Vulnerable Code ```bash cat > "${WRAPPER}" <<EOF #!/usr/bin/env bash set -euo pipefail REAL_SUDO_OVERRIDE="\${OPENCLAW_REAL_SUDO:-${REAL_SUDO}}" PYTHON3_OVERRIDE="\${OPENCLAW_PYTHON3:-${PYTHON3}}" SKILL_DIR="\${OPENCLAW_CYBER_SKILL_DIR:-${SKILL_DIR_DEFAULT}}" # Pass-through for sudo bookkeeping. if [[ \$# -eq 0 ]]; then exec "\${REAL_SUDO_OVERRIDE}" fi case "\${1:-}" in -h|--help|-V|--version|-v|-l|-k) exec "\${REAL_SUDO_OVERRIDE}" "\$@" ;; esac # Refuse non-interactive privilege escalation by default (safety). if [[ ! -t 0 && "\${OPENCLAW_ALLOW_NONINTERACTIVE_SUDO:-0}" != "1" ]]; then echo "[cyber-security-engineer] Refusing non-interactive sudo (set OPENCLAW_ALLOW_NONINTERACTIVE_SUDO=1 to override)." >&2 exit 2 fi REASON="\${OPENCLAW_PRIV_REASON:-OpenClaw requested privileged execution}" # Sanitize reason: strip shell metacharacters to prevent injection REASON="\$(printf '%s' "\${REASON}" | tr -d '\`\$\\!;|&<>(){}' | head -c 200)" export OPENCLAW_REAL_SUDO="\${REAL_SUDO_OVERRIDE}" export OPENCLAW_PYTHON3="\${PYTHON3_OVERRIDE}" exec "\${PYTHON3_OVERRIDE}" "\${SKILL_DIR}/scripts/guarded_privileged_exec.py" \ --reason "\${REASON}" \ --use-sudo \ -- "\$@" EOF ``` ### Technical Analysis The generated sudo shim accepts `OPENCLAW_PYTHON3`, `OPENCLAW_CYBER_SKILL_DIR`, and `OPENCLAW_REAL_SUDO` from its caller. It then executes the selected Python binary and guard script before performing canonical-path, ownership, or permission validation. Consequently, the component intended to enforce approval and policy can be replaced at invocation time: - `OPENCLAW_PYTHON3` can reference an attacker-controlled executable. - `OPENCLAW_CYBER_SKILL_DIR` can reference an attacker-controlled directory containing a substitute `guarded_privileged_exec ...[truncated 1483 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Remove runtime overrides for the interpreter, Skill directory, and real sudo binary from the installed shim. - Resolve and embed canonical paths during installation. - Before every invocation, verify that the interpreter, guard script, imported sibling modules, and sudo binary: - Are regular files. - Are not symlinks to unexpected locations. - Have expected canonical paths. - Are owned by a trusted administrative identity. - Are not group- or world-writable. - Clear all security-sensitive `OPENCLAW_*` override variables before invoking the guard. - Pin the installed shim and guard files using a signature or trusted checksum. - Install the enforcement component in an administrator-controlled, non-user-writable directory if it is expected to establish a security boundary against user-controlled OpenClaw processes. - Add tests that invoke the shim with malicious override variables and verify that it fails closed. ]]>

T06 · System Persistence

Error
Location
scripts/install-openclaw-runtime-hook.sh:95
Finding
Non-Interactive Installation Can Persistently Intercept Gateway Sudo Calls Without Confirmation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install-openclaw-runtime-hook.sh:95-170` **Vulnerability Type**: Persistent PATH modification and sudo interception **Risk Level**: High ### Vulnerable Code ```bash mkdir -p "${BIN_DIR}" chmod 700 "${OPENCLAW_DIR}" "${BIN_DIR}" || true WRAPPER="${BIN_DIR}/sudo" cat > "${WRAPPER}" <<EOF #!/usr/bin/env bash set -euo pipefail ... EOF chmod 700 "${WRAPPER}" log "Installed sudo shim: ${WRAPPER}" if [[ "$(uname -s)" == "Darwin" ]]; then PLIST="${HOME}/Library/LaunchAgents/ai.openclaw.gateway.plist" if [[ -f "${PLIST}" ]] && command -v /usr/libexec/PlistBuddy >/dev/null 2>&1; then if [[ -t 0 && "${OPENCLAW_SKIP_PLIST_CONFIRM:-0}" != "1" ]]; then printf '[cyber-security-engineer] This will modify the gateway LaunchAgent PATH in:\n %s\nProceed? [y/N]: ' "${PLIST}" read -r confirm if [[ "${confirm}" != "y" && "${confirm}" != "Y" ]]; then log "Skipped LaunchAgent PATH modification. You can add ${BIN_DIR} to PATH manually." log "Restart the OpenClaw gateway to apply:" log " openclaw gateway restart" exit 0 fi fi # Ensure EnvironmentVariables exists and prepend ~/.openclaw/bin to PATH. /usr/libexec/PlistBuddy -c "Add :EnvironmentVariables dict" "${PLIST}" 2>/dev/null || true EXISTING_PATH="$(/usr/libexec/PlistBuddy -c "Print :EnvironmentVariables:PATH" "${PLIST}" 2>/dev/null || true)" if [[ -z "${EXISTING_PATH}" ]]; then NEW_PATH="${BIN_DIR}:/usr/bin:/bin:/usr/sbin:/sbin" /usr/libexec/PlistBuddy -c "Add :EnvironmentVariables:PATH string ${NEW_PATH}" "${PLIST}" 2>/dev/null || \ /usr/libexec/PlistBuddy -c "Set :EnvironmentVariables:PATH ${NEW_PATH}" "${PLIST}" 2>/dev/null || true log "Updated gateway LaunchAgent PATH to include ${BIN_DIR}" else case ":${EXISTING_PATH}:" in *":${BIN_DIR}:"*) ;; *) NEW_PATH="${BIN_DIR}:${EXISTING_PATH}" /usr/libexec/Plist ...[truncated 2114 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Require an explicit installation flag such as `--confirm-path-interception`; fail closed when it is absent, regardless of TTY state. - Do not infer consent from whether execution is interactive. - Display the exact plist path and old/new PATH values before modification. - Back up the original plist value and provide a verified uninstall operation that restores it. - Validate plist ownership and permissions before editing it. - Use an administrator-controlled installation location if the shim is meant to enforce a security boundary. - Verify shim integrity before each gateway startup. - Correct `SKILL.md` so its file-write disclosure explicitly includes the LaunchAgent plist modification. - Prefer explicit invocation of the guarded command wrapper over globally shadowing a standard system tool. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/command_policy.py:12
Finding
Privileged Command and Prompt Policies Fail Open When Missing or Invalid<![CDATA[ ## Vulnerability Details **File Location**: `scripts/command_policy.py:12-19,58-100` **Vulnerability Type**: Fail-open privileged command authorization **Risk Level**: High ### Vulnerable Code ```python def _load_policy() -> Dict[str, object]: if not POLICY_PATH.exists(): return {} try: raw = json.loads(POLICY_PATH.read_text(encoding="utf-8")) return raw if isinstance(raw, dict) else {} except Exception: return {} def evaluate_command(argv: List[str]) -> Dict[str, object]: """ Evaluate the command argv against an optional allow/deny policy. Behavior: - If policy file is missing: allow. - If deny_exact or deny regex matches: block. - If allow_exact is non-empty: require exact match. - Else if allow regex list is non-empty: require allow match. """ cmd_str = shlex.join(argv) if argv else "" pol = _load_policy() allow = _compile_patterns(pol.get("allow")) deny = _compile_patterns(pol.get("deny")) allow_exact = _load_exact_rules(pol.get("allow_exact")) deny_exact = _load_exact_rules(pol.get("deny_exact")) if deny_exact and _match_exact(deny_exact, argv): return {"allowed": False, "reason": "deny_exact_match", "pattern": "exact"} deny_match = _match_any(deny, cmd_str) if deny_match: return {"allowed": False, "reason": "deny_match", "pattern": deny_match} if allow_exact: if not _match_exact(allow_exact, argv): return {"allowed": False, "reason": "not_in_allow_exact", "pattern": None} return {"allowed": True, "reason": "allow_exact_match", "pattern": "exact"} if allow: allow_match = _match_any(allow, cmd_str) if not allow_match: return {"allowed": False, "reason": "not_in_allowlist", "pattern": None} return {"allowed": True, "reason": "allow_match", "pattern": allow_match} return {"allowed": True, "reason": "no_policy_or_allow_empty", "pattern": N ...[truncated 2601 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Fail closed whenever privileged execution is enabled and the command policy is missing, unreadable, malformed, empty, or semantically invalid. - Make policy-file enforcement mandatory in code rather than controlled by an optional environment variable. - Require at least one exact argv allow rule for privileged commands. - Reject the entire policy if any configured regular expression is invalid. - Prefer exact argv matching over regular expressions built over shell-quoted command strings. - Explicitly prohibit shell and interpreter launchers unless a complete, narrowly scoped argv is approved. - Verify policy-file ownership, regular-file type, canonical path, and restrictive permissions. - Make task-session scoping and untrusted-source confirmation secure defaults. - Log policy validation failures, but do not continue with command execution. ]]>

T07 · Tool Hijacking and Spoofing

Warning
Location
scripts/live_assessment.py:149
Finding
Compliance Check Can Be Spoofed by Any Executable at the Expected Sudo-Shim Path<![CDATA[ ## Vulnerability Details **File Location**: `scripts/live_assessment.py:149-151,242-251` **Vulnerability Type**: Insufficient verification of security-control installation **Risk Level**: Medium ### Vulnerable Code ```python def runtime_hook_installed() -> bool: hook = Path.home() / ".openclaw" / "bin" / "sudo" return hook.exists() and os.access(hook, os.X_OK) ``` ```python approval_enforced = runtime_hook_installed() set_check( checks_by_id, "privilege_approval_required", "compliant" if approval_enforced else "violation", "high", "Runtime privileged execution hook is installed." if approval_enforced else "Runtime privileged execution hook not detected.", "Checked for ~/.openclaw/bin/sudo wrapper installed by cyber-security-engineer.", "Approval-first execution is not enforced for privileged actions.", "Run cyber-security-engineer/scripts/install-openclaw-runtime-hook.sh and restart OpenClaw gateway.", "Security Engineering", due_in(14), ) ``` ### Technical Analysis The assessment treats the approval control as compliant if an executable filesystem entry exists at `~/.openclaw/bin/sudo`. It does not verify: - File ownership or permissions. - Whether the entry is a regular file or symlink. - The shim's content or checksum. - The canonical guard and interpreter paths. - Whether the gateway PATH actually resolves `sudo` to this file. - Whether the wrapper's policy and approval checks are functional. As a result, a malicious, unrelated, stale, or broken executable can satisfy the compliance test. This creates a false assurance condition in generated reports and dashboards. ### Attack Path 1. An attacker or misconfigured installer places any executable at `~/.openclaw/bin/sudo`. 2. The gateway may continue using the system sudo binary, or the replacement may omit all approval controls. 3. `live_assessment.py` runs and calls `runtime_hook_installed()`. 4. The existence and executable checks return tr ...[truncated 595 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Verify that the hook is a regular file with expected ownership and restrictive permissions. - Resolve symlinks and reject paths outside the trusted installation directory. - Validate the shim against a signed manifest or pinned cryptographic hash. - Validate the interpreter, guard script, imported modules, and real sudo path referenced by the shim. - Inspect the effective gateway environment and confirm that PATH resolves `sudo` to the verified hook. - Perform a non-privileged functional test proving that the hook requests approval and enforces a known-denied command. - Report the control as `unknown` or `partial` when effective enforcement cannot be demonstrated. - Include verification evidence, such as hashes, canonical paths, ownership, permissions, and effective PATH order, in the generated assessment. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (92)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the skill can dispatch notifications to an external command and maintain state beyond what its description emphasizes, that expands its effective attack surface. In a security-engineering skill, undocumented subprocess execution is risky because users may trust it with sensitive host context and privileged workflow decisions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the skill can dispatch notifications to an external command and maintain state beyond what its description emphasizes, that expands its effective attack surface. In a security-engineering skill, undocumented subprocess execution is risky because users may trust it with sensitive host context and privileged workflow decisions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
If the skill can dispatch notifications to an external command and maintain state beyond what its description emphasizes, that expands its effective attack surface. In a security-engineering skill, undocumented subprocess execution is risky because users may trust it with sensitive host context and privileged workflow decisions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the skill can dispatch notifications to an external command and maintain state beyond what its description emphasizes, that expands its effective attack surface. In a security-engineering skill, undocumented subprocess execution is risky because users may trust it with sensitive host context and privileged workflow decisions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
If the skill can dispatch notifications to an external command and maintain state beyond what its description emphasizes, that expands its effective attack surface. In a security-engineering skill, undocumented subprocess execution is risky because users may trust it with sensitive host context and privileged workflow decisions.

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding
If the skill can dispatch notifications to an external command and maintain state beyond what its description emphasizes, that expands its effective attack surface. In a security-engineering skill, undocumented subprocess execution is risky because users may trust it with sensitive host context and privileged workflow decisions.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
rules.append(rule)

    rules.sort(key=lambda r: (int(r.get("port", 0)), str(r.get("protocol", "")), str(r.get("command", ""))))
    return rules, len(seen)


def main() -> int:
Confidence
85% confidence
Finding
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Env Variable Harvesting

High
Category
Data Exfiltration
Content
return 0
        _UNSAFE_ENV_VARS = {"LD_PRELOAD", "LD_LIBRARY_PATH", "DYLD_INSERT_LIBRARIES",
                           "PYTHONPATH", "RUBYLIB", "NODE_PATH", "IFS", "CDPATH"}
        safe_env = {k: v for k, v in os.environ.items() if k not in _UNSAFE_ENV_VARS}
        p = subprocess.run(argv, check=False, input=message, text=True, timeout=5, env=safe_env)
        return int(p.returncode or 0)
    except Exception:
Confidence
70% confidence
Finding
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Lp3

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding
The skill declares broad capabilities and references shell execution, environment variables, file reads, and file writes, but does not define an explicit tool/permission scope. In a security-sensitive skill that can influence privileged workflows and install a sudo shim, missing scope boundaries increases the chance of unintended or overbroad execution by the agent runtime.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- `OPENCLAW_UNTRUSTED_SOURCE` — set to `1` to flag the current content source as untrusted
- `OPENCLAW_VIOLATION_NOTIFY_CMD` — absolute path to a notifier binary (must also be allowlisted)
- `OPENCLAW_VIOLATION_NOTIFY_ALLOWLIST` — JSON array of allowed argv arrays, or comma-separated absolute paths
- `OPENCLAW_REAL_SUDO` — override path to the real sudo binary (used by the runtime hook shim)
- `OPENCLAW_PYTHON3` — override path to python3 (used by the runtime hook shim)
- `OPENCLAW_CYBER_SKILL_DIR` — override path to the skill directory (used by the runtime hook shim)
- `OPENCLAW_ALLOW_NONINTERACTIVE_SUDO` — set to `1` to allow non-interactive sudo through the shim (default: blocked)
Confidence
82% confidence
Finding
The skill exposes environment-variable overrides controlling the real sudo path, python path, skill directory, approval token behavior, and notifier execution. In a security-sensitive privileged-execution workflow, env-driven control of executable paths can be abused for command hijacking or policy bypass if not rigidly validated by the implementation.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- `OPENCLAW_REAL_SUDO` — override path to the real sudo binary (used by the runtime hook shim)
- `OPENCLAW_PYTHON3` — override path to python3 (used by the runtime hook shim)
- `OPENCLAW_CYBER_SKILL_DIR` — override path to the skill directory (used by the runtime hook shim)
- `OPENCLAW_ALLOW_NONINTERACTIVE_SUDO` — set to `1` to allow non-interactive sudo through the shim (default: blocked)
- `OPENCLAW_PRIV_REASON` — human-readable reason passed to the guarded execution wrapper
- `OPENCLAW_VIOLATION_NOTIFY_STATE` — override path to the notification state file
- `OPENCLAW_SKIP_PLIST_CONFIRM` — set to `1` to skip the interactive confirmation before modifying the macOS LaunchAgent plist
Confidence
78% confidence
Finding
The documented `OPENCLAW_ALLOW_NONINTERACTIVE_SUDO=1` switch weakens the safety model by allowing automated privileged execution through the shim. Combined with other env-based overrides, this can reduce the effectiveness of explicit user approval and enable unattended privilege use if misconfigured or attacker-controlled.

Session Persistence

Medium
Category
Rogue Agent
Content
- `OPENCLAW_ALLOW_NONINTERACTIVE_SUDO` — set to `1` to allow non-interactive sudo through the shim (default: blocked)
- `OPENCLAW_PRIV_REASON` — human-readable reason passed to the guarded execution wrapper
- `OPENCLAW_VIOLATION_NOTIFY_STATE` — override path to the notification state file
- `OPENCLAW_SKIP_PLIST_CONFIRM` — set to `1` to skip the interactive confirmation before modifying the macOS LaunchAgent plist

**Policy files (admin reviewed):**
- `~/.openclaw/security/approved_ports.json`
Confidence
75% confidence
Finding
This finding is the same persistence concern at the same line: a flag that disables confirmation before changing a LaunchAgent plist. LaunchAgent modifications affect future process behavior and therefore deserve strong anti-abuse controls.

Session Persistence

Medium
Category
Rogue Agent
Content
- `OPENCLAW_ALLOW_NONINTERACTIVE_SUDO` — set to `1` to allow non-interactive sudo through the shim (default: blocked)
- `OPENCLAW_PRIV_REASON` — human-readable reason passed to the guarded execution wrapper
- `OPENCLAW_VIOLATION_NOTIFY_STATE` — override path to the notification state file
- `OPENCLAW_SKIP_PLIST_CONFIRM` — set to `1` to skip the interactive confirmation before modifying the macOS LaunchAgent plist

**Policy files (admin reviewed):**
- `~/.openclaw/security/approved_ports.json`
Confidence
75% confidence
Finding
This finding is the same persistence concern at the same line: a flag that disables confirmation before changing a LaunchAgent plist. LaunchAgent modifications affect future process behavior and therefore deserve strong anti-abuse controls.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
8. If no approved baseline exists, generate one with `python3 scripts/generate_approved_ports.py`, then review and prune.
9. Benchmark controls against ISO 27001 and NIST and report violations with mitigations.

## Runtime Hook (sudo shim)

The script `scripts/install-openclaw-runtime-hook.sh` installs an **opt-in** sudo
shim at `~/.openclaw/bin/sudo`. This shim **shadows** the system `sudo` binary by
Confidence
86% confidence
Finding
Documenting and installing a sudo-shimming mechanism that shadows the system sudo via PATH manipulation is inherently sensitive. Even if opt-in, PATH-based interception of privileged commands is dangerous because it creates opportunities for confusion, bypass, or abuse if users or calling processes do not clearly understand which sudo implementation is executing.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
## Runtime Hook (sudo shim)

The script `scripts/install-openclaw-runtime-hook.sh` installs an **opt-in** sudo
shim at `~/.openclaw/bin/sudo`. This shim **shadows** the system `sudo` binary by
prepending `~/.openclaw/bin` to `PATH` in the OpenClaw gateway process.
Confidence
88% confidence
Finding
Placing a fake `sudo` earlier in PATH changes the trust boundary of all subsequent command execution in that process tree. In a security tool, that can be especially dangerous because operators may assume standard sudo behavior while actually invoking custom logic that mediates or logs privileged actions.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- Intercepts `sudo` invocations and routes them through `guarded_privileged_exec.py`
- Requires explicit interactive user approval before running any privileged command
- Enforces command policy allow/deny rules, audit logging, and a 30-minute idle timeout
- Blocks non-interactive sudo by default (prevents automated abuse)
- Passes through harmless flags (`-h`, `--version`, `-k`, `-l`) directly to real sudo

**What it does NOT do:**
Confidence
80% confidence
Finding
Interception of sudo invocations means this skill can sit in the execution path for privileged operations. That central mediation point becomes a high-value target: any flaw in policy enforcement, approval, logging, or argument handling could allow unauthorized root command execution or incomplete audit trails.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- Requires explicit interactive user approval before running any privileged command
- Enforces command policy allow/deny rules, audit logging, and a 30-minute idle timeout
- Blocks non-interactive sudo by default (prevents automated abuse)
- Passes through harmless flags (`-h`, `--version`, `-k`, `-l`) directly to real sudo

**What it does NOT do:**
- It does not replace or modify the system sudo binary
Confidence
71% confidence
Finding
Passing selected flags directly through to the real sudo introduces split behavior that can create bypass opportunities if the allowlisted flag set is incomplete or parsed ambiguously. Attackers often exploit subtle option parsing differences in wrappers around security-sensitive binaries.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- Passes through harmless flags (`-h`, `--version`, `-k`, `-l`) directly to real sudo

**What it does NOT do:**
- It does not replace or modify the system sudo binary
- It does not grant itself any elevated permissions
- It only affects processes whose `PATH` includes `~/.openclaw/bin` before `/usr/bin`
Confidence
84% confidence
Finding
The manifest explicitly states that behavior depends on PATH ordering, which is a classic command-hijacking vector. Any mechanism that relies on shadowing a standard administrative binary can be exploited or misapplied if PATH is manipulated unexpectedly or inherited in broader contexts than intended.

Session Persistence

Medium
Category
Rogue Agent
Content
**Opt-in:** The hook is **not installed by default**. To enable it, run bootstrap with
`ENFORCE_PRIVILEGED_EXEC=1`. On macOS, the installer will prompt for confirmation
before modifying the gateway LaunchAgent plist. The shim can be removed at any time
by deleting `~/.openclaw/bin/sudo`.

## File Writes
Confidence
75% confidence
Finding
The skill describes modifying the gateway LaunchAgent plist to enable PATH-based sudo interception, which is a form of persistent execution-context change. Persistence in a privileged-control skill is especially sensitive because it alters future command behavior beyond the immediate task.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- `~/.openclaw/security/root-session-state.json` — elevated session state (by `root_session_guard.py`)
- `~/.openclaw/security/privileged-audit.jsonl` — append-only audit log (by `audit_logger.py`)
- `~/.openclaw/security/violation-notify-state.json` — notification diff state (by `notify_on_violation.py`)
- `~/.openclaw/bin/sudo` — opt-in sudo shim (by `install-openclaw-runtime-hook.sh`, see Runtime Hook section)
- `~/.openclaw/logs/cyber-security-engineer-auto.log` — auto-cycle run log (by `auto_invoke_cycle.sh`)

**Under `assessments/` (inside skill directory):**
Confidence
74% confidence
Finding
The skill persists privileged session state and audit data and stores a sudo shim under the user’s OpenClaw directory. Persistence around privileged workflows increases risk because tampering with state files or the shim could alter approval behavior, suppress evidence, or affect future executions.

Session Persistence

Medium
Category
Rogue Agent
Content
<tr><td>privilege_approval_required</td><td>Route all privileged tasks through guarded_privileged_exec.py and enforce approval prompts for elevated execution.</td><td>Security Engineering</td><td>2026-03-15</td></tr>
<tr><td>least_privilege_enforced</td><td>Fix state dir ownership/permissions and enforce command allowlist/approval defaults.</td><td>Platform Security</td><td>2026-03-07</td></tr>
<tr><td>elevation_timeout_30m</td><td>Invoke guarded_privileged_exec.py for every elevated operation path.</td><td>Security Engineering</td><td>2026-03-15</td></tr>
<tr><td>audit_logging_privileged_actions</td><td>Create append-only correlated audit records linking approval, execution, and drop events.</td><td>SecOps</td><td>2026-03-22</td></tr>
<tr><td>open_ports_approved</td><td>Populate ~/.openclaw/security/approved_ports.json and remove unnecessary listeners.</td><td>Infrastructure</td><td>2026-02-28</td></tr>
<tr><td>insecure_ports_remediated</td><td>Enforce baseline checks to block insecure service ports.</td><td>Network Security</td><td>2026-04-01</td></tr>
        </tbody>
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
"observed_state": "Gateway logs and session transition logs are available.",
        "evidence": "gateway status reports log paths; root_session_guard records transition metadata.",
        "gap": "No single correlated privileged action audit timeline is guaranteed.",
        "mitigation": "Create append-only correlated audit records linking approval, execution, and drop events.",
        "owner": "SecOps",
        "due_date": "2026-03-22"
      },
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
This entry declares the least-privilege control as compliant while simultaneously documenting unresolved writable state directory and integrity warnings. That contradiction can mislead operators, auditors, or automated governance workflows into treating a non-hardened privileged environment as adequately protected, reducing urgency for remediation.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The control section repeats the same contradiction: it marks least-privilege enforcement as compliant while admitting the posture is incomplete due to ownership/permission and integrity concerns. In a security engineering skill, this is especially dangerous because downstream reporting or approval processes may rely on the control table as authoritative and permit risky privileged operation paths.

Session Persistence

Medium
Category
Rogue Agent
Content
"observed_state": "Gateway logs and session transition logs are available.",
      "evidence": "gateway status reports log paths; root_session_guard records transition metadata.",
      "gap": "No single correlated privileged action audit timeline is guaranteed.",
      "mitigation": "Create append-only correlated audit records linking approval, execution, and drop events.",
      "owner": "SecOps",
      "due_date": "2026-03-22"
    },
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Static analysis

No suspicious patterns detected.