T03 · Remote Payload Retrieval and Execution
- Location
SKILL.md:61- Finding
Externally Retrieved Terraform Templates Can Execute Arbitrary Code
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 61-74
Vulnerability Type: Remote executable template supply-chain risk
Risk Level: MediumRelevant Skill Instructions:
markdown ### Template Safety — IMPORTANT Templates define the actual cloud infrastructure that will be created. They may contain: - `remote-exec` provisioners that run arbitrary scripts on created instances - `user_data` / `cloud-init` scripts that execute on instance boot - Security group rules that open network ports (e.g., 0.0.0.0/0 ingress) - `local-exec` provisioners that run commands on your local machine **Before applying any template, you MUST:** 1. **Inspect the template source** — Run `get_template_info` to view the template's `main.tf`, `variables.tf`, and other files. Read them to understand what resources will be created. 2. **Use `plan_case` first** — This runs `terraform plan` to show a preview of all resources that will be created, modified, or destroyed. Review the plan output before proceeding to `start_case`. 3. **Audit registry templates** — The official template repository is fully open-source at https://github.com/wgpsec/redc-template. Compare pulled templates against the source to ensure they have not been tampered with. 4. **Do NOT blindly apply** — Never run `start_case` without first reviewing the plan. This skill will always use `plan_case` before `start_case` to give you a chance to review.The associated retrieval and execution workflow is documented as:
markdown ### 3. pull_template Download a template from the registry. **Command:** ```bash redc pull <template_name>MCP Tool:
pull_templatetemplate_name(string, required): Template name (e.g., "aliyun/ecs" or "aliyun/ecs:1.0.1")registry_url(string, optional): Registry base URLforce(boolean, optional): Force re-download even if template exists
text ### Technical Analysis The Ski ...[truncated 3386 chars]- Remediation
View remediation
Remediation Suggestions
- Require immutable template versions rather than allowing mutable or unversioned template names for deployment.
- Maintain an allowlist of approved templates, versions, registries, and SHA-256 content hashes.
- Cryptographically verify downloaded templates before inspection or execution. Prefer signed release manifests with a pinned and independently distributed public key.
- Disable arbitrary
registry_urloverrides by default. If custom registries are necessary, require explicit user approval and enforce HTTPS with strict certificate validation. - Verify every file in a retrieved template against an approved manifest, including referenced scripts, modules, provider lock files, and cloud-init assets.
- Reject templates containing
local-execorremote-execby default. Require a separate, explicit confirmation that identifies the exact command and execution context when such provisioners are necessary. - Display complete
user_data, cloud-init, provisioner commands, external module sources, and network exposure changes during review rather than relying only on summarized Terraform plan output. - Run Terraform in an isolated, minimally privileged container or sandbox with restricted filesystem access, no unrelated secrets, and tightly controlled outbound networking.
- Use short-lived, least-privileged cloud credentials limited to the required project, region, and resource types. Do not expose unrelated provider credentials to the process.
- Recalculate and verify the approved template hash immediately before
start_caseso that the reviewed content is exactly the content being applied. - Record the registry origin, version, digest, review decision, and applied digest in an auditable deployment log.
