T09 · Insecure Skill Coding Practices
- Location
references/observe_application.md:24- Finding
Remote Command Injection Through Unvalidated Deployment State Fields
- Content
View full analysis
--Type RunShellScript --InstanceId.1 \ --ContentEncoding Base64 \ --CommandContent "$(printf '%s' 'systemctl is-active ; systemctl is-active nginx; ss -ltnp | grep -E ":80|:" || true' | base64)" ``` The values used in this command are obtained from the project-controlled deployment state: ```text 2. Parse the JSON state file. Extract: - `region_id`, `stack_id`, `topology`, `app_type`, `nginx_mode`, `app_port` - `service_name` (service name, used for service/log checks; falls back to `qwencloud-app` when missing) - `outputs.public_ip`, `outputs.ecs_instance_ids[]`, `outputs.security_group_id`, `outputs.eip_allocation_id` ... 4. Validate region and resource IDs are non-empty. Missing critical IDs → mark the affected layer `unknown` with the reason. ``` The same untrusted service name is also inserted into log commands: ```bash journalctl -u --since '1 hour ago' --no-pager | tail -n 200 tail -n 200 /var/log/nginx/error.log ``` ### Technical Analysis The instructions require values such as `service_name` and `app_port` to be read from `.qwencloud-deploy` and substituted directly into shell source code. The documented validation only checks whether region and resource identifiers are non-empty. It does not require `service_name` to follow systemd unit-name syntax or `app_port` to be a numeric TCP port. An attacker-controlled value containing shell metacharacters, command substitutions, quotes, semicolons, or newlines could terminate the intended argument and add arbitrary shell commands. Encoding the resulting script with Base64 only prepares it for transport throug ...[truncated 1509 chars]- Remediation
View remediation
