T03 · Remote Payload Retrieval and Execution
Error
- Location
- setup.sh:9
- Finding
- Unverified Mutable Remote Code Is Downloaded and Executed<![CDATA[ ## Vulnerability Details **File Location**: `setup.sh`, lines 9-29 **Vulnerability Type**: Remote payload retrieval and execution **Risk Level**: Critical ### Vulnerable Code ```bash REPO_URL="https://github.com/jiangyisheng9-bot/hk3-crm.git" if [ -d "$CRM_DIR" ]; then cd "$CRM_DIR" && git pull else cd "$WORKSPACE" && git clone "$REPO_URL" fi cd "$CRM_DIR" pip3 install -r requirements.txt -q 2>/dev/null || pip install -r requirements.txt -q nohup python3 app.py > /tmp/hk3-crm.log 2>&1 & CRM_PID=$! echo $CRM_PID > "$CRM_DIR/.pid" ``` ### Technical Analysis The installer clones or updates a GitHub repository and then directly executes content obtained from that repository. It does not pin the repository to an immutable commit, validate an expected cryptographic hash, or verify a trusted signature. Consequently, the effective code executed by the Skill can change after the local Skill package has been audited. Both initial installation through `git clone` and later updates through `git pull` trust the current remote repository state. The remote repository controls `app.py` and `requirements.txt`, providing multiple code-execution opportunities. The local files do not prove that the current remote repository is malicious. The vulnerability is the unrestricted and unverified remote execution channel. ### Attack Path 1. An attacker compromises the GitHub repository, its maintainer account, or another mechanism capable of changing its default branch. 2. The attacker adds malicious instructions to `app.py`, changes `requirements.txt`, or modifies other code imported by the application. 3. A user or Agent invokes the Skill. 4. The installer retrieves the attacker-controlled revision through `git clone` or `git pull`. 5. The installer runs dependency installation and launches `python3 app.py` without validating the downloaded revision. 6. The malicious code executes with the operating-system privileges and environment access of the user runnin ...[truncated 686 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Vendor the required application source into a reviewed release artifact whenever practical. 2. If remote retrieval is necessary, pin an immutable commit hash rather than using the mutable default branch. 3. Maintain an allowlisted expected commit hash outside the downloaded repository and verify that the checked-out `HEAD` matches it before installing or executing anything. 4. Require cryptographically signed commits or release artifacts and validate signatures against a separately configured trusted key. 5. Download release archives only over authenticated HTTPS and verify a trusted SHA-256 or stronger digest before extraction. 6. Display the repository URL, exact revision, and verification result, and obtain explicit user approval before execution. 7. Abort safely if verification fails; never fall back to running an unverified revision. 8. Execute the application with a dedicated, least-privileged account or within an appropriately restricted container or sandbox. 9. Review the complete remote application and its dependency lockfile as part of each approved version update. ]]>
