Protecting the conversation between the UE and the core
“The radio carries your data, but the NAS carries your intentions — register me, page me, set up my session. Forge those and you don’t need to read the data at all.”
— WHY NAS SECURITY COMES FIRST
NAS — Non-Access Stratum — is the signaling dialogue between the UE and the AMF: registration, mobility, service requests, session setup. It rides transparently through the gNB, so it must protect itself end-to-end between UE and core. This chapter covers the NAS Security Mode Command, the NEA/NIA algorithms, the NAS COUNT that stops replay, and the bidding-down defense that keeps an attacker from forcing weak protection.
🎯 Learning objectives
Explain what NAS is and why it needs its own security, separate from the radio.
Walk the NAS Security Mode Command procedure step by step.
Describe NEA ciphering and NIA integrity algorithms (NEA0–3 / NIA0–3).
Explain NAS COUNT and how it defeats replay.
Explain the replayed-capabilities bidding-down defense.
Describe NAS security contexts (native/mapped, full/partial) and multiple NAS connections.
📘 Standards reference box — Chapter 8
Specification
Title
Release / version verified
TS 33.501
5G security — NAS security (clause 6.4, 6.7)
Rel-18, v18.11.0 (2026-04)
TS 24.501
NAS protocol for 5GS (messages, security header)
Rel-18/19 edition
TS 33.401 / 35.215+
EPS NAS security (comparison) / algorithm specs
current
Checked June 2026 — verify against the latest 3GPP version.
8.1 What NAS Protects, and Where It Sits
NAS messages travel between the UE and the AMF; the gNB relays them without reading them (NAS is transparent to the RAN). So NAS cannot rely on radio (AS) security — it carries its own ciphering and integrity, keyed by the NAS keys derived from KAMF (Chapter 7). This is the first protection that engages after authentication, and it guards the most powerful signaling in the system.
FIGURE 8.1NAS Within the Protocol Stack — End-to-End to the Core
Purpose: why NAS protects itself. Because the gNB only relays it, NAS security is the UE-to-core guarantee that survives a compromised or fake base station relaying signaling.
8.2 The NAS Security Mode Command
After authentication produces KAMF, the AMF turns protection on with the NAS Security Mode Command (SMC). It selects the algorithms, and — critically — echoes back the UE’s security capabilities it received earlier, integrity-protected, so the UE can confirm nobody tampered with them in the unprotected registration.
FIGURE 8.2The NAS Security Mode Command Procedure
Purpose: the moment NAS protection switches on. The replayed-capabilities check (step ②) is the bidding-down defense — detailed in §8.6.
FIGURE 8.3Inside the NAS Security Mode Command Message
Purpose: field-by-field, what the SMC carries and why. The first protected message must be integrity-protected (so the UE can trust the algorithm choice) before ciphering fully engages.
8.3 The Algorithms: NEA Ciphering, NIA Integrity
5G defines a small, shared algorithm set used by both NAS and AS (Chapter 9). Ciphering algorithms are NEA0–NEA3; integrity algorithms are NIA0–NIA3. The “0” variants are null — and where they belong is a recurring theme of this book.
ID
Ciphering (NEA)
Integrity (NIA)
Core
0
NEA0 — null (no encryption)
NIA0 — null (no integrity)
— (emergency only)
1
128-NEA1
128-NIA1
SNOW 3G
2
128-NEA2
128-NIA2
AES (CTR / CMAC)
3
128-NEA3
128-NIA3
ZUC
FIGURE 8.4NEA Ciphering — How a NAS Message Is Encrypted
Purpose: stream-cipher mechanics shared by NAS and AS. The uniqueness inputs are why COUNT discipline (Chapter 7) is non-negotiable.
FIGURE 8.5NIA Integrity — How a NAS Message Is Authenticated
Purpose: the integrity half. Note the asymmetry with ciphering: NAS integrity is essentially always on, because a forged command is more dangerous than a read message.
8.4 NAS COUNT and Replay Protection
Each direction (uplink, downlink) has a NAS COUNT: a counter combining a sequence number and an overflow counter. It feeds both ciphering and integrity as a freshness input, and the receiver rejects messages whose COUNT it has already seen — a captured-and-replayed NAS message simply fails.
FIGURE 8.6NAS COUNT — Structure and Replay Defense
Purpose: the counter that makes NAS messages one-time. Because COUNT also feeds the MAC, an attacker cannot “fix up” a replayed message to a new COUNT without KNASint.
8.5 Bidding-Down Defense: the Replayed Capabilities
Here is the attack 5G specifically closes. The UE’s security capabilities (which NEA/NIA it supports) are sent in the unprotected registration. A man-in-the-middle could strip the strong ones, hoping the AMF then selects a weak (or null) algorithm. 5G’s defense: the AMF echoes the capabilities back inside the integrity-protected SMC, and the UE compares them to what it actually sent. Any tampering shows up as a mismatch, and the UE aborts.
FIGURE 8.7Defeating Bidding-Down with Replayed Capabilities
Purpose: the bidding-down defense in action. The integrity-protected echo turns a silent downgrade into a detectable, abortable event — provided NIA is not itself null (which is why NIA0 outside emergency is so dangerous).
FIGURE 8.8Protecting Initial NAS Messages
Purpose: the careful handling of the bootstrap problem. 5G ciphers what it can as early as it can, and uses SUCI + the SMC echo to cover the unavoidable first message.
8.6 NAS Security Contexts and Multiple Connections
Purpose: the context vocabulary you will meet in traces and at the 4G/5G boundary. “Mapped” is the one to watch — it quietly imports the source system’s security level.
FIGURE 8.10Multiple NAS Connections — One KAMF, Separate COUNTs
Purpose: how one subscriber can be securely attached over cellular and Wi-Fi at once. Separate COUNTs prevent cross-access replay; the shared KAMF keeps it one identity.
FIGURE 8.11NAS Security Across the Common Procedures
Purpose: NAS security isn’t a one-time event — every subsequent procedure runs under it. Integrity is the constant; ciphering depends on the selected NEA.
FIGURE 8.12NAS Security Context — State Machine
Purpose: the lifecycle in one picture — what state a UE’s NAS security is in at any moment, and what moves it between states.
8.7 The Practical Operator View
Forbid NEA0/NIA0 except for emergency services in algorithm-priority configuration; alarm on any other use (Chapter 26).
Ensure NIA is never null for normal service — without NAS integrity, the bidding-down echo cannot protect anything.
Set algorithm priority lists deliberately (e.g. NEA2/NIA2 AES first); confirm both UE and AMF honor them.
Track the proportion of subscribers on mapped contexts — they are effectively at 4G security (Chapter 17).
Monitor NAS integrity-failure and replay-discard counters — spikes can mean attacks or a broken neighbor relation.
Common misconfiguration risks
NIA0 permitted for non-emergency service → bidding-down defense neutralized.
Algorithm priority leaving NEA0 high in the list → null ciphering selected when a UE “prefers” it.
Replayed-capability check disabled or not enforced by a UE/AMF implementation.
Mapped contexts accepted without policy at interworking.
8.8 Threats and Mitigations
Threat
Vector
Defense
Algorithm bidding-down
strip caps in clear registration
integrity-protected replayed capabilities
NAS message replay
capture & resend signaling
NAS COUNT freshness + MAC
Forged NAS command
fake AMF / injection
NIA integrity (MAC from K_NASint)
Eavesdropping signaling
passive capture
NEA ciphering + initial-message protection
Null-protection abuse
NEA0/NIA0 misconfig
policy forbidding null outside emergency; KPI
Downgrade via mapped context
4G→5G interworking
policy control (Chapter 17)
8.9 Terminology, Example, Checklist
Term
Meaning
NAS
Non-Access Stratum — UE↔AMF signaling, transparent to the gNB
NAS SMC
NAS Security Mode Command — activates protection, selects algorithms
UE security capabilities echoed in the SMC to detect tampering
native / mapped context
From a 5G auth / converted from a 4G context
Real network example. A security team auditing a new 5G SA launch captured the NAS exchange and found registrations completing with NIA2 integrity but NEA0 (null) ciphering — signaling was authenticated but readable. The cause: the AMF’s ciphering algorithm priority list had NEA0 at the top, a copy-paste from an early integration profile. Because integrity (NIA2) was intact, the bidding-down defense still worked and there was no active attack — but every subscriber’s NAS content (including, on some messages, slice and session details) was being sent in clear. Fix: reorder to NEA2/NEA3 first, NEA0 emergency-only, and add a KPI alarm on null-ciphered registrations. Integrity saved them from attack; the cipher misconfig still leaked content.
Capture a registration: confirm NEA and NIA selected are non-null for normal service.
Verify NEA0/NIA0 are emergency-only in algorithm priority lists on every AMF.
Confirm the replayed-capabilities check is enforced (negative test with modified caps if possible).
Check NAS COUNT handling and replay-discard counters are exposed in monitoring.
Measure the share of subscribers on mapped contexts.
Alarm on any non-emergency null-ciphered or null-integrity NAS.
★ Chapter Summary
NAS is UE↔AMF signaling, transparent to the gNB, so it carries its own ciphering and integrity keyed from K_AMF.
The NAS SMC activates protection, selects NEA/NIA, and echoes the UE’s capabilities integrity-protected.
NEA ciphers (null/SNOW3G/AES/ZUC), NIA integrity-protects; NAS integrity is essentially always on.
NAS COUNT per direction provides freshness and replay protection; it also feeds the MAC, so replays can’t be patched up.
The replayed-capabilities echo defeats bidding-down — but only if NIA is not null.
Contexts can be native or mapped (4G ceiling); a UE can hold separate NAS connections for 3GPP and non-3GPP access.
? Review Questions
Why does NAS need its own security when the radio (AS) is already encrypted?
Walk through the NAS SMC. Which message is integrity-protected but not ciphered, and why must it be that order?
Explain precisely how the replayed-capabilities mechanism defeats a bidding-down attacker — and why NIA0 would break it.
How does NAS COUNT stop a replayed message, and why can’t the attacker simply change the COUNT?
A trace shows NIA2 but NEA0 on registrations. Is the network under attack? What is leaking, and what do you fix?
Distinguish native and mapped NAS security contexts and the security implication of each.
Why does a UE attached over both cellular and Wi-Fi keep two NAS COUNT pairs but one K_AMF?
Which NAS procedures run under security after the context exists, and what is always-on vs policy-dependent?
🧪 Mini lab — watch NAS protection switch on
With Open5GS + UERANSIM + Wireshark: (1) Capture a full registration and find the Security mode command and Security mode complete — note which message is integrity-protected-only and which is fully ciphered. (2) Expand the SMC and locate the replayed UE security capabilities IE; confirm it matches the capabilities the UE sent earlier. (3) In the UERANSIM/AMF config, force the AMF ciphering priority to NEA0 and re-capture — observe NAS payloads become readable while integrity (NIA) stays on, reproducing the real-network example. (4) Restore NEA2 first. You have now seen, in packets, both the protection turning on and the exact misconfiguration that silently disables confidentiality.