T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/apollo-config.sh:7
- Finding
- Executable Configuration File Allows Arbitrary Shell Command Execution## Vulnerability Details **File Location**: `scripts/apollo-config.sh`, lines 7–12 **Vulnerability Type**: Unsafe shell configuration loading **Risk Level**: High **Vulnerable Code**: ```bash CONFIG_FILE="/Users/jhumanj/clawd/config/apollo.env" if [ -f "$CONFIG_FILE" ]; then # shellcheck disable=SC1090 source "$CONFIG_FILE" fi ``` ### Technical Analysis The script loads `apollo.env` with Bash's `source` built-in. Although the file is presented as an environment configuration file, `source` interprets its entire contents as executable shell code. Command substitutions, function declarations, commands, redirections, and other shell constructs in the file therefore execute with the privileges of the user invoking any Apollo helper. The configuration path is also a fixed, developer-specific absolute path. This conflicts with the documentation in `SKILL.md`, which tells users to create `config/apollo.env`, and may cause the script to load an unexpected file outside the project directory. ### Attack Path 1. An attacker obtains write access to `/Users/jhumanj/clawd/config/apollo.env`, replaces it, or causes a malicious file to exist at that fixed path. 2. The attacker inserts executable shell content, such as a command substitution or an ordinary shell command. 3. The user invokes `apollo-get.sh` or `apollo-post.sh`. 4. The helper sources `apollo-config.sh`. 5. `apollo-config.sh` sources the attacker-controlled environment file. 6. The injected commands execute as the invoking user before the Apollo request is made. ### Impact Assessment Successful exploitation provides arbitrary command execution under the invoking user's account. The attacker could read or modify files accessible to that user, steal environment variables and API credentials, alter project content, or execute additional local programs. This code does not itself elevate privileges, so the scope remains bounded by the user's existing permissions ...[truncated 1 chars]
- Remediation
- ## Remediation Suggestions - Do not use `source` to parse a data-only configuration file. - Resolve the configuration file relative to the project directory, or accept an explicit path from a trusted invocation parameter. - Parse only an allowlist of keys, such as `APOLLO_BASE_URL` and `APOLLO_API_KEY`, using a non-executing parser. - Reject shell metacharacters, command substitutions, unknown keys, malformed records, duplicate keys, and multiline values. - Verify that the file is a regular file, is owned by the expected user, and is not group- or world-writable. - Recommend restrictive permissions such as `0600`. - Prefer process environment variables or a dedicated secrets manager where available.
