T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:199
- Finding
- Unsafe Bulk Import of Environment Variables<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:199` **Vulnerability Type**: Unsafe shell-based environment-file parsing and excessive secret propagation **Risk Level**: Medium ### Vulnerable Code ```bash export $(grep -v '^#' ~/.clawdbot/.env | xargs) && npx mcporter list ``` ### Technical Analysis The troubleshooting command parses the entire `~/.clawdbot/.env` file using `grep`, `xargs`, shell expansion, and word splitting. This is not a reliable `.env` parser and does not limit access to the single variable required by the Skill, `WINDSOR_API_KEY`. Values containing spaces, quotes, wildcard characters, malformed assignments, or option-like tokens may be transformed unexpectedly. More importantly, every assignment in the file is exported to `mcporter`, including unrelated credentials or configuration values. Any process executed by `npx` or `mcporter` inherits those variables. This exceeds least privilege because the declared functionality requires only `WINDSOR_API_KEY`, not every secret stored in the Clawdbot environment file. ### Attack Path 1. Another application, tool, or attacker with write access adds malicious or sensitive entries to `~/.clawdbot/.env`. 2. The user follows the documented troubleshooting instruction. 3. `grep` and `xargs` transform the file contents into shell words without applying proper `.env` parsing rules. 4. The shell exports all resulting assignments, not only `WINDSOR_API_KEY`. 5. `npx` starts `mcporter` with the expanded environment. 6. A compromised, replaced, or vulnerable dependency can read unrelated inherited credentials or use attacker-controlled environment configuration. This command does not, by itself, cause shell syntax embedded in the file to be recursively evaluated as arbitrary commands. The primary risks are unsafe parsing, unintended variable alteration, and unnecessary propagation of secrets. ### Impact Assessment The issue operates with the privileges of the user running the comma ...[truncated 502 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Remove the bulk-export command and load only the required variable with a parser that understands the environment-file format. Recommended hardening measures: 1. Prefer a system keychain or dedicated secrets manager. 2. If a file must be used, create it with restrictive permissions before writing: ```bash mkdir -p ~/.clawdbot touch ~/.clawdbot/.env chmod 600 ~/.clawdbot/.env ``` 3. Retrieve only `WINDSOR_API_KEY`, validate that it is non-empty, and pass only that variable to the process. 4. Do not use `export $(...)`, `xargs`, or equivalent shell word splitting to parse `.env` files. 5. Avoid inheriting unrelated environment secrets when launching third-party tools. 6. Use a trusted environment-file library or the platform's native secrets integration if automated loading is required. ]]>
