### 漏洞概述 该漏洞涉及在5G网络中,当UE(用户设备)发送包含无效`registration_type`值的Registration Request时,AMF(接入和移动性管理功能)未能正确处理这些无效值,导致后续逻辑中出现意外行为。具体表现为: - 无效值可能错误地触发N4 UE上下文转移尝试。 - 某些设备和模糊工具发送的占位符5G-GUTI(AMF-ID和M-TMSI为零)被误认为是有效的,从而触发不必要的N4 UE上下文转移。 ### 影响范围 - **受影响组件**:AMF模块中的`gmm_handle_registration_request`函数。 - **影响场景**:UE发送包含无效`registration_type`值的Registration Request时,AMF可能错误地处理这些请求,导致后续逻辑中的意外行为。 ### 修复方案 1. **规范化`registration_type`值**: - 在`gmm_handle_registration_request`函数早期,将无效的`registration_type`值规范化为`OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL`。 - 确保后续逻辑基于有效的`registration_type`值进行操作。 2. **忽略占位符5G-GUTI**: - 在`gmm_registration_request_from_old_amf`函数中,忽略占位符5G-GUTI(AMF-ID和M-TMSI为零)。 - 将这些占位符视为非动作性,并回退到正常的Registration / Identity procedures。 ### 代码变更 #### `src/amf/gmm-handler.c` ```c if (registration_type->value == OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL) { /* * TS 24.501 Table 9.11.3.7.1: * Unused registration-type encodings shall be interpreted as * "Initial registration" by the network. * Normalize here so subsequent transfer logic has a stable basis. */ if (amf_ue->nas.registration.value != 0) { ogs_error("Normalize reg_type[%d] to INITIAL"); amf_ue->nas.registration.value = OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL; } if (amf_ue->nas.registration.value != OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL) { /* * Issue #2848 */ return false; } } /* * Robustness: many devices (and fuzzers) send a "placeholder" 5G-GUTI * (AMF-ID zero + M-TMSI zero). Treat it as non-actionable for context * transfer regardless of PLMN digits, and fall back to Identity Request / * normal registration handling. */ if ((amf_ue->old_guti.amf_id.region == 0 && amf_ue->old_guti.amf_id.mt2 == 0 && amf_ue->old_guti.nas.plmn_id.mcc1 == 0 && amf_ue->old_guti.nas.plmn_id.mcc2 == 0 && amf_ue->old_guti.nas.plmn_id.mcc3 == 0 && amf_ue->old_guti.nas.plmn_id.mnc1 == 0 && amf_ue->old_guti.nas.plmn_id.mnc2 == 0 && amf_ue->old_guti.nas.plmn_id.mnc3 == 0) || (amf_ue->old_guti.amf_id.region == 0 && amf_ue->old_guti.amf_id.mt2 == 0 && amf_ue->old_guti.m_tmsi == 0)) { return false; } ``` #### `src/amf/namf-build.c` ```c ogs_assert(amf_ue->nas.access_type); ogs_assert(amf_ue->nas.registration.value); ue_context_id = amf_ue_to_context_id(amf_ue); ogs_assert(ue_context_id); ``` ### 总结 该修复通过规范化无效的`registration_type`值和忽略占位符5G-GUTI,确保了AMF在处理Registration Request时的稳定性和正确性,避免了因无效值导致的意外行为。