T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/list-all-flows.sh:10
- Finding
- Arbitrary Command Execution Through Sourced Configuration File<![CDATA[ ## Vulnerability Details **File Location**: `scripts/list-all-flows.sh:10-15` **Vulnerability Type**: Unsafe shell evaluation of configuration data **Risk Level**: High ### Vulnerable Code ```bash # Load configuration if [ -f "$SKILL_DIR/config.env" ]; then source "$SKILL_DIR/config.env" else echo "Error: config.env not found in $SKILL_DIR" exit 1 fi ``` ### Technical Analysis The script uses Bash `source` to load `config.env`. This does not merely parse environment variable assignments: it executes the entire file as shell code in the current process. Although the file is intended to contain only `OPEN_C3_URL`, `APP_NAME`, and `APP_KEY`, there is no validation that restricts its contents to those assignments. Any command, command substitution, function definition, redirection, or other valid shell construct placed in `config.env` will execute with the privileges of the user invoking the skill. For example, a malicious configuration file could contain: ```bash APP_KEY="$(sensitive_command)" malicious_command ``` This is a local trust-boundary weakness. Exploitation requires an attacker to create or modify the skill's `config.env`, or to influence how that file is provisioned. ### Attack Path 1. An attacker obtains write access to `config.env`, supplies a malicious replacement, or convinces a user to install a crafted configuration file. 2. The attacker inserts arbitrary shell commands alongside apparently valid configuration assignments. 3. The user invokes `scripts/list-all-flows.sh`. 4. Bash executes `source "$SKILL_DIR/config.env"`. 5. The injected commands run before the Open-C3 API request and inherit the invoking user's permissions and environment. ### Impact Assessment Successful exploitation provides arbitrary command execution with the privileges of the user running the skill. Depending on that user's access, an attacker could: - Read or exfiltrate the Open-C3 application key and other accessible credentials. - Read, ...[truncated 317 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Do not evaluate configuration files as shell programs. 1. Replace `source` with a parser that accepts only an explicit allowlist of keys: - `OPEN_C3_URL` - `APP_NAME` - `APP_KEY` 2. Reject malformed lines, duplicate keys, command substitutions, shell metacharacters, and unexpected variables. 3. Prefer obtaining secrets from a dedicated secret manager or from an already sanitized process environment. 4. Verify that the configuration file is a regular file, is owned by the expected user, and is not writable by group or other users. 5. Recommend restrictive permissions such as `chmod 600 config.env`. 6. Add tests proving that strings such as `$(command)`, backticks, semicolons, and newline-injected commands are treated as data or rejected rather than executed. A safer design is for a non-shell parser to read a strict dotenv format and export only validated values before invoking the script. ]]>
