T03 · Remote Payload Retrieval and Execution
Error
- Location
- scripts/sync-github.sh:158
- Finding
- Unverified Remote Restore Script Execution<![CDATA[ ## Vulnerability Details **File Location**: `scripts/sync-github.sh:158-162` **Vulnerability Type**: `T03: Remote Payload Retrieval and Execution` **Risk Level**: Critical ### Vulnerable Code ```bash git clone "$REPO_URL" "$TEMP_DIR/repo" cd "$TEMP_DIR/repo/agent-backup" ./restore.sh ``` ### Technical Analysis The pull workflow accepts a repository URL from the command line, clones the repository, and immediately executes the repository-provided `agent-backup/restore.sh` script. The repository is not restricted to an approved owner or location. The script also performs no commit pinning, cryptographic signature verification, checksum verification, content validation, or interactive confirmation before execution. Consequently, the effective executable payload can be modified after this skill has been reviewed or installed. Although the push workflow creates a legitimate restore script, the pull workflow does not verify that the cloned script is the version generated by this project. Any repository with the expected directory and file structure can provide an arbitrary executable payload. ### Attack Path 1. An attacker creates a Git repository containing `agent-backup/restore.sh`. 2. The malicious restore script contains commands for credential theft, persistence, destructive operations, or arbitrary code execution. 3. The attacker convinces a user or agent to run: ```bash scripts/sync-github.sh <attacker-controlled-repository> --pull ``` 4. The script clones the repository into a temporary directory. 5. It changes into the repository-controlled `agent-backup` directory. 6. It executes `./restore.sh` without validating its origin or contents. 7. The malicious commands run with all privileges available to the user invoking the migration script. The same exploitation path applies if an otherwise trusted backup repository or its associated credentials are compromised. ### Impact Assessment An attacker can obtain arbitrary command execut ...[truncated 617 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not execute any script obtained from the cloned repository. - Implement restoration entirely through trusted local code shipped with this project. - Treat repository contents strictly as data and restore only an explicit allowlist of expected files. - Validate file types, names, ownership, permissions, symbolic links, and destination paths before copying data. - Restrict synchronization to explicitly approved repository owners and URLs. - Pin restoration to a known commit and verify its cryptographic signature or a trusted out-of-band checksum. - Require explicit user confirmation that displays the repository URL, commit identifier, and files to be restored. - Run restoration under a dedicated, least-privileged account. - If execution of a downloaded script is unavoidable, display and validate the script, isolate it in a sandbox, deny network access, and limit filesystem access before execution. ]]>
