CH2 — Credential Theft
The UDR stores every subscriber's permanent secret key. With OAuth2 disabled, any HTTP/2 client can read it — for any subscriber.
What Is the UDR?
The Unified Data Repository (UDR) is the 5G replacement for the HLR/AuC (Home Location Register / Authentication Center) from 2G/3G networks. It is a database that stores every subscriber's authentication secrets. Critically: it stores the permanent subscriber key K — the same secret burned into the physical SIM card at manufacture.
In a production deployment, the UDR is accessed exclusively by the UDM (Unified Data Management), which sits in front of it and provides a higher-level subscriber management API. Only the UDM is supposed to touch UDR authentication data — enforced by OAuth2 access tokens with specific NF-type claims. In this lab, there is no OAuth2. Any client can call the UDR directly.
The K Key
K is a 128-bit (32 hex character) secret key shared between exactly two places: the physical SIM card and the carrier's UDR. It is generated at manufacture, burned into the SIM, stored in the UDR, and never transmitted over any network. All of 5G authentication is a proof-of-knowledge protocol — the SIM proves it knows K without revealing K. Steal K from the UDR and you can impersonate the SIM.
The Vulnerability
The 3GPP specification (TS 33.501) requires that only the UDM — identified by a specific OAuth2 client credential and NF-type claim — may access the UDR's authentication subscription data. The UDR should verify the access token before returning anything. In this lab, the UDR accepts all requests without any authorization check.
Production UDR
Your Lab UDR
The Attack
This challenge builds on CH1. You use the NRF (learned in CH1) to locate the UDR, then query the UDR's authentication subscription endpoint directly using the target subscriber's IMSI. The response contains the raw K key — which is the flag.
--http2-prior-knowledge to every curl command or you will get no response.
Find the UDR via NRF
Query the NRF filtering by ?nf-type=UDR to get the UDR's IP address and port. You can also find it in the full NF list from CH1 — look for "nfType": "UDR" and note the ipv4Addresses.
Query the authentication subscription endpoint
Call the UDR's /nudr-dr/v1/subscription-data/ endpoint with the target IMSI and path suffix /authentication-data/authentication-subscription. The response JSON contains encPermanentKey — that is the K key, and it is the flag.
TWIN{} and submit:
TWIN{264d496f7c8985dcd2fd002d33d9de03} —
the 32-character hex string is the subscriber's K key. The real key on your live core will differ from this example.
| Field | What It Is | Impact If Stolen |
|---|---|---|
| encPermanentKey | K — the permanent subscriber key (128-bit / 32 hex chars) | Clone SIM, decrypt all past and future sessions, bypass 5G-AKA authentication |
| encOpcKey | OPc — operator-specific parameter (128-bit / 32 hex chars) | Required alongside K for a complete SIM clone. Without OPc the clone may not generate correct auth vectors. |
| authenticationManagementField | AMF — a 2-byte field the network uses for key separation across different services | Needed to replicate full authentication vector generation; lower impact on its own. |
| sqn | Sequence number — monotonically increasing counter to prevent replay attacks | Required to avoid synchronization failures when forging authentication vectors. |
Real World Context
This attack is not unique to 5G. Every generation of cellular network has had an equivalent vulnerability — an unauthenticated path to subscriber authentication secrets. The protocols changed; the attack class persisted.
SS7 MAP-SAI Attack
SS7's MAP Send Authentication Info (MAP-SAI) message allowed any node on the SS7 network to query a carrier's HLR/AuC for subscriber authentication vectors — including the RAND/SRES/Kc triplets derived from Ki. No authentication between nodes. Any interconnect participant could query any carrier's subscribers. The attack was documented publicly at the Chaos Communication Congress in 2014 and is still possible on networks with SS7 interconnects today.
UDR Direct Query
The UDR replaced the HLR/AuC. The 3GPP spec replaced SS7 with HTTP/2 and OAuth2. But the attack class is identical: bypass the authorization layer and read the subscriber's secret key from the database. In SS7 you got authentication vectors (not K directly). In an unprotected 5G UDR you get K itself — worse. The defense is the same too: enforce the authorization layer (OAuth2 in 5G, SS7 firewall in 2G/3G/4G).
Flag Format
The flag is the value of
encPermanentKey in the UDR authentication subscription
JSON response for the target subscriber IMSI imsi-999700000000099.Take the 32-char hex string, wrap it in
TWIN{}, and submit.
Do not include any other fields from the response — only the encPermanentKey value.
imsi-999700000000099.
MCC 999, MNC 70 — this is the lab network's test PLMN. The IMSI is always 15 digits after the imsi- prefix.
Using the wrong format returns a 400 Bad Request from the UDR.