fix(ngap): guard nil GNbId and missing targetRan in UplinkRANConfigurationTransfer#222
Merged
Alonza0314 merged 1 commit intoJun 24, 2026
Conversation
…ationTransfer Fixes free5gc/free5gc#1049 Two nil-pointer dereferences in handleUplinkRANConfigurationTransferMain: 1. targetRanNodeID.GNbId is nil when GlobalRANNodeID carries a non-gNB node type (globalN3IWF-ID, globalNgENB-ID, etc.). Add an explicit nil guard before accessing GNbId.GNBValue. 2. When AmfRanFindByRanID returns ok=false, targetRan is nil but SendDownlinkRanConfigurationTransfer was still called with it. Return early after logging the warning.
Contributor
Author
|
Hi maintainers, just following up on this PR — happy to rebase, squash, or address any review feedback if needed. The two nil-dereference guards in the NGAP |
Contributor
|
@Alonza0314 Test all pass |
Alonza0314
approved these changes
Jun 24, 2026
Member
|
Hi @neelareddybollu , Thanks again for your contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes free5gc/free5gc#1049 — nil pointer dereference in the AMF NGAP handler for
UplinkRANConfigurationTransfer.Root Cause
The function
handleUplinkRANConfigurationTransferMaincontained two bugs:Bug 1 — nil dereference on
GNbId(line 1914)ngapConvert.RanIdToModels()only setsranId.GNbIdwhen the incomingGlobalRANNodeIDcarries a global gNB-ID (GlobalRANNodeIDPresentGlobalGNBID).For any other node type —
globalN3IWF-ID,globalNgENB-ID,globalTNGF-ID,globalTWIF-ID,globalWAGF-ID— the field is leftnil.The handler then unconditionally accessed
targetRanNodeID.GNbId.GNBValue,causing a nil-pointer dereference panic.
Bug 2 — nil
targetRanpassed toSendDownlinkRanConfigurationTransferWhen
AmfRanFindByRanIDreturnsok = false,targetRanisnil. The previouscode logged a warning but continued to call
SendDownlinkRanConfigurationTransfer(targetRan, ...)with the nil pointer,risking a secondary panic inside that function.
How to Reproduce
Send a crafted NGAP
UplinkRANConfigurationTransfermessage whereTargetRANNodeID.GlobalRANNodeIDuses a non-gNB node type(e.g.
globalN3IWF-ID), or a valid gNB ID that does not match any known RAN.The AMF process panics immediately.
Changes
internal/ngap/handler.go: AddGNbId != nilguard before accessingGNbId.GNBValue; add earlyreturnwhentargetRanis not found.