D^3CTF 2025!
Organized by @Vidar, @CNSS, @L-Team, the 6th D^3CTF.
D^3 means “the cube of Dian”, i.e., the cube of “electronic” in Chinese. As the three teams co-hosting this CTF game come from three “University of Electronic” in China (UESTC, Xidian, HDU).
I participated in D^3CTF 2025, as a member of my institute’s club, InfoSecIITR. This writeup details the challenge I attempted during the competition.
Misc-Networking
d3RPKI
Challenge Description
After 2 network challenges in D^3CTF 2024 and 2021, here comes the third one.
在 D^3CTF 2024 and 2021 的两个网络题后,第三个网络题这就来了。
It’s time to test your network skill by hacking our BGP network.
是时候在我们的 BGP 网络中展现你的配网水平了。
Plz connect with ssh, login as root and the passwd is also root.
请使用 ssh 链接靶机,账户密码都是 root
It always takes at least 5 minutes to setup the environment, so it’s recommended to use local environment first.
靶机起码要开五分钟,别急,可以先试试本地
Attachments: src.zip
Solution
Unfortunately, I was only able to solve this challenge partially during the competition—I missed a minor but crucial step.
The challenge name mentions “RPKI” (Resource Public Key Infrastructure), which is used to secure BGP.
Network Topology
- t1 (AS 4211110001) - Main router at 10.1.0.1, acts as RPKI validator
- t2-1 (AS 4211110002) - Router at 10.2.0.1 where we’re currently located
- t2-2 (AS 4211110003) - Router at 10.3.0.1, contains the flag and sends it to 10.4.0.5:1234
- t2-3 (AS 4211110004) - Router at 10.4.0.1
Docker Compose (compose.yml)
Sets up the network topology with:
- Multiple networks using macvlan drivers for Layer 2 connectivity
- Each container gets specific IP addresses on different subnets
- NET_ADMIN capabilities for network manipulation
- Port 2233 mapped to SSH on t2-1 for external access
BGP Routing (bird.conf files)
Each router runs BIRD (BGP daemon) configured to:
- Establish BGP peering relationships between routers
- Use ROA (Route Origin Authorization) validation via RPKI
- Filter routes based on ROA validation to prevent route hijacking
- Advertise static routes for their local subnets
RPKI/ROA System (roa_stayrtr.json)
- t1 runs StayRTR as an RPKI cache server
- roa_stayrtr.json defines valid route origins for each AS
- Other routers connect to t1’s RPKI cache for route validation
- Routes failing ROA validation are rejected
The challenge title and the provided files clearly indicate a BGP route hijacking attack that exploits a fundamental limitation in RPKI.
The RPKI Limitation
RPKI validates that a specific network prefix (like 10.4.0.0/24) is authorized to be announced by a particular AS (like AS 4211110004). However, RPKI doesn’t verify WHO is actually making the announcement - it only checks if the announced prefix and AS number combination is valid.
The Attack Strategy
The goal is to intercept the flag that t2-2 is sending to 10.4.0.5:1234. To do this, the attacker needs to:
- Hijack the IP 10.4.0.5 by making other routers believe traffic to that IP should come through the attacker
- Bypass RPKI validation by making the hijacked route appear legitimate
Upon logging in via SSH
, we’re provided with limited commands and already have access to the BIRD
config files. We can use commands like bird
, birdc
, nc
, etc.
Configuring bird.conf on t2-1
1 | $ ssh root@35.241.98.126 -p 30921 |
- Add a Static Route
route 10.4.0.5/32 reject; # More specific route than the /24
This creates a more specific route (/32 is more specific than /24) that will be preferred by BGP.
- Filter Incoming Routes
if net = 10.4.0.0/24 then reject;
Block the legitimate route announcement for the entire 10.4.0.0/24 subnet.
- Forge the AS-PATH
1 | if net = 10.4.0.5/32 then { |
When announcing the hijacked route, prepend AS 4211110004 to the AS-PATH. This makes it appear as if the route is legitimately coming from AS 4211110004.
I missed Step 3 during the competition. :(
Why This Works
More Specific Route: The /32 route is more specific than any /24 route, so it will be preferred.
RPKI Validation Passes: Because the AS-PATH shows AS 4211110004 as the origin, and the ROA table says AS 4211110004 is authorized for 10.4.0.0/16, RPKI validation succeeds.
Traffic Redirection: Other routers will now send traffic destined for 10.4.0.5 to the attacker instead of the legitimate destination.
Further lookup for the IP 10.4.0.5:
1 | root@b04002374330:~# ip addr add 10.4.0.5/32 dev lo |
The route for 10.4.0.5/32 is now in place and reachable via our node. Let’s listen through Netcat command:
1 | root@b04002374330:~# nc -lvp 1234 |
We got our flag from t2-2 with IP as 10.3.0.1
.
Flag
1 | d3ctf{c9780467-2ff8-4ccf-96e1-49b36e3f6822} |