T03 · Remote Payload Retrieval and Execution
Error
- Location
- scripts/provision.sh:121
- Finding
- Mutable Remote Installer Is Executed Directly Through a Shell Pipeline<![CDATA[ ## Vulnerability Details **File Location**: `scripts/provision.sh`, lines 21-22 and 121 **Vulnerability Type**: Remote payload retrieval and execution **Risk Level**: Critical ### Vulnerable Code ```bash INSTALL_URL="${INSTALL_URL:-https://install.ninja-portal.com/kannaka}" NATS_DEFAULT="nats://swarm.ninja-portal.com:4222" ``` ```bash as_user "curl -fsSL '$INSTALL_URL' | sh -s -- $flags" || { echo "installer failed" >&2; return 1; } ``` ### Technical Analysis The provisioning script downloads content from a mutable external URL and immediately passes it to `sh`. The fetched installer is not saved, version-pinned, signature-verified, or digest-verified before execution. The documentation claims that the remote installer reads a signed manifest and downloads SHA-256-checked releases. Those downstream checks do not authenticate the bootstrap installer itself. If the installer endpoint, delivery infrastructure, DNS/TLS trust chain, or server account is compromised, the returned shell program can perform arbitrary operations as the target login user before any release verification occurs. `INSTALL_URL` is also environment-overridable. Because it is interpolated into a command string consumed by `bash -c`, an attacker who can control the provisioning environment may redirect execution to an arbitrary source. A value containing a single quote could additionally escape the intended shell quoting. ### Attack Path 1. The attacker compromises the configured installer endpoint or gains control over `INSTALL_URL`. 2. The attacker serves a malicious shell script instead of the expected installer. 3. An operator runs `bash provision.sh install` or `bash provision.sh all`. 4. `curl` downloads the attacker-controlled response. 5. The response is passed directly to `sh` and executes as the configured Kannaka user. 6. The payload can steal user-readable credentials and node data or replace the Kannaka binary. 7. A later service step can copy the malicious binary ...[truncated 459 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `curl | sh` execution pattern. 2. Vendor a reviewed installer in the Skill or download it to a temporary file before execution. 3. Pin the installer to an immutable version and expected cryptographic digest. 4. Verify a detached digital signature using a public key distributed with the audited Skill. 5. Abort before execution if signature, digest, ownership, or permissions are unexpected. 6. Remove the unrestricted `INSTALL_URL` override or restrict it to an explicit HTTPS hostname allowlist. 7. Avoid constructing commands for `bash -c`; pass URLs and installer arguments through positional parameters or arrays. 8. Independently verify downloaded binaries again before copying them into privileged system locations. ]]>
