Back to skill

Security audit

OpenClaw Session Reply Debug & Model Fallback

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly purpose-aligned, but it can persistently change OpenClaw model configuration and send API credentials to whatever provider endpoint is configured, so users should review it before installing.

Install only if you are comfortable letting the skill read OpenClaw session/config/log files, call configured provider APIs, and modify persistent OpenClaw model settings. Prefer dry-run first, review the exact files and selected endpoint, use trusted HTTPS provider base URLs, avoid sharing diagnostic output that may expose provider settings, and be cautious before wiring --apply into heartbeat or cron automation.

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

Error
Location
scripts/switch-model-with-fallback.js:229
Finding
Provider API Credential Sent to an Unvalidated Configurable Endpoint## Vulnerability Details **File Location**: `scripts/switch-model-with-fallback.js:229-240` **Additional Locations**: `openclaw-model-connectivity-test.md:50-56`, `openclaw-model-connectivity-test.md:181-187` **Vulnerability Type**: Credential disclosure through an unvalidated network destination **Risk Level**: High ### Vulnerable Code ```js const response = await fetch(`${providerConfig.baseUrl}/chat/completions`, { method: "POST", headers: { Authorization: `Bearer ${providerConfig.apiKey}`, "Content-Type": "application/json", }, body: JSON.stringify({ model, messages: [{ role: "user", content: "reply with OK" }], max_tokens: 8, }), signal: controller.signal, }); ``` The mandatory connectivity runbook documents the same behavior: ```js fetch(`${p.baseUrl}/chat/completions`,{ method:"POST", headers:{Authorization:`Bearer ${p.apiKey}`,"Content-Type":"application/json"}, body:JSON.stringify({ model, messages:[{role:"user",content:"reply with OK"}], max_tokens:8 }) }) ``` ### Technical Analysis The fallback script loads `baseUrl` and `apiKey` from the local OpenClaw configuration and sends the reusable API credential as an HTTP Bearer token to the configured endpoint. The code checks only that these values exist. It does not enforce HTTPS, verify the endpoint hostname against an approved provider list, restrict ports, reject local or private-network destinations, or establish an explicit trust decision for custom gateways. An authenticated provider probe is relevant to the Skill's model-connectivity functionality. However, forwarding a reusable credential to any configurable URL is broader than the minimum privilege necessary. Destination validation is required because configuration is data, not a sufficient security boundary. If the configuration is maliciously or accidentally changed, the probe becomes a credential-disclosure mechani ...[truncated 1982 chars]
Remediation
## Remediation Suggestions 1. Parse the configured destination with the standard `URL` class and reject malformed URLs. 2. Require `https:` for all remote provider endpoints. Permit plaintext HTTP only through an explicit, separately named development override that displays a prominent warning. 3. Maintain an explicit allowlist of approved provider hostnames and ports. If custom gateways are supported, require an affirmative option such as `--allow-custom-endpoint` rather than trusting configuration implicitly. 4. Resolve the hostname and reject loopback, link-local, private, multicast, and other special-purpose addresses unless local gateways are an explicitly supported and confirmed use case. 5. Disable automatic redirects for authenticated probes with `redirect: "error"`, or independently validate every redirect destination before forwarding credentials. 6. Reject URLs containing embedded usernames or passwords and normalize the URL before validation to prevent parser-confusion and hostname-bypass techniques. 7. Use a narrowly scoped, probe-only credential where the provider supports one. Avoid exposing a broadly privileged production key to routine heartbeat checks. 8. Separate endpoint configuration from credential storage where possible, and apply restrictive filesystem permissions to the credential source. 9. Update `openclaw-model-connectivity-test.md` to use the same hardened validation helper rather than duplicating an unrestricted authenticated `fetch`. 10. Log only the validated origin and model identifier. Never print the API key, Authorization header, or full configuration object. 11. Add tests covering HTTP rejection, unapproved hosts, private IP addresses, embedded credentials, unusual ports, redirects, and approved custom-gateway behavior.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
This mismatch is especially risky because the skill presents itself as an operational safety workflow while reportedly lacking background recovery logic and directly editing multiple OpenClaw config/session files without declared permissions. In practice, that can mislead users into invoking a broad, state-mutating procedure under the assumption that it is controlled and self-validating, increasing the likelihood of configuration corruption, downtime, or accidental persistence of a bad model selection.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This mismatch is especially risky because the skill presents itself as an operational safety workflow while reportedly lacking background recovery logic and directly editing multiple OpenClaw config/session files without declared permissions. In practice, that can mislead users into invoking a broad, state-mutating procedure under the assumption that it is controlled and self-validating, increasing the likelihood of configuration corruption, downtime, or accidental persistence of a bad model selection.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
The README encourages users to invoke model-switching commands that rewrite configuration and session references, but the tutorial flow does not clearly warn that these changes are persistent and can affect future sessions. In an agent-skill context, that omission can cause users or downstream automation to unintentionally alter long-lived runtime state, leading to misconfiguration, unexpected model usage, or difficult-to-diagnose behavior.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The heartbeat/cron section documents scheduled execution that will repeatedly run a state-changing script, yet it does not prominently warn that active model configuration may be automatically changed over time without interactive confirmation. In a persistent automation context, this increases the risk of unintended repeated reconfiguration, operational instability, and silent switching to alternate models with different cost, behavior, or compliance properties.

Lp3

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding
The skill instructs the agent to run network-relevant model availability probes and invoke scripts that can alter OpenClaw state, but it declares no tool scope or permissions boundary. This creates an authorization gap where a caller may not realize the skill can perform connectivity checks and system changes, increasing the chance of unintended network access or unsafe execution in environments that rely on explicit capability declarations.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The document instructs operators to run a direct provider probe that reads an API key from $HOME/.openclaw/openclaw.json and sends authenticated requests, but it gives no warning about secret handling, logging, shell history, or output capture. While the command does not explicitly print the key, this kind of diagnostic workflow increases the chance of credential exposure through copied configs, debug modifications, terminal recording, or sharing command/output during troubleshooting.

Description-Behavior Mismatch

Medium
Confidence
98% confidence
Finding
The manifest describes diagnosing missing assistant replies, safely switching active model references with primary and multi-fallback support, and heartbeat-triggered recovery to the highest available model. This file instead scans a local OpenClaw directory and rewrites specific model strings from openai/gpt-5.3 to openai/gpt-5.2, with no diagnostic logic, no fallback selection logic, no heartbeat handling, and no recovery to the highest available model.

Intent-Code Divergence

Medium
Confidence
97% confidence
Finding
The file is named switch-model-to-gpt-5.2.js and the help text presents it as that operation, but the implementation treats GPT-5.3 as the current target and replaces it with GPT-5.2. This is an active contradiction in developer-facing intent signals, because the code is not selecting GPT-5.2 generally; it is specifically downgrading GPT-5.3 references.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
This code writes modified JSON back to configuration files and creates backup files when `--apply` is used. Although the script logs what it did, there is no interactive confirmation or in-code warning immediately before the irreversible file modifications, which is a safety-relevant operation affecting user configuration data.

Static analysis

No suspicious patterns detected.