-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The same function held four working examples of the right pattern\n\nfree5GC is the most widely deployed open-source 5G core. The PCF, Policy Control Function, is one of seven service-based interface (SBI) network functions free5GC packages. Its job is to hand session-management, access-management, and UE policies down to other NFs that ask for them. Every request to a PCF endpoint is supposed to carry an OAuth2 access token issued by the NRF, the Network Repository Function. 3GPP TS 33.501 requires it. The PCF's OpenAPI generators name the local check `RouterAuthorizationCheck`.\n\n`internal/sbi/server.go` declares the router. The entry point is one function, `NewServer`, that registers all seven service groups against the Gin engine. The pattern for each group is identical: declare the routes, declare a `gin.RouterGroup` under the service's URI prefix, declare a `RouterAuthorizationCheck` for that service, wire the check as a group-level middleware, apply the routes.\n\nFour of the seven groups follow that pattern. This is the form they take in v1.4.2, the version the CVE names as vulnerable:\n\n```go\namPolicyRoutes := s.getAmPolicyRoutes()\namPolicyGroup := s.router.Group(factory.PcfAMpolicyCtlResUriPrefix)\namRouterAuthorizationCheck := util.NewRouterAuthorizationCheck(models.ServiceName_NPCF_AM_POLICY_CONTROL)\namPolicyGroup.Use(func(c *gin.Context) {\n amRouterAuthorizationCheck.Check(c, s.Context())\n})\napplyRoutes(amPolicyGroup, amPolicyRoutes)\n\nbdtPolicyRoutes := s.getBdtPolicyRoutes()\nbdtPolicyGroup := s.router.Group(factory.PcfBdtPolicyCtlResUriPrefix)\nbdtRouterAuthorizationCheck := util.NewRouterAuthorizationCheck(models.ServiceName_NPCF_BDTPOLICYCONTROL)\nbdtPolicyGroup.Use(func(c *gin.Context) {\n bdtRouterAuthorizationCheck.Check(c, s.Context())\n})\napplyRoutes(bdtPolicyGroup, bdtPolicyRoutes)\n```\n\nThe OAM group and the PolicyAuthorization group take the same five-line block, different service name, group prefix, and variable. Four instances of the pattern in one function. Each one imports `util.NewRouterAuthorizationCheck` from `internal/util/router_auth_check.go`, instantiates the check against the group's `ServiceName` constant from the openapi models package, calls `Use` on the router group, and registers the routes underneath. The shape is consistent enough that a reader can verify by visual inspection whether a given group is gated.\n\nThree groups in the same function are not gated. SMPolicyControl, the group the CVE names:\n\n```go\nsmPolicyRoutes := s.getSmPolicyRoutes()\nsmPolicyGroup := s.router.Group(factory.PcfSMpolicyCtlResUriPrefix)\napplyRoutes(smPolicyGroup, smPolicyRoutes)\n```\n\nUEPolicyControl, immediately below it:\n\n```go\nuePolicyRoutes := s.getUePolicyRoutes()\nuePolicyGroup := s.router.Group(factory.PcfUePolicyCtlResUriPrefix)\napplyRoutes(uePolicyGroup, uePolicyRoutes)\n```\n\nThe npcf-callback group, which receives notifications from the UDR:\n\n```go\nhttpcallbackRoutes := s.getHttpCallBackRoutes()\nhttpcallbackGroup := s.router.Group(factory.PcfCallbackResUriPrefix)\napplyRoutes(httpcallbackGroup, httpcallbackRoutes)\n```\n\nThree lines per group, not five. The two middle lines, the ones that construct the check and call `Use`, are absent. There is no `if` branch separating these three from the four above, no build tag, no feature flag, no comment explaining why these particular services do not need authentication. The pattern is in the file. These three lines are what the pattern looks like with the middleware deleted.\n\n## The endpoint returns the identifier 5G was redesigned to conceal\n\nThe `getSmPolicyRoutes` function lists four routes:\n\n```go\nfunc (s *Server) getSmPolicyRoutes() []Route {\n return []Route{\n {Name: \"CreateSMPolicy\", Method: http.MethodPost,\n Pattern: \"/sm-policies\", APIFunc: s.HTTPCreateSMPolicy},\n {Name: \"DeleteSMPolicy\", Method: http.MethodPost,\n Pattern: \"/sm-policies/:smPolicyId/delete\", APIFunc: s.HTTPDeleteSMPolicy},\n {Name: \"GetSMPolicy\", Method: http.MethodGet,\n Pattern: \"/sm-policies/:smPolicyId\", APIFunc: s.HTTPGetSMPolicy},\n {Name: \"UpdateSMPolicy\", Method: http.MethodPost,\n Pattern: \"/sm-policies/:smPolicyId/update\", APIFunc: s.HTTPUpdateSMPolicy},\n }\n}\n```\n\nThe GET handler in `internal/sbi/processor/smpolicy.go`:\n\n```go\nfunc (p *Processor) HandleGetSmPolicyContextRequest(\n c *gin.Context,\n smPolicyId string,\n) {\n ue := p.Context().PCFUeFindByPolicyId(smPolicyId)\n if ue == nil || ue.SmPolicyData[smPolicyId] == nil {\n problemDetail := util.GetProblemDetail(\"smPolicyID not found in PCF\", util.CONTEXT_NOT_FOUND)\n c.JSON(int(problemDetail.Status), problemDetail)\n return\n }\n smPolicyData := ue.SmPolicyData[smPolicyId]\n response := &models.SmPolicyControl{\n Policy: smPolicyData.PolicyDecision,\n Context: smPolicyData.PolicyContext,\n }\n c.JSON(http.StatusOK, response)\n}\n```\n\n`SmPolicyControl` is the response shape. The openapi model is auto-generated from 3GPP TS 29.512 V17.11.0, the Session Management Policy Control Service. Its `Context` field is `*SmPolicyContextData`. The first half of that struct:\n\n```go\ntype SmPolicyContextData struct {\n Gpsi string `json:\"gpsi,omitempty\"`\n Supi string `json:\"supi\"`\n InvalidSupi bool `json:\"invalidSupi,omitempty\"`\n InterGrpIds []string `json:\"interGrpIds,omitempty\"`\n PduSessionId int32 `json:\"pduSessionId\"`\n Dnn string `json:\"dnn\"`\n NotificationUri string `json:\"notificationUri\"`\n AccessType AccessType `json:\"accessType,omitempty\"`\n ServingNetwork *PlmnIdNid `json:\"servingNetwork,omitempty\"`\n UserLocationInfo *UserLocation `json:\"userLocationInfo,omitempty\"`\n UeTimeZone string `json:\"ueTimeZone,omitempty\"`\n Pei string `json:\"pei,omitempty\"`\n Ipv4Address string `json:\"ipv4Address,omitempty\"`\n Ipv6AddressPrefix string `json:\"ipv6AddressPrefix,omitempty\"`\n // ...\n}\n```\n\n`Supi` is the SIM card's permanent identifier (IMSI, network-specific identifier, GCI, or GLI per 3GPP TS 23.003). `Pei` is the Permanent Equipment Identifier, typically the IMEI or IMEISV: the device's hardware identity. `Gpsi` is the Generic Public Subscription Identifier, in most deployments the subscriber's MSISDN, the phone number. `UserLocationInfo` is the cell-level location. `Ipv4Address` is the current bearer IP. `ServingNetwork` is the visited PLMN ID. `Dnn` is the data network name the session is connected to.\n\nEvery one of those fields is in the response body the GET handler emits. The handler runs because the route registered without `Use(authCheck)`. There is no token check, there is no caller identity, there is no audit. A reachable HTTP GET against `/npcf-smpolicycontrol/v1/sm-policies/{smPolicyId}` returns the lot.\n\nThe path parameter `smPolicyId` is not random. `HandleCreateSmPolicyRequest`, in the same file, constructs it:\n\n```go\nsmPolicyID := fmt.Sprintf(\"%s-%d\", ue.Supi, request.PduSessionId)\n```\n\nThe format is `-`. `PduSessionId` is a uint8 per 3GPP TS 24.007, range 0 to 255, with practical sessions in the single digits. A caller who knows or guesses one SUPI can enumerate sessions 0 through 15 with sixteen GETs and pull every active policy bound to that subscriber. The Create endpoint, also unauthenticated, returns a `USER_UNKNOWN` problem detail for SUPIs that are not provisioned and proceeds for ones that are. The same endpoint is an existence oracle for any SUPI the caller wishes to test.\n\n```bash\ncurl -s http://pcf:8000/npcf-smpolicycontrol/v1/sm-policies/imsi-208930000000001-1\n# {\"context\":{\"supi\":\"imsi-208930000000001\",\"pei\":\"imeisv-3556790100123456\",\n# \"gpsi\":\"msisdn-33611223344\",\"pduSessionId\":1,\"dnn\":\"internet\",\n# \"ipv4Address\":\"10.60.0.2\",\"userLocationInfo\":{...},\n# \"servingNetwork\":{\"mcc\":\"208\",\"mnc\":\"93\"},...},\n# \"policy\":{...}}\n```\n\nThe bearer IP, the cell, the device IMEISV, the subscriber's phone number, the home and serving networks, all in one response, returned to a caller who attached no credentials of any kind.\n\n## The fix is eight lines\n\nCommit `599803b`, March 5, 2026, \"fix(pcf): add missing auth middleware to smPolicyGroup and uePolicyGroup\":\n\n```diff\n smPolicyRoutes := s.getSmPolicyRoutes()\n smPolicyGroup := s.router.Group(factory.PcfSMpolicyCtlResUriPrefix)\n+smRouterAuthorizationCheck := util.NewRouterAuthorizationCheck(models.ServiceName_NPCF_SMPOLICYCONTROL)\n+smPolicyGroup.Use(func(c *gin.Context) {\n+ smRouterAuthorizationCheck.Check(c, s.Context())\n+})\n applyRoutes(smPolicyGroup, smPolicyRoutes)\n\n uePolicyRoutes := s.getUePolicyRoutes()\n uePolicyGroup := s.router.Group(factory.PcfUePolicyCtlResUriPrefix)\n+uePolicyRouterAuthorizationCheck := util.NewRouterAuthorizationCheck(models.ServiceName_NPCF_UE_POLICY_CONTROL)\n+uePolicyGroup.Use(func(c *gin.Context) {\n+ uePolicyRouterAuthorizationCheck.Check(c, s.Context())\n+})\n applyRoutes(uePolicyGroup, uePolicyRoutes)\n```\n\nEight new lines. Four for SMPolicy, four for UEPolicy. They are character-for-character what the four already-gated groups in the same function looked like, with the service-name constant and the variable prefix substituted. The patch's commit message says: \"Add auth middleware to both groups following the same pattern used by amPolicyGroup, bdtPolicyGroup, oamGroup, and policyAuthorizationGroup.\"\n\nA second commit, `f56a548`, March 12, 2026, added the same five-line pattern to `httpcallbackGroup`. Twelve days later, commit `7fdc2dd` retrofitted the OAuth check onto the consumer-side notification path. Three patches over March 2026, three implementations of a pattern already documented four times over in the same file since May 2024.\n\nThe underlying `RouterAuthorizationCheck` is forty lines of Go and was introduced in commit `cf2fa01` on January 31, 2024. Its `Check` method, with the abort behavior the unguarded routes had been missing:\n\n```go\nfunc (rac *RouterAuthorizationCheck) Check(c *gin.Context, pcfContext pcf_context.NFContext) {\n token := c.Request.Header.Get(\"Authorization\")\n err := pcfContext.AuthorizationCheck(token, rac.serviceName)\n if err != nil {\n logger.UtilLog.Debugf(\"RouterAuthorizationCheck::Check Unauthorized: %s\", err)\n c.JSON(http.StatusUnauthorized, gin.H{\"error\": err.Error()})\n c.Abort()\n return\n }\n}\n```\n\nThe function existed before the route registrations did. The four gated groups call it. The three unguarded groups never imported it.\n\n## Parallel implementation gap, same file, forty lines apart\n\nThis is [parallel-implementation-gap](/patterns/parallel-implementation-gap). The pattern describes a capability implemented by parallel modules, where a shared utility holds a security check and the canonical module imports it while a divergent one does not. The shape here is denser than that. The parallel implementations are not in separate files. They are in the same function, the same forty-line stretch, written by the same author in one sitting on May 29, 2024 (commit `0cee90c`, \"fix: new sbiServer bug\"). That commit added the auth-check pattern to four of the seven groups simultaneously and skipped three.\n\nThe version we covered in [CVE-2026-27771, Gitea's container module not importing `GetDoerRepoPermission`](/posts/gitea-cve-2026-27771-reqcontaineraccess-knows-no-container) had ten divergent implementations across ten package handlers; the canonical lived in the repository module. The free5GC version has three divergent implementations in the same router function as four canonical ones. The seam between \"this group is protected\" and \"this group is not\" is the visual distance between a five-line block and a three-line block, on the same indent level, separated by two blank lines.\n\nThe SMPolicyControl group is the only one of the three that returns subscriber data. The UEPolicyControl handlers in `internal/sbi/api_uepolicy.go` all return `http.StatusNotImplemented`:\n\n```go\nfunc (s *Server) HTTPReadIndividualUEPolicyAssociation(c *gin.Context) {\n c.JSON(http.StatusNotImplemented, gin.H{})\n}\n```\n\nThe patch closes three doors. Behind one of them was the SUPI. Behind the other two were empty rooms. The CVE assignment, CVE-2026-42083, attaches only to the door with something behind it. The reporter, LinZiyuu, filed GHSA-6rgm-gr97-x3j5 on May 7, 2026, sixty-three days after the patch landed.\n\n## The thing 3GPP cryptographically conceals on the radio, free5GC handed to a TCP listener\n\nThe SUPI is the 5G replacement for the IMSI. The redesign was driven by the IMSI-catcher problem: in LTE and earlier generations, a rogue base station could broadcast that it was the strongest cell in range and harvest the IMSI from any UE that attached. 3GPP TS 33.501 closes the channel by mandating that the SUPI never leave a UE without being wrapped in a SUCI, an ECIES envelope keyed to the home network's public key. The standard enumerates the cipher suites across clause 6.12 and annex C. The threat model is explicit: the SUPI is a long-term identifier whose disclosure correlates a subscriber across networks and across time, and the radio is a hostile medium.\n\nThe threat model on the SBI side, the wired side of the core, is also explicit. 3GPP TS 33.501 clause 13 mandates OAuth2 access tokens issued by the NRF for every SBI request between network functions. The PCF's `RouterAuthorizationCheck` is the local implementation of that requirement. The standard does not contemplate the case where the network function declines to apply the check.\n\nfree5GC did not decline. free5GC wrote the check, wrote four examples of it correctly, and wrote three route groups whose middleware chain stopped short of the call. For twenty-one months, an operator running free5GC's PCF with a reachable port was running a 5G core whose air interface dutifully wrapped the SUPI in ECIES and whose Service-Based Interface dutifully returned it in JSON.\n\nPoC: [GHSA-6rgm-gr97-x3j5](https://github.com/advisories/GHSA-6rgm-gr97-x3j5)","closing_line":"The patch is eight lines. They mirror eight lines already in the same function.","hook_md":"3GPP rewrote 5G's air-interface authentication so the SUPI, the permanent identifier of a SIM card, would never traverse a radio in cleartext. TS 33.501 specifies elliptic-curve concealment under the home network's public key. The standard's authors gave the wrapped form a separate name, SUCI, to mark it as the form a base station is permitted to see. CVE-2026-42083 is what happens when the network function that holds the unwrapped SUPI, the free5GC PCF, accepts an HTTP GET for it without an OAuth token attached.\n\nThe same `NewServer` function that registered the unprotected route group held four working examples of how to attach the OAuth gate, forty lines apart. Three route groups skipped it. The CVE catches one.","post_id":530,"slug":"free5gc-pcf-cve-2026-42083-supi-served-over-unauth-get","title":"CVE-2026-42083: free5GC's PCF Served The SUPI To Anyone Who Could Reach The Port","type":"initial","unreadable_sentence":"For twenty-one months, the function that built free5GC's SBI router held four working examples of how to attach the OAuth gate and three route groups it never attached it to."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCawcidAAKCRDeZjl4jgkQ JupTAQCFU0hjLMb1J74Yu56FS7LqsyORtzlrzXn4ensQQU5lDQD6AqJnM0P19vjA eks4YkZUxVPYvCi+7a6W1+6dh/wLywY= =b8Un -----END PGP SIGNATURE-----