T03 · Remote Payload Retrieval and Execution
Error
- Location
- SKILL.md:53
- Finding
- Unpinned Remote Model Code Is Downloaded and Executed## Vulnerability Details **File Location**: `SKILL.md:53-59`, `SKILL.md:69-80`, `SKILL.md:84-93`, `SKILL.md:107-118`, and `SKILL.md:122-131` **Vulnerability Type**: Untrusted remote payload retrieval and execution **Risk Level**: High ### Vulnerable Code ```bash docker exec <CONTAINER> python3 -c " from modelscope import snapshot_download snapshot_download('<MODEL_ID>', local_dir='/data/models/<MODEL_NAME>') " ``` The downloaded model is subsequently loaded with remote code explicitly trusted: ```bash docker exec <CONTAINER> bash -c ' export USE_FLAGGEMS=0 unset FLAGCX_PATH timeout 300 python3 /tmp/run_offline_inference.py \ --model <MODEL_PATH> \ --tp <TP_SIZE> \ --trust-remote-code ' > /tmp/run_a_offline.json ``` The same `--trust-remote-code` option is present in the Run A serve command and both Run B commands. ### Technical Analysis A model identified by a user-provided remote ID is downloaded from ModelScope without an immutable revision, expected cryptographic digest, or signature verification. The verification commands then use `--trust-remote-code`, which permits custom Python code supplied by the model repository to execute during model loading. Consequently, the effective executable payload can change after this Skill has been reviewed. A repository owner, compromised account, registry compromise, or attacker-controlled model ID could supply malicious custom model code. This is not merely model-data processing: trusted remote model implementations can execute Python with the permissions of the inference process. ### Attack Path 1. An attacker publishes a model repository containing malicious custom Python model code, or compromises an otherwise trusted repository. 2. The attacker supplies that repository ID as the requested model, or waits for an unpinned repository revision to be replaced. 3. The Skill downloads the current repository ...[truncated 925 chars]
- Remediation
- ## Remediation Suggestions 1. Disable remote model code by default and remove `--trust-remote-code` unless the selected model has a documented and reviewed requirement for it. 2. Require explicit, informed user approval before executing custom code from a model repository. 3. Restrict downloads to an allowlist of approved registries, namespaces, and repositories. 4. Pin every remote model to an immutable commit or revision rather than downloading the current mutable state. 5. Verify repository signatures or cryptographic hashes before model loading. 6. Review and locally vendor any required custom model implementation instead of executing mutable repository code. 7. Run model loading as a dedicated non-root user in a hardened, disposable container. 8. Remove sensitive mounts, credentials, host-control sockets, and unnecessary Linux capabilities from the container. 9. Disable outbound network access during model loading and inference unless it is strictly required. 10. Record the source repository, immutable revision, and verified digest in the generated report for auditability.
