T09 · Insecure Skill Coding Practices
- Location
scripts/router.py:155- Finding
Model Switching and Rollback Are Reported but Never Executed
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a query classifier/router, but its claimed switching, rollback, and locking protections do not match the implementation and it retains prompt text in local logs.
Review carefully before installing. Treat this as a recommendation/classification tool, not a reliable model switcher with rollback. Avoid routing secrets or private data through it unless audit logging is disabled or changed, because prompt prefixes are saved locally in plaintext.
scripts/router.py:155Model Switching and Rollback Are Reported but Never Executed
scripts/router.py:32File Lock Is Released Before the Protected Routing Operation
scripts/router.py:49Raw User Query Content Is Persisted in Plaintext Audit Logs
The documentation claims safety controls like lock protection, verify-after-switch, rollback, and audit logs, but the supplied skill content does not substantiate that those protections are actually implemented. This can mislead users and integrators into trusting a routing or model-switch workflow as safe and atomic when it may only classify or recommend actions, increasing the chance of unsafe automation, failed rollbacks, or untracked model changes.
The router claims to perform switching, verification, and rollback, but never actually executes any model-change operation before reporting success-like states. This can mislead operators and downstream automation into believing safety controls were enforced when no switch or rollback occurred, creating a dangerous false sense of protection and potentially routing sensitive work to the wrong model.
The code's comments and user-facing messages state that a switch and rollback occur, but the logic only logs and returns status objects without performing either operation. In a routing/safety skill, deceptive operational semantics are security-relevant because users may rely on rollback and verification guarantees that do not exist during failures or model mismatches.
The skill advertises and invokes scripts that can perform shell execution, file access, logging, and model-switching behavior, yet the skill manifest declares no explicit tool scope or allowed-tools. That creates an authorization and review gap: operators cannot easily constrain what the skill is permitted to do, and downstream systems may execute it with broader privileges than intended.
The skill includes broad invocation phrases such as 'route this query', 'classify this', and 'which model should I use', which can cause unintended activation in ordinary conversation. In a routing skill, accidental invocation is especially relevant because it may trigger model-selection logic or follow-on automation for benign user text that was not meant as a command.
Code issues a request to a loopback, link-local, or private-range host. This can reach internal services not meant to be exposed and is a common SSRF pivot.
return _AVAILABLE_MODELS
try:
import urllib.request
req = urllib.request.Request("http://localhost:11434/api/tags")
with urllib.request.urlopen(req, timeout=5) as resp:
data = json.loads(resp.read())
_AVAILABLE_MODELS = [m["name"] for m in data.get("models", [])]
The manifest describes a unified query router with operational safety features around switching and logging. In this file, the core classify function only scores content type/complexity and returns a recommended model; there is no lock handling, verification after model switch, rollback logic, or audit log generation anywhere in the implementation shown.
The audit logger writes a portion of the user query to disk without any consent, redaction, or sensitivity filtering. Because routed queries may contain secrets, personal data, source code, or internal prompts, this creates a local data exposure risk through log files, especially in shared environments or when logs are collected centrally.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def get_current_model() -> str:
"""Get currently active model."""
try:
result = subprocess.run(
["openclaw", "status", "--json"],
capture_output=True, text=True, timeout=10
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
"""
try:
# Check via openclaw status
result = subprocess.run(
["openclaw", "status", "--json"],
capture_output=True, text=True, timeout=timeout
)
The documentation claims a specific set of prefix shortcuts as part of the merged routing approach. In the code, only aliases listed under PREFIX_MAP are expanded via ALIAS_TO_PREFIX, and '@q' and '@cl' have empty alias lists, so the docstring's grouped wording is misleading about what is implemented as alias-based shorthand.
The code performs an HTTP request to a local service at http://localhost:11434/api/tags to discover available models, but there is no print/log message, confirmation, or nearby comment/docstring warning that the skill makes a network call. For code files, outbound or network operations that transmit system or user context should include some visible disclosure unless clearly covered elsewhere in the skill description, which is not shown here.