T09 · Insecure Skill Coding Practices
- Location
scripts/alchemy.sh:7- Finding
Shared Credential File Is Executed as Shell Code
- Content
View full analysis
Vulnerability Details
File Location:
scripts/alchemy.sh:7-8
Vulnerability Type: Unsafe sourcing of a shared credential file
Risk Level: MediumVulnerable Code
bash # Load environment [ -f "$HOME/.openclaw/.env" ] && source "$HOME/.openclaw/.env"Technical Analysis
The script uses the Bash
sourcecommand to load~/.openclaw/.env. Contrary to parsing a data-only environment file,sourceexecutes the entire file as shell code in the current process. Any command substitution, function definition, redirection, or arbitrary command present in that file therefore runs whenever the Alchemy CLI is invoked.The Skill only needs the
ALCHEMY_API_KEYand optionalALCHEMY_CHAINvalues. Executing all content in a shared file exceeds the minimum privileges necessary for that purpose and creates a local trust-boundary violation. The risk is heightened because the path is shared across OpenClaw components rather than being a dedicated, strictly validated configuration file for this Skill.Exploitation requires an attacker, compromised Skill, or other local process to gain write access to
~/.openclaw/.env. The code does not itself grant such access, so this is not an independent remote-code-execution vulnerability.Attack Path
-
A malicious or compromised local component obtains write access to
~/.openclaw/.env. -
It inserts a shell payload, for example:
bash ALCHEMY_API_KEY=expected_value arbitrary_attacker_command -
A user or Agent invokes
scripts/alchemy.sh. -
Line 8 sources the complete file.
-
The injected command executes with the same OS identity, environment, filesystem access, and network permissions as the invoking Agent or user.
Impact Assessment
Successful exploitation permits arbitrary command execution under the account running the Skill. The attacker could access files available to that account, read environment variables, alter workspace data, initiate network requests, or ...[truncated 471 chars]
-
- Remediation
View remediation
Remediation Suggestions
-
Prefer requiring
ALCHEMY_API_KEYandALCHEMY_CHAINto be supplied through the process environment. Remove automatic sourcing entirely:bash API_KEY="${ALCHEMY_API_KEY:-}" CHAIN="${ALCHEMY_CHAIN:-eth-mainnet}" -
If file-based configuration is required, use a dedicated Skill-specific file rather than a shared OpenClaw environment file.
-
Parse only explicitly allowlisted keys as data. Do not use
source,eval, or command substitution while parsing configuration. -
Validate
ALCHEMY_CHAINagainst a strict allowlist before constructing an endpoint hostname. -
Verify that any configuration file is owned by the current user, is not a symbolic link, and has restrictive permissions such as mode
0600. Refuse to load it if these checks fail. -
Update
SKILL.md:35-41and the error atscripts/alchemy.sh:64so documentation no longer recommends an executable shared.envfile. Document restrictive permissions and API-key rotation procedures.
-
