Back to skill

Security audit

Aemet

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent AEMET weather skill, but it needs review because its municipality search builds unsafe jq programs from user input while also handling a local API key.

Install only if you are comfortable with a local shell script that reads an AEMET API key from ~/.openclaw/credentials and makes HTTPS requests to AEMET. Review the sudo dependency commands first, and avoid passing untrusted or generated municipality search strings until the jq interpolation is fixed.

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 (3)

T09 · Insecure Skill Coding Practices

Warning
Location
aemet.sh:133
Finding

User-Controlled jq Program Injection in Municipality Lookup

Content
View full analysis
/dev/null | head -1) if [[ -n "$result" ]]; then echo "$result" | cut -d':' -f1 return fi ``` ### Technical Analysis The user-controlled `query` value is interpolated directly into a jq program enclosed in a shell double-quoted string. The value is therefore treated as jq source code rather than as data. An attacker can include quotation marks, jq operators, and a jq comment marker to terminate the intended `test()` expression and inject a different pipeline. jq provides built-ins such as `env`, which exposes the executing process's environment variables. This is jq expression injection rather than shell command injection: the attacker cannot directly execute arbitrary operating-system commands through jq, but can alter jq processing, read accessible data exposed by jq built-ins, manipulate lookup results, or consume excessive resources. ### Attack Path 1. An attacker supplies a crafted municipality name to the forecast command. 2. `get_municipio_code` stores the attacker-controlled argument in `query`. 3. The script inserts `query` directly into the jq source expression. 4. The crafted value closes the intended regular expression and appends attacker-selected jq filters. 5. The injected jq expression executes with the environment and file access already available to the Skill process. 6. Results can influence municipality selection or expose environment-derived information through command output. For example, a payload using a jq comment marker can terminate the fixed remainder of the expression after inserting another jq pipeline. Exploitation does not require shell metacharacter interpretation because the vulnerabl ...[truncated 639 chars]
Remediation
View remediation
/dev/null | head -1) ``` Additional hardening should include: 1. Restrict municipality-query length to a reasonable maximum. 2. If regular-expression behavior is unnecessary, use a literal case-insensitive comparison instead of `test()`. 3. Handle invalid regular expressions explicitly if regex search remains supported. 4. Run the Skill with a minimal environment so unrelated credentials are not exposed to child processes. 5. Add regression tests containing quotation marks, jq operators, comment markers, and malformed regular expressions. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
aemet.sh:298
Finding

User-Controlled jq Program Injection in Municipality Search

Content
View full analysis
/dev/null) else results=$(jq -r ".[] | select(.nombre | test(\"$query\"; \"i\")) | \"📍 \(.nombre) (\(.provincia)) - CP: \(.codigoPostal) - ID: \(.id)\"" "$municipios_cache" 2>/dev/null | head -10) fi ``` ### Technical Analysis For non-postal-code searches, `query` is embedded directly in the jq program passed to `jq -r`. Escaping performed by shell quoting does not make this safe because the input is deliberately placed inside jq syntax. A malicious query can close the string passed to `test()`, introduce additional jq filters, and comment out the remaining fixed expression. This permits execution of attacker-selected jq expressions. In particular, jq's environment built-ins can expose process environment variables to standard output. The numeric branch is constrained by the five-digit validation and is not practically injectable through `query`; the vulnerable path is the nonnumeric `else` branch. ### Attack Path 1. An attacker causes the Skill to run `buscar` with a crafted nonnumeric search argument. 2. The argument passes into `show_buscar` as `query`. 3. The script concatenates it into the jq source program. 4. The payload terminates the intended `test()` call and inserts an alternate jq pipeline. 5. jq evaluates the injected expression under the Skill process's security context. 6. Environment data or manipulated output is printed as search results. A representative payload structure is: ```text x"; "i")) | env # ``` The exact behavior depends on the surrounding generated jq expression, but the quotation marks terminate the intended string and `#` commen ...[truncated 514 chars]
Remediation
View remediation
/dev/null) else results=$(jq -r --arg query "$query" \ '.[] | select(.nombre | test($query; "i")) | "📍 \(.nombre) (\(.provincia)) - CP: \(.codigoPostal) - ID: \(.id)"' \ "$municipios_cache" 2>/dev/null | head -10) fi ``` Further hardening: 1. Enforce a maximum input length. 2. Prefer literal substring matching if regular expressions are not required. 3. Reject or safely handle malformed regular expressions. 4. Keep sensitive credentials out of the parent process environment. 5. Add tests proving that jq syntax and comment markers are handled only as input data. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
aemet.sh:22
Finding

AEMET API Key Exposed Through curl Process Arguments

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
Findings (11)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill description, usage examples, and troubleshooting guidance are entirely in Spanish, including command vocabulary such as 'alertas', 'pronóstico', and 'buscar'. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale constraint is explicitly documented and justified; this README does not clearly state that the skill is Spanish-only or region-restricted by design.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · README.md (reported line 19)May include surrounding context.

bash
# Instalar dependencias
sudo apt update
sudo apt install -y curl jq libxml2-utils

# Configurar API key (gratuita)

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · README.md (reported line 20)May include surrounding context.

bash
# Instalar dependencias
sudo apt update
sudo apt install -y curl jq libxml2-utils

# Configurar API key (gratuita)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill documentation instructs users to run a shell script and install system packages, but the manifest declares no tool scope or allowed-tools restrictions. That mismatch weakens least-privilege controls and can cause the skill to be executed with broader shell capability than is explicitly disclosed or reviewed.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 23)May include surrounding context.

bash
echo "TU_CLAVE_AQUI" > ~/.openclaw/credentials/aemet-api-key.txt
chmod 600 ~/.openclaw/credentials/aemet-api-key.txt

2. Dependencias del sistema

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
76% confidence
Finding

The skill directs users to run 'sudo apt update', which requires elevated privileges. In a skill context, asking for root-capable commands increases risk because a user may execute them without separately validating necessity, and any future modification to installation steps could affect the whole system.

Content

Scanner excerpt · SKILL.md (reported line 29)May include surrounding context.

2. Dependencias del sistema

bash
sudo apt update
sudo apt install -y curl jq libxml2-utils coreutils

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

The documented command 'sudo apt install -y curl jq libxml2-utils coreutils' performs package installation as root. Even though these are common packages, normalizing root execution inside a skill expands the blast radius if the instructions are copied blindly or later altered, and '-y' further reduces user scrutiny.

Content

Scanner excerpt · SKILL.md (reported line 30)May include surrounding context.

bash
sudo apt update
sudo apt install -y curl jq libxml2-utils coreutils
  • curl — peticiones HTTP a la API de AEMET

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The manifest says the skill provides weather alerts and forecasts from AEMET, but the code additionally accesses a local file under $HOME/.openclaw/credentials to obtain an API key. While network access is expected for this purpose, direct filesystem reads of user-scoped credential material are a separate capability not disclosed in the stated purpose.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script's user-facing strings, usage text, and command names are consistently in Spanish, including required invocation terms like 'alertas', 'pronóstico', and 'buscar'. This imposes a specific language/locale on all users without opt-in or justification, which matches the natural-language locale policy violation criteria.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The help banner states "Consulta alertas meteorológicas," which narrows the apparent intent to alerts only. Elsewhere in the code, the skill clearly supports forecast retrieval, municipality lookup, and API connectivity tests, so the inline documentation understates and contradicts actual behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The package description states the skill provides AEMET OpenData forecasts "para España," indicating a Spain-specific locale constraint. In this manifest, there is no accompanying note that the skill is region-specific by design or that users can choose another locale, so the description reads as a fixed locale limitation without explicit opt-in.

Content

No source excerpt is available for this finding.