Hello! Welcome back to our 5G security lab.
In the last lesson, we successfully executed a bidding-down attack, forcing a 5G-capable UE to connect to our malicious 4G base station. That exercise demonstrated how an attacker can manipulate a UE's connection choice.
Today, we'll shift our focus back to a pure 5G Standalone connection. Now that we know how to force a connection, let's explore what sensitive information we can gather during the initial, seemingly secure, 5G attach procedure. This lesson addresses the learning outcome: "Capture and analyze the initial RRC messages in a 5G connection to identify subscriber information."
Understanding this initial exchange is fundamental for an attacker. It's the moment the subscriber reveals their identity to the network, and intercepting this information—or understanding how it's protected—is the basis for tracking attacks like IMSI/SUCI catching.
The Theory: Hiding in Plain Sight with SUCI
In older 2G, 3G, and 4G networks, a major privacy vulnerability exists: the device's permanent identifier, the International Mobile Subscriber Identity (IMSI), is often sent unencrypted over the air. This allows anyone with the right radio equipment to passively listen and link a device's activity to a specific SIM card.
5G was designed to fix this. It introduces two key concepts:
- SUPI (Subscription Permanent Identifier): This is the 5G equivalent of the IMSI. It's a globally unique identifier for your subscription, stored securely on the USIM card.
- SUCI (Subscription Concealed Identifier): To prevent the SUPI from being sent unencrypted, the UE conceals it before transmission. It does this by encrypting the SUPI with the home network's public key, creating a SUCI. Only the home network, with its private key, can decrypt the SUCI to reveal the SUPI.
To grasp these crucial concepts, let's watch a video from the 5G Mobile Communications channel that explains the relationship between SUPI and SUCI.
Please watch from 15:08 to 17:05 to understand the security issue with the IMSI in older networks. Then, watch from 17:05 to the end (around 33:03), focusing on: How the SUCI is constructed from the SUPI using encryption. The high-level message exchange showing the UE sending the SUCI and the core network (UDM) decrypting it.
As the video explains, the SUCI is essentially a cryptographic container for the SUPI.

The key takeaway is that the permanent identifier (SUPI) should never appear on the air interface in a secure 5G network. Instead, we should only see the temporary, encrypted SUCI.
The Message Flow: Piggybacking Identity
So, where exactly is the SUCI sent? It's transmitted during the UE's initial registration with the network. This involves two protocol layers you may recall from your networking background:
- RRC (Radio Resource Control): This protocol manages the radio connection between the UE and the base station (gNB).
- NAS (Non-Access Stratum): This protocol handles session management and mobility between the UE and the core network (AMF). NAS messages are said to be "piggybacked" inside RRC messages to get them across the radio interface.
The initial connection sequence is a multi-step dance.
5G SA L3 RRC Analysis - 5G SA Call Flow & Resource Grid Visualization Using Post Processing Tool
The channel Our Technology Planet provides an excellent walkthrough of a 5G connection log. Let's watch it to see the exact sequence of RRC messages.
Watch the segments from 02:26-07:24, 08:37-10:08, and 14:00-14:47. Pay close attention to these key messages: MIB and SIB1: How the UE first learns about the cell. RRC Setup Request: The UE asks to establish a connection. RRC Setup Complete: This is the critical message from the UE that carries the first uplink NAS message—the Registration Request—which contains the subscriber's identity (SUCI).
To summarize the flow:
- The UE performs a Random Access procedure (RACH) to get the gNB's attention.
- The UE sends an
RRCSetupRequest. - The gNB responds with
RRCSetup. - The UE confirms with
RRCSetupComplete. Inside this message is the NASRegistration Request, which contains the SUCI.
The gNB then extracts this NAS payload and forwards it to the AMF inside an Initial UE Message over the N2 interface. Your experience with Wireshark and encapsulated protocols like HTTP within TCP/IP is analogous here—NAS is encapsulated within RRC, which is then re-packaged into NGAP.
Lab: Capturing and Analyzing the 5G Attach
Now, let's put theory into practice. We will capture the traffic from a 5G attach procedure in our lab and find the SUCI.
Step 1: Configure srsRAN for Packet Capture
We need to tell our srsRAN gNB to save the radio messages to a .pcap file that we can analyze in Wireshark.
Open5GS and srsRAN 5G Network Log Analysis - WordPress.com
The blog post 'Open5GS and srsRAN 5G Network Log Analysis' provides practical guidance on how to enable logging and captures. We'll follow its advice.
Please read the section titled "srsRAN_Project Logging". It describes the configuration options for logging and pcap generation in the gNB.
Based on this, open your gNB configuration file (srsRAN_Project/gnb_zmq.yaml). Find or add the pcap section and modify it to enable MAC-layer capture. The mac_filename directive will tell srsRAN where to save the RRC messages.
pcap:
enable: true
mac_enable: true
mac_filename: /tmp/gnb_mac.pcap
ngap_enable: false # We're focusing on the RRC layer for now
Save the file. This configuration will now create a file named gnb_mac.pcap in your /tmp directory every time you run the gNB.
Step 2: Run the Scenario
-
Start the Core Network: In a terminal, start Open5GS as usual.
cd Open5GS-srsRAN/docker docker-compose up -d -
Start the gNB: In a second terminal, start the
gnbwith our modified capture config.cd srsRAN_Project/build sudo ./apps/gnb/gnb -c ../../gnb_zmq.yaml -
Start the UE: In a third terminal, start the
srsueand let it attach to the network.cd srsRAN_Project/build sudo ./apps/ue/ue -c ../../ue.yamlWait for the UE log to show that it has successfully attached and received an IP address. Once it has, you can stop the
gnbandsrsuewithCtrl+C.
Step 3: Analyze the Capture in Wireshark
The capture file /tmp/gnb_mac.pcap now contains the radio messages from the connection. Let's analyze it.
- Open the file in Wireshark.
wireshark /tmp/gnb_mac.pcap - Set the Dissector: The packets will likely show up as "DLT_USER" because srsRAN uses a custom encapsulation. To make Wireshark decode them correctly as 5G RRC, go to
Edit -> Preferences -> Protocols -> DLT_USER, and edit the DLT User table. SetUser 12 (DLT=159)tonr-rrc.mac. Click OK. The display should update to show RRC messages. - Filter the Traffic: In the display filter bar, type
nr-rrcand press Enter to see only the RRC messages. - Find the
RRCSetupCompletemessage. Scroll through the packets and locate this message, which is sent from the UE to the gNB. - Drill Down: Click on the
RRCSetupCompletemessage and expand the protocol tree in the packet details pane. Navigate as follows:NR RRCc1: rrcSetupComplete (1)rrcSetupCompletecriticalExtensions: rrcSetupComplete (0)rrcSetupComplete-r8dedicatedNAS-Message

-
Identify the Subscriber Information:
ThededicatedNAS-Messagefield contains the UE'sRegistration Request. If you expand the5GMM (5G Mobility Management)details within it, you will find an information element called5GS mobile identity. Expand this.- You will see
Type of identity: SUCI... - You will also see the SUCI value itself, which in our lab is composed of the MCC, MNC, and the subscriber's permanent ID.
An important note for security: As the
Open5GS and srsRAN 5G Network Log Analysisarticle mentions, Open5GS withnull-encryptedSIMs does not actually encrypt the SUPI. TheSUCIin the capture is therefore identical to theSUPI. This demonstrates a critical real-world concept: security features are only effective if they are correctly configured and implemented. In our controlled lab, we can see the "plaintext" SUPI, achieving the goal of an IMSI/SUCI-catcher. - You will see
Conclusion
Congratulations! You have successfully captured and dissected the initial 5G connection messages to find a subscriber's identifier.
Key Takeaways:
- 5G improves privacy by encrypting the permanent subscriber identifier (SUPI) into a concealed identifier (SUCI) for over-the-air transmission.
- The SUCI is transmitted within a NAS
Registration Requestmessage. - This NAS message is carried over the radio interface inside an
RRCSetupCompletemessage from the UE to the gNB. - Using srsRAN's built-in pcap functionality and Wireshark, we can capture and analyze this RRC traffic.
- Security is implementation-dependent. Our lab uses null-scheme encryption, which allows us to see the SUPI within the SUCI field, effectively bypassing the privacy measure.
Preview of the Next Lesson:
We've now examined traffic on the radio interface (UE-gNB). But what about the core network itself? In the next lesson, we will use web security tools to probe the HTTP/2 interfaces of the Open5GS core network functions. You'll see how your existing cybersecurity skills in API and web security are directly applicable to the 5G Service-Based Architecture.