T09 · Insecure Skill Coding Practices
- Location
scripts/generate_daily.sh:13- Finding
Project-local .env file is executed as shell code
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_daily.sh, lines 13-15
Vulnerability Type: Unsafe configuration-file execution
Risk Level: Mediumbash if [ -f "$SKILL_DIR/.env" ]; then source "$SKILL_DIR/.env" fiTechnical Analysis
The wrapper loads
.envwith the Bashsourcecommand. This does not merely parse environment-variable assignments; it executes the entire file as shell code under the identity of the user running the wrapper.The Skill only needs to retrieve
NCBI_EMAILandNCBI_API_KEY. Granting a configuration file arbitrary command-execution capability exceeds that requirement. Shell substitutions, redirections, function definitions, and ordinary commands embedded in.envwill all execute.Attack Path
- An attacker, compromised process, or malicious project distribution obtains the ability to create or modify the project-local
.env. - The attacker inserts shell commands, for example:
bash NCBI_EMAIL=user@example.com NCBI_API_KEY=example malicious_command - The user manually invokes
scripts/generate_daily.sh, or an explicitly configured scheduled workflow invokes it. - Bash executes
malicious_commandwhen processingsource "$SKILL_DIR/.env". - The command runs with the permissions and environment of the invoking user.
Impact Assessment
Successful exploitation provides arbitrary command execution as the user running the Skill. An attacker could read files accessible to that user, access inherited environment variables, steal configured credentials, alter user-owned files, modify OpenClaw configuration, or establish additional user-level persistence.
This flaw does not independently grant root privileges. Exploitation requires the attacker to influence the
.envfile before the wrapper runs. No malicious.envfile was present in the audited project.- An attacker, compromised process, or malicious project distribution obtains the ability to create or modify the project-local
- Remediation
View remediation
Remediation Suggestions
- Do not use
source,., orevalto load a dotenv file. - Parse the file as non-executable data using a maintained dotenv implementation or a strict custom parser.
- Allow only the exact keys
NCBI_EMAILandNCBI_API_KEY. - Reject command substitutions, shell metacharacters, malformed assignments, duplicate keys, and unexpected variable names.
- Verify that the configuration file is a regular file, is owned by the expected user, and is not writable by other users.
- Prefer credentials supplied by the process environment or a dedicated secret manager instead of a project-local plaintext file.
- Run the scheduled workflow with a dedicated, minimally privileged account where practical.
- Do not use
