T09 · Insecure Skill Coding Practices
- Location
scripts/deploy_site.sh:1- Finding
Unvalidated Subdomain Allows Docker Compose YAML Injection
- Content
View full analysis
\"$TEMP_DIR/docker-compose.yml\" version: '3.8' services: nginx: image: nginx:alpine container_name: \"${SUBDOMAIN}-web\" labels: - \"traefik.enable=true\" - \"traefik.http.routers.${SUBDOMAIN}-router.rule=Host(\`${FULL_DOMAIN}\`)\" - \"traefik.http.routers.${SUBDOMAIN}-router.entrypoints=websecure\" - \"traefik.http.routers.${SUBDOMAIN}-router.tls=true\" - \"traefik.http.routers.${SUBDOMAIN}-router.tls.certresolver=le\" - \"traefik.http.services.${SUBDOMAIN}-service.loadbalancer.server.port=80\" networks: - web networks: web: external: true EOF pushd \"$TEMP_DIR\" || { echo \"Failed to change directory to $TEMP_DIR\"; exit 1; } docker compose up -d || { echo \"Failed to start docker compose services\"; popd; exit 1; } ``` ### Technical Analysis The second positional argument is accepted as `SUBDOMAIN` without validation and interpolated directly into a generated Docker Compose YAML document. Shell quoting around the variable does not protect the structure of the generated YAML because variable expansion occurs while processing the heredoc. A subdomain containing quote characters, line breaks, or YAML syntax can potentially terminate an existing scalar and inject additional Compose properties. Depending on the crafted structure, an attacker could attempt to introduce properties such as: - Host filesystem bind mounts - An attacker-controlled container command or entry point - Additional environment variables - Privileged container mode - Ho ...[truncated 1792 chars]- Remediation
View remediation
