5GMM cause #23: UE security capabilities mismatch, explained
What 5GMM cause #23 means in TS 24.501, why the UE sends it in SECURITY MODE REJECT, what the AMF must do next, and how to test it against your core.
Cause #23, "UE security capabilities mismatch", is one of the 5GMM causes that is easy to misread. It looks like a reason the network would give for rejecting a UE. In TS 24.501 it is the other way round: it is a reason the UE gives for refusing the network's security mode command. Getting the direction right matters when you write a test for it, because it decides which side your tester plays and what you assert.
Clause numbers below refer to TS 24.501 unless another spec is named.
Where #23 sits in the spec
The 5GMM cause information element is defined in clause 9.11.3.2. Annex A groups the values, and #23 is listed with the PLMN specific network failures, congestion and authentication failures in Annex A.3, next to #20 MAC failure, #21 synch failure, #24 security mode rejected (unspecified) and #26 non-5G authentication unacceptable.
The procedure that uses it is NAS security mode control, clause 5.4.2. The AMF starts it after authentication by sending SECURITY MODE COMMAND, which selects the NAS ciphering and integrity algorithms and carries a field called replayed UE security capabilities.
Why the AMF replays the capabilities
When a UE registers, it tells the network which 5G security algorithms it supports, in the UE security capability IE of REGISTRATION REQUEST. REGISTRATION REQUEST is not integrity protected. A party who could change it in transit might remove the stronger algorithms and push the UE onto weaker ones. Security robustness testing is how a lab checks for that bidding-down case.
The defence is simple. In SECURITY MODE COMMAND, which is integrity protected with the new NAS security context, the AMF sends back the capabilities it received. The UE compares them with what it actually sent. TS 33.501 describes the same mechanism in the NAS security mode command procedure (clause 6.7.2).
When the UE sends #23
Clause 5.4.2.3 describes the UE side: the UE checks the integrity of SECURITY MODE COMMAND and checks that the replayed UE security capabilities match what it sent. Clause 5.4.2.5 covers the case where the UE does not accept the command. If the replayed UE security capabilities have been altered compared with the latest values the UE sent to the network, the UE answers with SECURITY MODE REJECT and 5GMM cause #23. For other reasons the UE typically uses #24, security mode rejected, unspecified.
So #23 is evidence of one thing: what the AMF replayed is not what the UE sent. On a live network that can mean the capabilities were altered in transit. In a lab it is far more often a bug: the AMF stored the wrong capability octets, truncated an optional octet, or replayed capabilities from an old context.
What the AMF must do next
Clause 5.4.2.5 is also clear about the network side. When the AMF receives SECURITY MODE REJECT, it stops timer T3560 and aborts the ongoing procedure that triggered security mode control. For an initial registration, that means the registration does not complete: no REGISTRATION ACCEPT should follow.
That gives you two testable behaviours:
- The AMF replays the capabilities correctly, so a conforming UE never needs to send #23.
- The AMF handles a SECURITY MODE REJECT correctly when it gets one, by aborting instead of carrying on.
A note on #23 in REGISTRATION REJECT
You may see #23 in the other direction too. Some AMF implementations send REGISTRATION REJECT with #23 when a REGISTRATION REQUEST carries security capabilities they cannot use, for example none of the algorithms they support. That is an implementation choice. Clause 5.5.1.2.5, which lists the causes the UE handles in REGISTRATION REJECT during initial registration, does not list #23. If your core does this, it is fine to test for it, but the test should say it is asserting your core's behaviour, not a requirement of the spec.
How to test it
With Runik playing the gNB and the UE, both behaviours are flows you can run on every change.
Test 1: the replay is right. Run a normal registration. The flow waits for SECURITY MODE COMMAND, answers with SECURITY MODE COMPLETE, and expects REGISTRATION ACCEPT. If the replayed capabilities were wrong, a conforming UE would reject here, so a clean registration with security mode is the baseline check. Add -trace to see the replayed capability octets when you need to inspect them.
Test 2: the AMF aborts on reject. The flow answers SECURITY MODE COMMAND with SECURITY MODE REJECT instead, then checks that the registration does not go on. A flow declares its own final states, so this one names the outcome it expects. From the catalog flow gnb/security_mode_reject_aborts_registration, abridged:
final_states: [rejected, tolerated, aborted_no_signalling, unproven, failed]
final_checks:
- name: the flow reached the rejected terminal
metric: final_state_counts.rejected
op: equals
value: 1
- name: and no assertion failed
metric: checks_failed
op: equals
value: 0
{ "flow_name": "security_mode_reject_aborts_registration", "verdict": "pass", "all_passed": true,
"final_checks": [ { "name": "the flow reached the rejected terminal", "pass": true } ] }
Runik's NAS builders include both SECURITY MODE COMPLETE and SECURITY MODE REJECT, and rk vocab lists the fields each builder takes. These are well-formed messages, so both tests run in Runik Community.
Exit 0 means the core behaved as the flow expects. Exit 1 means a check failed, for example the AMF sent REGISTRATION ACCEPT after the reject, and the verdict names the failed check. Exit 3 means the core does not implement the scenario.
Going further: malformed capabilities
A REGISTRATION REQUEST with an empty or zeroed security capability IE, or one with no algorithm in common with the AMF, is a different test from the well-formed SECURITY MODE REJECT above. Pick the flow that matches the behaviour you want to pin down, and read the verdict the same way. See editions for what each edition runs.
Common causes of #23 in a lab
If a conforming UE, or a tester behaving like one, sends #23 against your core, check these first:
- Stored octets. The AMF stores the capability IE from the first REGISTRATION REQUEST and replays it. A parser that drops optional octets, or re-encodes the IE with a different length, changes the replay.
- Wrong context. On a re-registration or after a context transfer, the AMF replays capabilities from an older context than the one the UE just sent.
- Mixed fields. The AMF replays the right 5G capabilities but gets the optional EPS-related part wrong.
A test that runs registration with security mode on every build catches all three as soon as they appear, before a device in the field does. Put it in your CI gate, next to the rest of the cause-code checks.
Start
Install Community with curl -fsSL https://get.dflux.io/runik/install.sh | sh, clone the flow catalog, and run registration with security mode against your core. Then add the reject case and see what your AMF does.