T09 · Insecure Skill Coding Practices
- Location
scripts/weather-full.sh:6- Finding
Arbitrary Shell Execution Through Unsafe Credential File Sourcing
- Content
View full analysis
Vulnerability Details
File Location:
scripts/weather-full.sh, lines 6-8
Vulnerability Type: Unsafe execution of a credential/configuration file
Risk Level: Mediumbash if [ -f ~/.openclaw/.env ]; then source ~/.openclaw/.env fiTechnical Analysis
The script uses Bash
sourceto load~/.openclaw/.env. Thesourcecommand does not treat the file as passive configuration: it parses and executes its entire contents as shell code in the current process.The Skill only requires the
WEATHERAPI_KEYandSUNSETHUE_KEYvalues. Executing every statement in a shared credential file therefore exceeds the minimum access and behavior necessary for the declared weather-query functionality. An unsafe file could contain command substitutions, function calls, redirections, environment changes, or arbitrary commands, for example:bash WEATHERAPI_KEY="$(arbitrary_command)"No malicious content was observed in the audited project. Exploitation depends on another user, process, or component being able to create or modify
~/.openclaw/.env.Attack Path
- An attacker or compromised local component gains the ability to create or modify
~/.openclaw/.env. - The attacker adds a shell command or command substitution to that file.
- A user or agent invokes
scripts/weather-full.sh. - Lines 6-8 load the file through
source. - Bash executes the injected statement with the identity and permissions of the user running the Skill.
- The injected code can access resources available to that user and can alter the remainder of the script's execution.
Impact Assessment
Successful exploitation provides arbitrary command execution under the account running the Skill. The resulting code could read or modify user-accessible files, expose environment variables and credentials, issue unauthorized network requests, or manipulate weather-query results.
This behavior does not independently elevate operating-system privileges. Its scop ...[truncated 209 chars]
- An attacker or compromised local component gains the ability to create or modify
- Remediation
View remediation
Remediation Suggestions
- Remove automatic sourcing of
~/.openclaw/.env. - Prefer requiring the two API keys to be supplied through the inherited process environment:
bash : "${WEATHERAPI_KEY:?WEATHERAPI_KEY is required}" : "${SUNSETHUE_KEY:?SUNSETHUE_KEY is required}"- If file-based configuration is unavoidable, use a non-executing parser that accepts only the exact expected keys and rejects shell syntax, command substitutions, duplicate assignments, and unexpected variables.
- Store Skill-specific credentials in a dedicated file rather than loading a shared OpenClaw environment file.
- Verify that any credential file is owned by the invoking user, is not a symbolic link, and has restrictive permissions such as mode
0600. - Where the external APIs support it, transmit credentials in authorization headers rather than URL query parameters to reduce exposure through process listings and URL logs.
- Avoid printing credential values in errors, debugging output, or command traces.
- Remove automatic sourcing of
