T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/twenty-config.sh:7
- Finding
- Arbitrary Shell Command Execution Through Sourced Configuration File<![CDATA[ ## Vulnerability Details **File Location**: `scripts/twenty-config.sh:7-11` **Vulnerability Type**: Unsafe execution of configuration as shell code **Risk Level**: High ### Vulnerable Code ```bash CONFIG_FILE="/Users/jhumanj/clawd/config/twenty.env" if [ -f "$CONFIG_FILE" ]; then # shellcheck disable=SC1090 source "$CONFIG_FILE" fi ``` ### Technical Analysis The script uses Bash `source` to load `twenty.env`. This operation does not merely parse environment-variable assignments; it executes the entire file as shell code in the context of the calling process. Consequently, command substitutions, function definitions, redirections, and arbitrary commands placed in the configuration file are executed whenever any REST or GraphQL helper imports `twenty-config.sh`. The file location is also hardcoded outside the project directory and conflicts with the project documentation, which describes `config/twenty.env` as the expected location. This makes configuration provenance and permission management less predictable. ### Attack Path 1. An attacker obtains write access to `/Users/jhumanj/clawd/config/twenty.env`, directly or through another local vulnerability or insecure file permissions. 2. The attacker inserts a shell payload, for example: ```bash TWENTY_BASE_URL=https://crm.example.com TWENTY_API_KEY=example arbitrary_attacker_command ``` 3. The victim invokes any REST or GraphQL helper in the Skill. 4. The helper sources `twenty-config.sh`. 5. Bash sources `twenty.env` and executes the attacker's command with the victim's privileges. ### Impact Assessment Successful exploitation permits arbitrary command execution with the privileges of the user or Agent running the Skill. The attacker could read or modify files accessible to that account, steal the Twenty API key and other credentials, alter CRM requests, or execute additional local programs. The issue does not independently provide elevated operating-system privileges; ...[truncated 68 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not use `source` to read a data-only configuration file. - Parse only an explicit allowlist of keys, such as `TWENTY_BASE_URL` and `TWENTY_API_KEY`. - Reject malformed lines, duplicate keys, command substitutions, shell metacharacters, and unexpected variables. - Use a documented project-relative or explicitly user-configurable path rather than a developer-specific absolute path. - Verify that the configuration file is a regular file, is owned by the expected user, and is not writable by group or other users. - Prefer credentials supplied through a protected process environment or operating-system secret store. A safe implementation can parse each line as data without evaluating it as Bash code. ]]>
