Skip to content

Virtual machines ​

For challenges that need a full operating system, like kernel exploitation, add VMs with x-ctf-vms. The platform runs them with KubeVirt (an admin has to install it). Docker Compose doesn't know x-ctf-vms, so VMs don't start with ctfgarden compose.

If you only need privileges like cap_add: [SYS_ADMIN] or privileged: true, you don't need a VM: such services already run in a lightweight VM, see Compose support.

YAML
x-ctf-vms:
    main:
      memory: 256Mi
      cpu_cores: 1
      disks:
        - image: quay.io/kubevirt/cirros-container-disk-demo
        - cloud_init_user_data_base64: IyEvYmluL3NoCmVjaG8gJ3ByaW50ZWQgZnJvbSBjbG91ZC1pbml0IHVzZXJkYXRhJwo=
      ports: # the same as for services, see exposing services
        - name: ssh
          target: 22
          protocol: tcp
          app_protocol: ssh
          x-username: cirros
          x-password: gocubsgo
      network_policy: # the same as x-ctf-network-policy on services
          outgoing:
              rules:
                  - other_party: ClusterDns # One of Challenge, ClusterDns, World
                    ports: # Optional
                      - port: 53
                        protocols:
                          - UDP
                          - TCP

Ports work like for services, and network_policy like network policies. Disks are container images with a disk image, or base64-encoded cloud-init user data.

A disk image should contain exactly one .qcow2 or .img file in /disk/. For example:

sh
cat << END > Dockerfile
FROM scratch
ADD --chown=107:107 my-chal.qcow2 /disk/
END

docker build -t my-chal:latest .

Imprint