T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/weather-full.sh:6
- Finding
- Shared credential file is evaluated as executable shell code<![CDATA[ ## Vulnerability Details **File Location**: `scripts/weather-full.sh:6-8` **Additional Location**: `SKILL.md:83,95` **Vulnerability Type**: Overbroad credential loading and unsafe shell evaluation **Risk Level**: Medium ### Vulnerable Code ```bash if [ -f ~/.openclaw/.env ]; then source ~/.openclaw/.env fi ``` The documentation also directs users to evaluate the same shared file: ```bash source ~/.openclaw/.env && curl -s "https://api.weatherapi.com/v1/forecast.json?key=${WEATHERAPI_KEY}&q=Beijing&days=1&lang=zh&aqi=yes" ``` ```bash source ~/.openclaw/.env && curl -s "https://api.sunsethue.com/event?latitude=39.90&longitude=116.41&date=$(date +%Y-%m-%d)&type=sunset&key=${SUNSETHUE_KEY}" ``` ### Technical Analysis The Skill only requires `WEATHERAPI_KEY` and `SUNSETHUE_KEY`, but it uses `source` to evaluate the entire shared `~/.openclaw/.env` file as shell code. This exceeds the minimum access needed for the declared weather functionality. A shell environment file is not treated as passive configuration when sourced. Command substitutions, function definitions, redirections, and arbitrary shell commands in that file execute with the privileges of the user running the Skill. The process also imports unrelated values stored in the shared file, unnecessarily broadening its exposure to credentials that the Skill does not need. The reviewed code does not intentionally transmit those unrelated variables, and no malicious command is currently embedded in the package. Exploitation therefore requires another party or compromised component to gain write access to the shared environment file. ### Attack Path 1. An attacker, compromised Skill, or vulnerable local component obtains write access to `~/.openclaw/.env`. 2. The attacker adds a shell command or command substitution to the file. 3. The user invokes `scripts/weather-full.sh` or follows one of the documented raw commands. 4. Bash evaluates the entire file through `source`. 5. The injecte ...[truncated 571 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not source a shared credential file from the Skill. 2. Require the caller or Skill runtime to provide only `WEATHERAPI_KEY` and `SUNSETHUE_KEY` through a controlled environment. 3. If file-based loading is unavoidable, use a dedicated file containing only these two values and parse it as data rather than shell code. 4. Enforce restrictive file permissions, such as owner read/write access only. 5. Reject unknown variable names and malformed entries. 6. Check that both required values are present before making requests, for example: ```bash : "${WEATHERAPI_KEY:?WEATHERAPI_KEY is required}" : "${SUNSETHUE_KEY:?SUNSETHUE_KEY is required}" ``` 7. Update `SKILL.md` so its examples do not instruct users or agents to source the shared environment file. ]]>
