A Rare Glimpse into 5G Security with Decrypted NR Attach

Understanding the intricacies of 5G network security is paramount for professionals safeguarding mobile infrastructure. While many network traces remain encrypted, a recent Wireshark work-item (19757) published a unique 5G NR trace. This capture, comprising 151 frames over approximately 49 seconds at the MAC layer, is unusually transparent because it includes the User Equipment's (UE) keys. This allows for an in-depth examination of genuine radio security, specifically NEA2 (AES) ciphering and NIA2 (AES-CMAC) integrity, moving beyond the common NEA0 null cipher found in many lab-environment traces.

The capture provides a clear illustration of a fundamental principle in 5G: the core network and the radio access network (RAN) secure their communication channels independently, and these security procedures often run concurrently. This dual-layer approach is crucial for the overall robustness of the 5G architecture.

Parallel Security Procedures: NAS and AS Modes

The trace highlights how the UE and the 5G Core's Access and Mobility Management Function (AMF) engage in a NAS (Non-Access Stratum) Security Mode procedure. This is evident in frames 11 through 16. During this phase, commands are exchanged, and crucially, the responses from the AMF are tagged with a NAS security-header type 4, indicating that the NAS message bodies are both integrity protected and ciphered. This means the actual payload of these core network signaling messages becomes unreadable to an eavesdropper.

Simultaneously, and shortly after the NAS security is established, the base station (gNB) initiates the AS (Access Stratum) Security Mode Command. Frames 17 and 18 show this procedure. The gNB selects specific security algorithms: NEA2 for ciphering and NIA2 for integrity protection. This selection signifies the establishment of a distinct security context for the radio interface itself, operating independently from the core network's NAS security. The use of NEA2 and NIA2, both based on AES, indicates a robust level of encryption and integrity checking for the air interface traffic.

Understanding the Two Security Contexts

The presence of two distinct security contexts – one for the NAS signaling between the UE and the core network, and another for the AS signaling between the UE and the gNB – is a key architectural feature of 5G. This separation allows for flexibility and granular control over security policies. For instance, the core network might mandate certain security parameters for control plane signaling, while the radio access network might have different requirements based on radio channel conditions or specific service needs.

The NAS security procedure, handled by the AMF, is responsible for protecting the control plane communication that manages mobility, session establishment, and other core network functions. The AS security procedure, managed by the gNB, protects the user plane data and lower-layer control plane signaling that traverses the radio interface. This layered security ensures that even if one layer's security were somehow compromised (highly unlikely with strong algorithms), the other layer would still provide protection.

Implications of NEA2 and NIA2

The selection of NEA2 and NIA2 for ciphering and integrity protection, respectively, is significant. NEA2 utilizes AES in a Counter Mode (CM) or Cipher Block Chaining (CBC) mode for encryption, providing strong confidentiality. NIA2 uses AES-CMAC (Cipher-based Message Authentication Code) for integrity protection, ensuring that messages are not tampered with in transit and that they originate from a trusted source. These algorithms are part of the 3GPP's security specifications and represent a substantial upgrade over older 3G and 4G security mechanisms, offering higher throughput and better protection against sophisticated attacks.

The fact that this trace uses genuine, non-null security algorithms is what makes it so valuable. Many security analyses are performed on traces where encryption is disabled for ease of debugging. However, this capture forces an examination of how security protocols actually function in a live, protected network. It demonstrates the practical application of these cryptographic primitives within the 5G framework.

What This Means for Network Operators and Developers

For network operators, this trace underscores the importance of correctly configuring and managing security keys for both NAS and AS layers. Proper key management is the bedrock of any secure communication system, and 5G's dual-security context amplifies this need. Misconfigurations could lead to connectivity issues or, in worst-case scenarios, vulnerabilities if not managed meticulously.

For developers working with 5G network analysis tools like Wireshark, this capture is an invaluable learning resource. It provides real-world examples of security procedures in action, enabling them to better understand packet analysis in a secure environment. The ability to decrypt and analyze these frames, thanks to the included keys, bridges the gap between theoretical security protocols and their practical implementation. This allows for more accurate troubleshooting and deeper insights into network behavior.

Future Research Directions

While this capture offers a rich dataset, it also opens avenues for further investigation. What happens when network conditions fluctuate and security re-keying procedures are initiated? How do different UE implementations handle the parallel security negotiations? Furthermore, analyzing inter-cell handover scenarios with active security contexts would provide an even more comprehensive understanding of 5G's security resilience. The security of the key exchange and management protocols themselves remains a critical area, as even the strongest encryption is only as good as the keys it protects.