T09 · Insecure Skill Coding Practices
- Location
scripts/heartbeat-daemon.sh:27- Finding
Arbitrary Shell Execution Through Daemon Configuration Loading
- Content
View full analysis
&2 exit 1 fi } ``` ### Technical Analysis The daemon loads `config.env` with Bash's `source` command. A sourced file is not treated as passive key-value data; every shell construct in the file is executed in the daemon's current process. An attacker who can create, replace, or modify the selected configuration file can insert command substitutions, function calls, redirections, or arbitrary commands. The injected commands run whenever the heartbeat daemon starts or restarts. The `--config` option also permits an alternate file to be selected. Although choosing that file normally requires user action, presenting an untrusted file as a configuration file provides a direct code-execution path. `set -a` additionally exports all subsequently assigned configuration values to child processes. This unnecessarily exposes sensitive values such as `FEISHU_APP_SECRET` and `GATEWAY_TOKEN` to subprocess environments. ### Attack Path 1. An attacker supplies a malicious configuration file or gains write access to the configured `config.env`. 2. The attacker inserts shell code, for example: ```bash FEISHU_APP_ID="expected-value" arbitrary_command --attacker-controlled-arguments ``` 3. The user starts the daemon with `--config` or the enabled systemd service restarts automatically. 4. `load_config` executes `source "$config_file"`. 5. The injected command runs with the privileges and filesystem access of the user operating the daemon. 6. Because the service is configured to restart automatically, malicious code r ...[truncated 702 chars]- Remediation
View remediation
