Severity by source
AV:A/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:L
Primary rating from GitHub Advisory · only source for this CVE.
CVSS VectorGitHub Advisory
CVSS:3.1/AV:A/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:L
Lifecycle Timeline
4DescriptionGitHub Advisory
Summary
The AMF in Free5GC v4.2.1 does not enforce the concurrent security procedure rules defined in 3GPP TS 33.501 §6.9.5.1. The AMF does not check for ongoing N2 handover procedures before initiating a NAS Security Mode Command, and vice versa. This can lead to mismatches between NAS and AS security contexts in the network and the UE.
Details
Vulnerability Type: CWE-358 (Improperly Implemented Security Check for Standard)
Affected File: internal/ngap/handler.go - handleHandoverRequiredMain() and internal/gmm/sm.go - SecurityMode()
Root Cause:
3GPP TS 33.501 §6.9.5.1 states:
> "Concurrent runs of security procedures may, in certain situations, lead to mismatches between security contexts in the network and the UE. In order to avoid such mismatches, the following rules shall be adhered to: > 1. AMF shall not initiate any of the N2 procedures including a new key towards a UE if a NAS Security Mode Command procedure is ongoing with the UE. > 2. The AMF shall not initiate a NAS Security Mode Command towards a UE if one of the N2 procedures including a new key is ongoing with the UE."
Free5GC AMF uses an OnGoing state tracking mechanism (SetOnGoing(), GetOnGoing()) with OnGoingProcedureN2Handover type. However, the cross-procedure checks required by §6.9.5.1 are not implemented:
Rule 2 violation: SecurityMode() in internal/gmm/sm.go sends SMC on EntryEvent without checking if N2 handover is ongoing.
Rule 1 violation: handleHandoverRequiredMain() in internal/ngap/handler.go calls SetOnGoing(OnGoingProcedureN2Handover) without checking if SMC is ongoing.
Why NH/NCC and SMC are related:
SMC activates a new KAMF, which changes the basis for NH key derivation. The N2 HandoverRequest includes NH/NCC derived from the old KAMF. If both procedures run concurrently, the target gNB and UE derive different KgNB keys, breaking AS security.
PoC
Source code evidence:
Free5GC AMF internal/gmm/sm.go - SecurityMode():
func SecurityMode(state *fsm.State, event fsm.EventType, args fsm.ArgsType) {
switch event {
case fsm.EntryEvent:
// No check for OnGoing N2 procedure
// Directly proceeds to SMCFree5GC AMF internal/ngap/handler.go - handleHandoverRequiredMain():
amfUe.SetOnGoing(sourceUe.Ran.AnType, &context.OnGoing{
Procedure: context.OnGoingProcedureN2Handover,
})
// No check for ongoing SMC before setting N2Packet Evidence (pcap available):
| Packet | Time | Message | Description |
|---|---|---|---|
| #1 | 0.000s | HandoverRequired | gNB_A requests handover |
| #18 | 0.002s | HandoverRequest | N2 started (NH/NCC included) |
| *(no response from gNB_B)* | N2 ongoing | ||
| #28 | 2.062s | Registration request | UE re-registers (same SUPI) |
| #63 | 2.069s | Authentication request | |
| #64 | 2.070s | Authentication response | |
| #71 | 2.072s | Security mode command | SMC during N2 ongoing = Rule 2 violation |
NGAPHandover-N2-SMC-Concurrent.zip
Impact
Integrity (MEDIUM): Concurrent NAS and AS security procedures can cause security context mismatches between UE, AMF, and gNB. The SMC activates a new KAMF while the N2 HandoverRequest carries NH/NCC derived from the old KAMF, resulting in KgNB derivation mismatch.
Availability (LOW): Security context mismatch may cause handover failure or security verification failures.
AnalysisAI
Free5GC Access and Mobility Function (AMF) versions up to 1.4.3 fail to enforce 3GPP TS 33.501 §6.9.5.1 concurrent security procedure rules, allowing NAS Security Mode Command (SMC) to execute simultaneously with N2 handover procedures. This causes security context mismatches between the UE and network when SMC activates a new KAMF while N2 HandoverRequest carries Next Hop (NH) and Next Hop Chaining Counter (NCC) derived from the old KAMF, resulting in different KgNB key derivation at the target gNB and UE and breaking access stratum (AS) security integrity. Source code analysis confirms missing cross-procedure validation in SecurityMode() and handleHandoverRequiredMain() functions; packet evidence demonstrates Rule 2 violation (SMC initiated during ongoing N2 handover).
Technical ContextAI
Free5GC is an open-source 5G core network implementation. The vulnerability exists in the Access and Mobility Function (AMF), which manages UE mobility and security procedures in 5G networks. The AMF implements a finite state machine (FSM) for NAS-level security with an OnGoing state tracker (SetOnGoing/GetOnGoing) for tracking procedure status. The root cause is CWE-358 (Improperly Implemented Security Check for Standard): the AMF tracks OnGoingProcedureN2Handover state but does not cross-check with NAS SMC state before initiating either procedure. The vulnerability violates 3GPP TS 33.501 §6.9.5.1, which mandates: (1) AMF shall not initiate N2 procedures with new keying material if NAS SMC is ongoing, and (2) AMF shall not initiate NAS SMC if N2 procedures with new keying material are ongoing. The technical impact stems from the relationship between KAMF (master key in NAS) and KgNB (access stratum key): SMC activates a new KAMF, which changes the basis for NH/NCC derivation used in N2 HandoverRequest. Concurrent execution causes UE and target gNB to derive different KgNB values, breaking AS ciphering and integrity protection.
RemediationAI
No vendor-released patch identified at time of analysis. The package metadata indicates fixed version as 'None', confirming no official patch is available. Immediate remediation options are limited and must rely on compensating controls. Organizations operating Free5GC AMF in production should: (1) disable or defer N2 handover procedures when SMC must be executed by modifying FSM logic to queue SMC until N2 procedures complete, accepting increased latency during mobility events; (2) implement external handover orchestration that serializes SMC and N2 handover via application-layer logic outside the AMF, ensuring mutual exclusion at the cost of handover performance; (3) restrict concurrent UE registrations and handovers via subscriber policy enforcement to minimize trigger conditions, reducing service availability; or (4) immediately patch the source code by adding OnGoing checks in both SecurityMode() (check GetOnGoing for N2Handover before sending SMC) and handleHandoverRequiredMain() (check GetOnGoing for NAS SMC before setting N2 handover state). The recommended interim fix is to apply source-code patch adding conditional checks: in SecurityMode(), add if GetOnGoing(OnGoingProcedureN2Handover) then defer SMC; in handleHandoverRequiredMain(), add if GetOnGoing(OnGoingProcedureNASSecurity) then reject N2 handover initiation. Upstream fix requires contribution to the Free5GC project; monitor https://github.com/free5gc/free5gc for patches or fork and apply locally.
Same technique Information Disclosure
View allShare
External POC / Exploit Code
Leaving vuln.today
EUVD-2026-32556
GHSA-vrrx-58h3-prmh