Problem & Real-World Motivation
Running live Web Exploitation and Digital Forensics challenges for university competitions and hands-on training (GTU-CTF) exposed structural limits in traditional single-container and FRP port-forwarded CTFd setups:
- Shared-State Pollution & Cross-Team Interference: When competing teams share a single challenge instance, destructive payloads, database mutations, or noisy scanners immediately degrade the lab for other participants.
- Public Port Exposure (
FRP): Exposing dozens of random public TCP ports creates firewall sprawl, prevents clean multi-service web architectures, and strips away realistic network reconnaissance. - Broken Reverse Shells & Hostname Routing: Participants behind campus or residential NAT cannot easily receive reverse shells over raw TCP port forwarding, and virtual-host or multi-endpoint web apps cannot rely on arbitrary high port numbers.
Dehliz CTF was engineered to give every team or solo player an isolated, encrypted virtual lab environment where challenges are completely unreachable from the public internet yet feel like a real internal network.
Architecture & Network Isolation
Dehliz CTF pairs a customized CTFd control plane (plugins/ctfd-dehliz) with an Alpine-based WireGuard & DNS Gateway (gateway/) and a Docker Swarm overlay pool (dehliz_containers):
- Control Plane (
ctfd-dehliz): When a player or team spawns an instance in CTFd,docker_manager.py(Swarm services) orcompose_manager.py(multi-container Compose stacks) provisions isolated containers attached to the externaldehliz_containersnetwork, records expiration TTLs in the database, and callsvpn-gateway:5000overdehliz_bridge. - Gateway Plane (
dehliz_vpn_gateway):vpn_manager.pyassigns per-team WireGuard subnets, updatesdnsmasqhost mappings (SIGHUPreload) for*.dehliz.local, and appliesiptablesforwarding rules binding each instance strictly to its owning team subnet. - Data Plane (
wg0→dehliz_containers): Traffic enters solely through encrypted WireGuard tunnels. Competitors resolve targets via*.dehliz.local, run standardnmapscans, and receive direct reverse shells to their own VPN IP without NAT obstacles.
Key Engineering Decisions
- Zero Exposed Challenge Ports: Challenge containers have no published host ports; only
CTFd(8000/tcp) and WireGuard (51820/udp) face the outside network. - Kernel-Level
iptablesMicro-Segmentation: Cross-team traffic and unauthorized cross-lab access are dropped at the kernel forwarding chain, while teammates inside the same/24VPN subnet can collaborate directly. - Dynamic Local DNS with Turkish-Safe Slugification: Challenge titles are normalized (
slugify()indocker_manager.py) into clean*.dehliz.localhostnames served bydnsmasqat10.13.37.1:53. - Dual Swarm & Compose Orchestration with Quotas: Supports both single-container services and multi-container Compose topologies alongside configurable global instance limits (
dehliz:max_containers,dehliz:max_compose_instances), unique per-instance dynamic flags, and automated background expiry cleanup (scheduler.py). - Minimal Gateway Footprint & End-to-End Verification: Built on Alpine 3.20 (~50 MB RAM footprint) and backed by an automated test suite (
tests/run_tests.sh/tests/run_tests.ps1) verifying live WireGuard handshakes, DNS resolution, intra-team ping, and cross-teamDROPenforcement.
Production Validation (GTU-CTF)
Dehliz CTF serves as the deployment backbone for the Gebze Technical University Cybersecurity Club (GTU-CTF) challenge repository—supporting 22 production scenarios across Web Exploitation (15 challenges) and Digital Forensics (7 challenges):
- Hardened Challenge Runtimes: Web labs deployed through the
GTU-CTFworkflow enforceread_onlyroot filesystems with explicittmpfsmounts, automated exploit verification (solve.py), and zero-spoiler blind peer review packs before going live. - Automated Sync (
sync_challenges.py): Challenge metadata, assets, and container specifications are synchronized directly into CTFd + Dehliz without manual container wiring or exposed port tracking.