T09 · Insecure Skill Coding Practices
- Location
claw-config.py:546- Finding
Unrestricted Documentation URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is mostly coherent, but it gives agents persistent configuration-changing power and has under-scoped URL fetching and patch-guard weaknesses that users should review before installing.
Install only if you are comfortable giving this skill persistent access to inspect and modify OpenClaw configuration. Before using `apply`, require human review of the patch, avoid `--force-shared` unless an operator explicitly approves it, and do not pass full URLs to `docs`; use only known OpenClaw documentation slugs until the URL allowlist, cache path containment, and array-replacement guard are fixed.
claw-config.py:546Unrestricted Documentation URL Fetching Enables Server-Side Request Forgery
claw-config.py:439URL-Derived Cache Path Traversal Enables Writes Outside the Documentation Cache
claw-config.py:190Cross-Agent Protection Can Be Bypassed Through Destructive Array Replacement
SKILL.md:49Untrusted Remote Documentation Can Influence Security-Sensitive Agent Actions
This skill is explicitly designed to let an agent modify its own persistent OpenClaw configuration, which is a real self-modification capability. Even with documented guardrails, this is security-sensitive because a compromised or misaligned agent could use the feature to alter command dispatch, bindings, or other persistent behavior and potentially degrade controls or entrench persistence.
# claw-config
Shared skill for the OpenClaw self-hosted agent gateway that lets any single agent safely self-diagnose and self-modify its own slice of `~/.openclaw/openclaw.json` without hallucinating field names, identity, or paths.
Python 3 · stdlib only · MIT
The declared purpose is a bounded self-diagnosis/config utility, but the observed behavior includes installation into the user's skills directory, PATH persistence via symlink, and preflight/environment manipulation that are not clearly disclosed by the top-level contract. Description-behavior drift is dangerous because operators and calling agents may trust the skill for narrow config inspection while it performs broader persistent system modifications.
The installation instructions place the skill in a shared auto-discovered skills directory and symlink it onto the user's PATH, creating durable session persistence for all agents on the host. This increases risk because any future compromise, prompt injection, or unintended invocation can repeatedly access the installed capability without additional user review.
cd claw-config
# install into your shared OpenClaw skills directory (auto-discovered by every agent)
mkdir -p ~/.openclaw/skills/claw-config
cp SKILL.md claw-config.py ~/.openclaw/skills/claw-config/
chmod +x ~/.openclaw/skills/claw-config/claw-config.py
The skill advertises shell, environment, file-read, and file-write capabilities but does not declare any explicit tool scope such as permissions or allowed-tools. That creates an over-privileged execution surface where a caller or downstream agent may invoke destructive operations like config writes, backups, symlink creation, or network-backed docs fetches without a clearly constrained policy boundary.
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.
> *"Who am I, what does my own config look like, and how do I change it safely?"*
**Design principle: no hallucination.** Every field name, every JSON pointer, every current value is read from the installed `openclaw` CLI at call time (`openclaw config schema`, `openclaw config get`). Every write goes through `openclaw config patch` (which validates against the schema internally). When the agent needs to know what a field *does*, the skill fetches the official documentation from `docs.openclaw.ai` (Mintlify `.md` raw + full-content index `llms-full.txt`) — never the model's training memory.
**Comparison with `openclaw doctor`**: `doctor` is a system-wide health check (gateway / secrets / channels), human-readable output. `claw-config` is **agent-scoped** (sliced by `$OPENCLAW_AGENT_ID` — only sees the caller's own config) and supports `--json` for downstream tooling. They are complementary, not duplicates.
The module docstring states that identity verification makes wrong-agent writes impossible by construction, but later code allows patching shared/non-self sections such as agents.defaults, gateway, secrets, auth, and similar paths when --force-shared is used. That is an active contradiction between the documented safety guarantee and the implemented write behavior.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def ocw(*args, stdin=None, check=True, timeout=60):
"""Run `openclaw <args>`. Return (stdout, stderr, rc)."""
try:
p = subprocess.run(
[OPENCLAW, *args],
input=stdin,
capture_output=True,
Although curl is invoked without a shell, this still creates an outbound fetch primitive over attacker-influenced input (url). In a skill intended to retrieve only official docs, this can be abused for SSRF-like access to internal services, metadata endpoints, or unintended egress to arbitrary hosts.
raise RuntimeError(f"docs fetch disabled in cron and no cached copy at {cache_file}")
try:
p = subprocess.run(
["curl", "-fsSL", "--max-time", "10", url],
capture_output=True, text=True, timeout=12,
)
The docs command accepts any full http:// or https:// URL, contradicting the stated trust boundary that it only fetches official documentation. This widens the skill from a bounded documentation reader into a generic network retrieval tool, enabling data exfiltration paths and access to sensitive internal endpoints if the environment has network reachability.
This code exposes a general outbound network capability through the ostensibly harmless docs interface. In agent skill context, that is more dangerous than in ordinary CLI tooling because another agent may be induced to use it as a proxy to reach attacker-chosen destinations, bypassing intended capability scoping.