Back to skill

Security audit

subagent-timeout-config

Security checks for vulnerabilities and agentic risk

Overview

The skill is a disclosed OpenClaw timeout configurator that edits the expected config file and can restart the gateway, with some implementation cautions but no evidence of malicious behavior.

Install only if you want an agent or CLI to change OpenClaw timeout settings. Use --dry-run first, prefer --no-restart when you do not want the gateway interrupted, and be aware that the current writer should be hardened to preserve config file permissions on multi-user systems.

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/set_timeout.py:116
Finding

Atomic Configuration Replacement Does Not Preserve Restrictive File Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/set_timeout.py, lines 116–124
Vulnerability Type: Unsafe temporary-file permissions and loss of destination permission mode
Risk Level: Medium

Vulnerable Code

python
def write_config(path: Path, config: Dict) -> bool:
    try:
        # Atomic write: temp file + rename
        tmp = path.with_suffix(path.suffix + ".tmp")
        with open(tmp, "w", encoding="utf-8") as f:
            json.dump(config, f, indent=2, ensure_ascii=False)
            f.write("\n")
        os.replace(tmp, path)
        return True
    except Exception as e:
        print(f"❌ Failed to write config: {e}", file=sys.stderr)
        return False

Technical Analysis

The implementation serializes the complete OpenClaw configuration into a predictably named temporary file using open(tmp, "w"). The temporary file's mode is determined by the process umask rather than inherited from the original configuration. The subsequent os.replace(tmp, path) installs the temporary file—including its independently assigned permission mode—as the live configuration.

Consequently, an original configuration restricted to its owner, such as mode 0600, can become mode 0644 under a common 0022 umask. The temporary copy may also be readable by other local users while it exists. Although the skill only modifies timeout fields, it reads and rewrites the entire JSON document, which may contain unrelated sensitive OpenClaw settings.

The predictable <config>.tmp path also lacks the collision resistance of a securely created temporary file. This increases robustness concerns when concurrent invocations occur, although exploitation through link manipulation depends on directory permissions and the victim's local environment.

Attack Path

  1. A user has an OpenClaw configuration file with restrictive permissions, such as 0600, and the file contains sensitive settings.
  2. The user invokes the skill to apply a timeout profil ...[truncated 1155 chars]
Remediation
View remediation

Remediation Suggestions

  1. Obtain the original file's mode before writing and explicitly apply it to the replacement file.
  2. Create the temporary file securely and exclusively in the destination directory, initially using mode 0600. A random temporary name created through tempfile.mkstemp(dir=path.parent) avoids predictable-name collisions.
  3. After serialization, flush Python buffers and call os.fsync() on the temporary file before replacement.
  4. Apply the original permission mode with os.fchmod() before installing the file. If ownership preservation is required and permitted, verify and preserve ownership as well.
  5. Atomically replace the destination only after all writes and metadata operations succeed.
  6. Remove the temporary file in a finally block when any operation fails.
  7. Consider fsync() on the parent directory after os.replace() where crash durability is required.
  8. Add an automated test that begins with a 0600 configuration, performs an update, and verifies that the resulting file remains 0600.

A hardened implementation should follow this sequence:

python
import os
import stat
import tempfile

original_mode = stat.S_IMODE(path.stat().st_mode)
fd, tmp_name = tempfile.mkstemp(prefix=f".{path.name}.", dir=path.parent)

try:
    with os.fdopen(fd, "w", encoding="utf-8") as f:
        json.dump(config, f, indent=2, ensure_ascii=False)
        f.write("\n")
        f.flush()
        os.fsync(f.fileno())
        os.fchmod(f.fileno(), original_mode)

    os.replace(tmp_name, path)
finally:
    try:
        os.unlink(tmp_name)
    except FileNotFoundError:
        pass
Vulnerability Patterns
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (5)

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger phrases include broad terms like configure timeout and openclaw timeout, which are likely to appear in ordinary troubleshooting conversation. In an agent skill, overly broad activation can cause the skill to run unexpectedly and modify local configuration, potentially writing files and restarting services when the user only intended to discuss timeouts.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill explicitly instructs users to read environment variables, read and write a configuration file, and invoke a shell command (openclaw gateway restart), but it does not declare any tool scope such as permissions or allowed-tools. That creates unnecessary ambient authority: an agent runtime may permit broader file, env, or shell access than this skill actually needs, increasing the blast radius if the skill is modified, misused, or invoked in an unexpected context.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · scripts/set_timeout.py (reported line 18)May include surrounding context.

python
patient   "Patient"   — 300s / 3h / 3h    long-running tasks, big codebases

Safety:
  - Auto-backup of the config file to <config>.bak.<YYYYMMDD-HHMMSS> before write
  - Default: triggers `openclaw gateway restart` after a successful write.
    Pass `--no-restart` if you want to restart manually later.
  - `--dry-run` previews diffs without writing anything.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/set_timeout.py (reported line 137)May include surrounding context.

python
def gateway_restart() -> bool:
    """Trigger `openclaw gateway restart`. Returns True on success."""
    try:
        result = subprocess.run(
            ["openclaw", "gateway", "restart"],
            capture_output=True, text=True, timeout=60,
        )