T09 · Insecure Skill Coding Practices
- Location
SKILL.md:14- Finding
Unsafe Execution of a Shared Environment File for Credential Loading
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:14-16; duplicated inreferences/api-key.md:3-8
Vulnerability Type: Unsafe shell sourcing and excessive credential scope
Risk Level: MediumVulnerable Code
SKILL.md:14-16:bash source ~/.openclaw/workspace/.env # loads A2E_KEYreferences/api-key.md:3-8:markdown The API key is stored in `~/.openclaw/workspace/.env` as `A2E_KEY`. Load it before using the a2e.sh script or curl commands: ```bash source ~/.openclaw/workspace/.envtext ### Technical Analysis The documented initialization procedure uses the shell `source` command to load one required credential from a shared workspace file. `source` does not parse the file as passive configuration; it executes every statement in the file in the context of the current shell. The Skill declares only `A2E_KEY` as required, but this procedure loads all variables and executes all commands contained in `~/.openclaw/workspace/.env`. If the file contains credentials for unrelated services, those values become available in the current shell and may be inherited by subsequently invoked processes. This exceeds the minimum credential scope needed for the declared A2E API functionality. If another user, Skill, process, or compromised component can modify the shared file, it can insert command substitutions, shell functions, redirections, or arbitrary commands. These execute when a user or Agent follows the documented setup instructions. The executable wrapper itself does not source the file. At `scripts/a2e.sh:6`, it only requires an existing environment variable: ```bash A2E_KEY="${A2E_KEY:?Set A2E_KEY environment variable (source ~/.openclaw/workspace/.env)}"Therefore, exploitation depends on the documented sourcing step and an attacker first obtaining write influence over the shared environment file. No evidence was found that the Skill modifies that file, transmits unrelated ...[truncated 1341 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove all instructions that source the shared workspace
.envfile. - Rely on the Skill runtime to inject only
A2E_KEY, consistent with the existing metadata declaration:yaml requires: env: - A2E_KEY primaryEnv: A2E_KEY - If manual setup is necessary, instruct users to export only the required value:
bash read -rsp "A2E API key: " A2E_KEY export A2E_KEY printf '\n' - If file-backed storage is unavoidable, use a dedicated file containing only the A2E credential, restrict it to the owner with mode
0600, and parse the expected key as data rather than executing the file as shell code. - Do not use
eval, command substitution, orsourcewhen parsing credential files. - Update the error message in
scripts/a2e.sh:6so it no longer recommends sourcing the shared file:bash A2E_KEY="${A2E_KEY:?Set the A2E_KEY environment variable}" - Document credential rotation and ensure the A2E key is scoped to only the API permissions required by this Skill, where supported.
- Remove all instructions that source the shared workspace
