GHSA-VRRX-58H3-PRMH

Vulnerability from github – Published: 2026-05-07 01:56 – Updated: 2026-05-07 01:56
VLAI
Summary
Free5GC AMF has Missing Concurrent NAS SMC Validation During NGAP Handover
Details

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.gohandleHandoverRequiredMain() and internal/gmm/sm.goSecurityMode()

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.goSecurityMode():

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 SMC

Free5GC AMF internal/ngap/handler.gohandleHandoverRequiredMain():

amfUe.SetOnGoing(sourceUe.Ran.AnType, &context.OnGoing{
    Procedure: context.OnGoingProcedureN2Handover,
})
// No check for ongoing SMC before setting N2

Packet 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.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/free5gc/amf"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "1.4.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-42082"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-358"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-05-07T01:56:13Z",
    "nvd_published_at": null,
    "severity": "LOW"
  },
  "details": "### Summary\n\nThe AMF in Free5GC v4.2.1 does not enforce the concurrent security procedure rules defined in 3GPP TS 33.501 \u00a76.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.\n\n### Details\n\n**Vulnerability Type:** CWE-358 (Improperly Implemented Security Check for Standard)\n\n**Affected File:** `internal/ngap/handler.go` \u2014 `handleHandoverRequiredMain()` and `internal/gmm/sm.go` \u2014 `SecurityMode()`\n\n**Root Cause:**\n\n3GPP TS 33.501 \u00a76.9.5.1 states:\n\n\u003e \"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:\n\u003e 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.\n\u003e 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.\"\n\nFree5GC AMF uses an `OnGoing` state tracking mechanism (`SetOnGoing()`, `GetOnGoing()`) with `OnGoingProcedureN2Handover` type. However, the cross-procedure checks required by \u00a76.9.5.1 are not implemented:\n\n**Rule 2 violation:**\n`SecurityMode()` in `internal/gmm/sm.go` sends SMC on `EntryEvent` without checking if N2 handover is ongoing.\n\n**Rule 1 violation:**\n`handleHandoverRequiredMain()` in `internal/ngap/handler.go` calls `SetOnGoing(OnGoingProcedureN2Handover)` without checking if SMC is ongoing.\n\n**Why NH/NCC and SMC are related:**\n\nSMC 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.\n\n### PoC\n\n**Source code evidence:**\n\nFree5GC AMF `internal/gmm/sm.go` \u2014 `SecurityMode()`:\n```go\nfunc SecurityMode(state *fsm.State, event fsm.EventType, args fsm.ArgsType) {\n    switch event {\n    case fsm.EntryEvent:\n        // No check for OnGoing N2 procedure\n        // Directly proceeds to SMC\n```\n\nFree5GC AMF `internal/ngap/handler.go` \u2014 `handleHandoverRequiredMain()`:\n```go\namfUe.SetOnGoing(sourceUe.Ran.AnType, \u0026context.OnGoing{\n    Procedure: context.OnGoingProcedureN2Handover,\n})\n// No check for ongoing SMC before setting N2\n```\n\n**Packet Evidence (pcap available):**\n\n| Packet | Time | Message | Description |\n|--------|------|---------|-------------|\n| #1 | 0.000s | HandoverRequired | gNB_A requests handover |\n| #18 | 0.002s | **HandoverRequest** | **N2 started (NH/NCC included)** |\n| | | *(no response from gNB_B)* | **N2 ongoing** |\n| #28 | 2.062s | Registration request | UE re-registers (same SUPI) |\n| #63 | 2.069s | Authentication request | |\n| #64 | 2.070s | Authentication response | |\n| #71 | 2.072s | **Security mode command** | **SMC during N2 ongoing = Rule 2 violation** |\n[NGAPHandover-N2-SMC-Concurrent.zip](https://github.com/user-attachments/files/26735421/NGAPHandover-N2-SMC-Concurrent.zip)\n\n\n### Impact\n\n**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.\n\n**Availability (LOW):** Security context mismatch may cause handover failure or security verification failures.",
  "id": "GHSA-vrrx-58h3-prmh",
  "modified": "2026-05-07T01:56:13Z",
  "published": "2026-05-07T01:56:13Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/free5gc/free5gc/security/advisories/GHSA-vrrx-58h3-prmh"
    },
    {
      "type": "WEB",
      "url": "https://github.com/free5gc/amf/blame/v1.4.3/internal/gmm/sm.go"
    },
    {
      "type": "WEB",
      "url": "https://github.com/free5gc/amf/blame/v1.4.3/internal/ngap/handler.go"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/free5gc/free5gc"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:A/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:L",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Free5GC AMF has Missing Concurrent NAS SMC Validation During NGAP Handover "
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…
Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…