T09 · Insecure Skill Coding Practices
- Location
alexandrie.sh:12- Finding
Arbitrary Shell Code Execution Through Sourced Credential File
- Content
View full analysis
/dev/null || true PASSWORD="${ALEXANDRIE_PASSWORD:-}" ``` ### Technical Analysis The script uses Bash `source` to obtain a single credential from `/home/eth3rnit3/clawd/.env`. Unlike a data-only configuration parser, `source` evaluates the entire file as shell code in the current process. Consequently, command substitutions, function definitions, redirections, and arbitrary commands placed in the `.env` file execute with the privileges of the user invoking the Skill. This happens before command dispatch, so even non-authentication operations such as `help` trigger evaluation. The declared functionality requires access only to `ALEXANDRIE_PASSWORD`. Executing every statement in a general environment file exceeds that minimum requirement. Sourcing the file may also load unrelated values into the shell, unnecessarily expanding the sensitive-data exposure surface. ### Attack Path 1. An attacker or compromised local process obtains permission to modify or replace `/home/eth3rnit3/clawd/.env`. 2. The attacker adds a shell payload, for example a command substitution or ordinary shell command. 3. A user or Agent invokes any `alexandrie.sh` command. 4. Bash evaluates the malicious statement through `source`. 5. The payload runs under the invoking user's account before the requested Alexandrie operation begins. This path requires the attacker to be able to alter the referenced credential file or a component of its path. ### Impact Assessment Successful exploitation permits arbitrary command execution with all operating-system privileges available to the invoking user. The payload could read or modify files accessible to that account, access other credentials available to the process, alter note data through the authen ...[truncated 216 chars]- Remediation
View remediation
&2 exit 1 fi PASSWORD=$(<"$PASSWORD_FILE") ``` 4. Verify that the credential file is owned by the expected user and is not group- or world-accessible. 5. Set restrictive permissions, such as `0600` for the secret file and `0700` for its parent directory. 6. Load the password only for operations that require a new login rather than for every command. 7. Avoid suppressing all loading errors with `2>/dev/null || true`; report configuration and permission failures clearly without printing secret contents. ]]>
