Ten teams in one room, 24 hours on the clock, and one rule announced to the finalists: no AI agents solving the challenges.
Announcing that rule took one line. Enforcing it took a night, a long series of changes to a live production network, one self-inflicted DNS outage, and a rollback of protections that were not the problem at all.
This is the honest version: what each layer caught, what slipped through, what we broke, and what I would do differently.
Context
NCTF26 is the 4th edition of the National CTF of Togo, organised by CERT.tg (https://ctf.tg). After an online qualifier, 10 teams (47 players) played a 24-hour on-site final in Lomé, on the venue's network. I was the technical lead; everything below has since been removed.
This was an on-site fairness measure, not a position against AI (several of our challenges were about AI): in the room, everyone plays under the same conditions.
The five layers
We ended up with five layers, not all planned, not equally useful.
| Layer | What it stops | What it does not see |
|---|---|---|
| Challenge design (per-team flags) | a flag copied from another team | an agent solving for a team |
| Venue network (DNS + IP) | online AI services, whatever the client pretends to be | phone tethering, offline local models |
| CDN / WAF (user-agent) | bots and agents that declare themselves | an agent that drives a real browser |
| Origin web server (user-agent) | same, including on challenge instances | same |
| Humans in the room | everything else | only what they actually look at |
In short: only the network layer touched agents disguised as a browser, because they still have to reach their model provider. The user-agent layers mostly produced evidence. Humans were the only reliable proof, and were not organised in advance.
Layer 1: the venue network
The room had one router with no firewall rules, a plain NAT, its own resolver switched off, and workstations resolving through public resolvers. We built the filtering in three sub-layers.
1a. A DNS sinkhole
Every AI-service domain resolves to loopback, for IPv4 and IPv6, with subdomains included. A generic equivalent with dnsmasq looks like this:
# /etc/dnsmasq.d/ctf-sinkhole.conf (example domains only) # "address=/domain/" matches the domain and every subdomain. address=/ai-provider.example/127.0.0.1 address=/ai-provider.example/::1 address=/another-assistant.example/127.0.0.1 address=/another-assistant.example/::1 Three lessons:
- Our router refused
0.0.0.0as an A record and aborted the batch on the first entry. Loopback works everywhere. - We first wrote only A records, and the cache showed real IPv6 addresses for blocked domains. Harmless there (no IPv6 route), but close it: one AAAA per name.
- Tag entries by category. Removal becomes one command per category, which mattered most when rolling back under pressure.
The AI list started at 54 names. By morning the router held 168 blocked names across all categories (AI services, but also social networks, VPNs and remote-control tools). I will not publish the list: it would be a bypass checklist.
1b. Force every DNS query through the router
A sinkhole is useless if a workstation simply asks a public resolver. We redirected all port-53 traffic from the LAN to the router's own resolver, in UDP and TCP:
# Generic nftables equivalent: LAN port 53 goes to the local resolver nft add table ip nat nft add chain ip nat prerouting '{ type nat hook prerouting priority dstnat; }' nft add rule ip nat prerouting iifname "lan0" udp dport 53 redirect to :53 nft add rule ip nat prerouting iifname "lan0" tcp dport 53 redirect to :53 1c. Reject encrypted DNS
Right after layer 1b, a test workstation showed the problem: the system resolver answered 127.0.0.1, and the AI site still opened in the browser. Modern browsers resolve over DNS-over-HTTPS (port 443 to well-known resolvers) or DNS-over-TLS (port 853) and never touch the router.
The fix was a set of public DoH resolver addresses, a rule on 443 towards that set, a global rule on 853, and sinkholing the DoH bootstrap hostnames:
# Generic nftables sketch: refuse encrypted DNS, explicitly nft add table inet filter nft add chain inet filter forward '{ type filter hook forward priority 0; }' nft add set inet filter doh_resolvers '{ type ipv4_addr; }' # populate doh_resolvers with the public resolvers you want to cover nft add rule inet filter forward iifname "lan0" ip daddr @doh_resolvers tcp dport 443 reject with tcp reset nft add rule inet filter forward iifname "lan0" ip daddr @doh_resolvers udp dport 443 reject nft add rule inet filter forward iifname "lan0" tcp dport 853 reject with tcp reset nft add rule inet filter forward iifname "lan0" udp dport 853 reject Note reject, not drop. We started with drop, and that choice caused one of the outages described below.
The painful part: nearly five hours passed between 1b and 1c. During those hours the DNS block was decorative for any recent browser. The three sub-layers only make sense together.
1d. Apps that do not ask DNS at all
Messaging apps and some desktop AI clients keep cached IP addresses and connect without a DNS query. We added address lists, a drop rule and a purge of established connections. At one point about 14 workstations were still reaching one AI provider's range directly despite the DNS block. That provider was the only one with a dedicated range; the others sit on shared clouds. Blocking by IP is a tool for a few services, not a strategy.
1e. A DNS monitor that blocks only obvious cases
New AI services appear faster than any list. A small script read the router's DNS cache every five minutes, processed only the names it had not seen before (8,867 over the final), and classified them:
import re STRONG = re.compile(r"(assistant-brand-a|assistant-brand-b|llm-gateway)") # placeholders WEAK = re.compile(r"(chat|llm|gpt|assistant|neural)") SKIP = re.compile(r"(^|\.)(cdn-provider\.example|bigcloud\.example)$|\.brandtld$") def classify(name: str) -> str: if SKIP.search(name): return "ignore" # shared infrastructure: never touch if STRONG.search(name): return "block" # auto-block the registrable root, A + AAAA, tagged if WEAK.search(name): return "review" # write to a candidates file, a human decides return "ignore" The choice that saved us: auto-block only clear signatures, send everything ambiguous to a human. "Block every new domain" would have sinkholed every legitimate site a player visited. Even so, the monitor produced two false positives: an office suite's umbrella domain and a VPN vendor whose name contained a matching substring. The weak signature alone matched a messaging app, a software vendor and a university site. Never auto-block on a weak signature, keep an exception list, anchor your patterns.
One limit no script fixes: the router did not log who made a query. The monitor told us what was resolved in the room, never by whom.
Layers 2 and 3: user-agent rules at the edge and at the origin
On the platform side, we extended an existing CDN/WAF rule that already blocked known bots, and added an equivalent map on the origin web server so that challenge instances, which did not go through the CDN, were covered too:
# Generic example: refuse self-declared agent user-agents map $http_user_agent $declared_agent { default 0; "~*(example-agent|another-agent/)" 1; } server { # ... if ($declared_agent) { return 403; } } We drew one line deliberately: directory scanners and headless browsers were blocked on the platform (which is not a target), but allowed on challenge instances, where fuzzing and scripted browsers are part of solving. Plain browsers and players' own scripts passed everywhere.
What this layer is worth: it stops tools that announce themselves and leaves a trace in the logs. One changed header bypasses it, and it cannot see an agent driving a real browser. A JavaScript challenge we added briefly had the same blind spot and annoyed players; it lasted about an hour.
Layer 4: humans
Proctors were in the room, but without a procedure. A workstation check sheet (processes, local model ports, model files) was written during the night, but as far as I know it was never applied systematically. This is the layer that should have been designed first.
What went wrong
We turned the router into a single point of failure
Forcing all DNS through the venue router had a side effect I had not thought through: before, each workstation fell back on its own when a resolver failed. Afterwards, one failure on the router became a failure for the whole room. In the early morning we got exactly that, in three stages:
- An upstream resolver failing on our names. The router forwarded to two public resolvers, and one of them failed on our platform domains and on instance subdomains. Players saw "non-existent domain" for the CTF itself. The fix was to forward only to upstream resolvers we had tested against our own names, then flush the cache.
- A queue that was too short. The problem came back an hour later, with the router at 1% CPU. The resolver's default limit was 100 concurrent queries, for about 170 in flight. Raising it (and the cache size) fixed it.
- Silent drops on encrypted DNS. DHCP still advertised public resolvers next to the router. Browsers in "automatic" secure-DNS mode tried DoH towards them, our rules dropped the packets silently, and the browser waited for its timeout before showing
ERR_NAME_NOT_RESOLVED. The fix: advertise only the filtering resolver in DHCP, and switch the DoH/DoT rules fromdroptorejectso the client falls back immediately.
We left the resolver open to the internet
Enabling the router's resolver for the LAN also made it answer anyone on the WAN side (empty input chain). It stayed open for about twelve hours. Enabling a resolver and closing it to the outside must be one change.
We rolled back the wrong thing
When players reported the platform unreachable, the obvious suspects were the CDN rules added earlier that night, the newest only half an hour before. I had them rolled back. Nothing improved: the cause was the room's DNS, and the instances did not even go through the CDN.
The deeper cause was organisational: two agent sessions were changing infrastructure in parallel, one on the router, one on the platform, with no shared change log. The platform side even guessed "someone may have added DNS filtering on the router", without knowing that was exactly the case.
Later, "the router is overloaded" got the filtering paused for a few minutes. CPU was at 1%; I never measured the real cause. After the final, every layer was removed category by category, each one checked.
What the network will never see
Some things are out of reach of any filtering on the venue network:
- Phone tethering. A laptop on a 4G hotspot is simply not on your network.
- Offline local models. A model running on the player's own machine makes no network traffic at all. Undetectable from the outside.
- Agents in a real browser. They defeat user-agent rules and JavaScript challenges by design.
- Features inside allowed sites. Unblocking a social network on request also brought back the assistant built into it.
- Attribution. The whole room left through one public IP; the platform never saw a local IP or MAC. DHCP logging was off, some MACs were randomised, and the platform's web-server logs covered only a few hours, with no account identifier. Seeing something on the network almost never told us who.
The result of a night of filtering, stated plainly: from the logs, one use of an AI agent submitting flags was established, and every submission it sent was wrong. Nothing else was established. Fast solves turned out to be families of challenge variants sharing a technique, and speed alone proves nothing. No sanction was decided on the basis of suspicion.
What I would do again, and what I would change
Keep:
- Tagged, reversible layers: sinkhole, forced port 53, rejected encrypted DNS. A default-deny egress allowlist would be stronger, but was too risky mid-event and incompatible with challenges that need the internet.
- A monitor that blocks only clear signatures.
- A configuration backup before every change, and a restore script.
Change:
- Deploy before the start, all three DNS sub-layers at once, tested the day before from the venue against the platform and an instance. Ours went in several hours into the final.
- Corrected settings from day one: tested upstreams, high concurrency limit, large cache, DHCP pointing only at the filter,
rejectnotdrop, A and AAAA, WAN port 53 closed. - A DNS health probe through the router every minute:
#!/bin/sh # dns-probe.sh: resolve critical names through the venue resolver, alert on failure RESOLVER="${RESOLVER:?set the venue resolver address}" for name in platform.example.org probe.instances.example.org; do if ! dig +short +time=2 +tries=1 @"$RESOLVER" "$name" | grep -q .; then echo "DNS probe failed for $name via $RESOLVER" | ./notify.sh # your alert channel fi done - Turn on DHCP logging and keep a device-to-player register at check-in (non-randomised MAC, or one SSID/VLAN per team).
- Log every submission with account and user-agent in the platform database, for the whole event.
- Decide beforehand which services stay open, instead of unblocking them one by one at night.
- Keep one change log for every person and agent session touching the infrastructure.
- Write the rule properly: an article on AI with what is forbidden, what is allowed and a graduated scale of sanctions, plus the proctors' right to look at screens and ask a player to explain a solve. A rule announced without a written sanction left us with an established fact and no clear basis to act on it.
Key takeaways
- Filter at the network first. A disguised agent still needs to reach its model provider; user-agent rules only catch tools that announce themselves.
- DNS filtering is three layers or nothing: sinkhole, forced port 53, and explicit rejection of DoH/DoT. Use
reject, notdrop, or browsers hang on timeouts. - Centralising DNS centralises failure. Size the resolver, test its upstreams against your own domains, and probe it continuously.
- Automate only the obvious. Auto-block clear signatures, route ambiguous names to a human, and keep an exception list.
- The network never sees everything. Tethering and local models are invisible; the only reliable proof is a proctor in the room and a player asked to explain their solve.
Closing
This article is part of the series NCTF26: running a national CTF, where I go through what we built, what broke and what I decided while running a national competition. Writeups from players are on https://ctf.tg/writeups, and ideas for NCTF27 are welcome on https://ctf.tg/idees.
If you organise on-site competitions: do you forbid AI, filter it, or write it into the rules? I am looking for rules that hold up in practice.
Next in the series: 20 CTFd plugins for a national CTF: the patterns that held and the ones that broke
