The same function held four working examples of the right pattern
free5GC 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.
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.
Four of the seven groups follow that pattern. This is the form they take in v1.4.2, the version the CVE names as vulnerable:
amPolicyRoutes := s.getAmPolicyRoutes()
amPolicyGroup := s.router.Group(factory.PcfAMpolicyCtlResUriPrefix)
amRouterAuthorizationCheck := util.NewRouterAuthorizationCheck(models.ServiceName_NPCF_AM_POLICY_CONTROL)
amPolicyGroup.Use(func(c *gin.Context) {
amRouterAuthorizationCheck.Check(c, s.Context())
})
applyRoutes(amPolicyGroup, amPolicyRoutes)
bdtPolicyRoutes := s.getBdtPolicyRoutes()
bdtPolicyGroup := s.router.Group(factory.PcfBdtPolicyCtlResUriPrefix)
bdtRouterAuthorizationCheck := util.NewRouterAuthorizationCheck(models.ServiceName_NPCF_BDTPOLICYCONTROL)
bdtPolicyGroup.Use(func(c *gin.Context) {
bdtRouterAuthorizationCheck.Check(c, s.Context())
})
applyRoutes(bdtPolicyGroup, bdtPolicyRoutes)
The 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.
Three groups in the same function are not gated. SMPolicyControl, the group the CVE names:
smPolicyRoutes := s.getSmPolicyRoutes()
smPolicyGroup := s.router.Group(factory.PcfSMpolicyCtlResUriPrefix)
applyRoutes(smPolicyGroup, smPolicyRoutes)
UEPolicyControl, immediately below it:
uePolicyRoutes := s.getUePolicyRoutes()
uePolicyGroup := s.router.Group(factory.PcfUePolicyCtlResUriPrefix)
applyRoutes(uePolicyGroup, uePolicyRoutes)
The npcf-callback group, which receives notifications from the UDR:
httpcallbackRoutes := s.getHttpCallBackRoutes()
httpcallbackGroup := s.router.Group(factory.PcfCallbackResUriPrefix)
applyRoutes(httpcallbackGroup, httpcallbackRoutes)
Three 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.
The endpoint returns the identifier 5G was redesigned to conceal
The getSmPolicyRoutes function lists four routes:
func (s *Server) getSmPolicyRoutes() []Route {
return []Route{
{Name: "CreateSMPolicy", Method: http.MethodPost,
Pattern: "/sm-policies", APIFunc: s.HTTPCreateSMPolicy},
{Name: "DeleteSMPolicy", Method: http.MethodPost,
Pattern: "/sm-policies/:smPolicyId/delete", APIFunc: s.HTTPDeleteSMPolicy},
{Name: "GetSMPolicy", Method: http.MethodGet,
Pattern: "/sm-policies/:smPolicyId", APIFunc: s.HTTPGetSMPolicy},
{Name: "UpdateSMPolicy", Method: http.MethodPost,
Pattern: "/sm-policies/:smPolicyId/update", APIFunc: s.HTTPUpdateSMPolicy},
}
}
The GET handler in internal/sbi/processor/smpolicy.go:
func (p *Processor) HandleGetSmPolicyContextRequest(
c *gin.Context,
smPolicyId string,
) {
ue := p.Context().PCFUeFindByPolicyId(smPolicyId)
if ue == nil || ue.SmPolicyData[smPolicyId] == nil {
problemDetail := util.GetProblemDetail("smPolicyID not found in PCF", util.CONTEXT_NOT_FOUND)
c.JSON(int(problemDetail.Status), problemDetail)
return
}
smPolicyData := ue.SmPolicyData[smPolicyId]
response := &models.SmPolicyControl{
Policy: smPolicyData.PolicyDecision,
Context: smPolicyData.PolicyContext,
}
c.JSON(http.StatusOK, response)
}
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:
type SmPolicyContextData struct {
Gpsi string `json:"gpsi,omitempty"`
Supi string `json:"supi"`
InvalidSupi bool `json:"invalidSupi,omitempty"`
InterGrpIds []string `json:"interGrpIds,omitempty"`
PduSessionId int32 `json:"pduSessionId"`
Dnn string `json:"dnn"`
NotificationUri string `json:"notificationUri"`
AccessType AccessType `json:"accessType,omitempty"`
ServingNetwork *PlmnIdNid `json:"servingNetwork,omitempty"`
UserLocationInfo *UserLocation `json:"userLocationInfo,omitempty"`
UeTimeZone string `json:"ueTimeZone,omitempty"`
Pei string `json:"pei,omitempty"`
Ipv4Address string `json:"ipv4Address,omitempty"`
Ipv6AddressPrefix string `json:"ipv6AddressPrefix,omitempty"`
// ...
}
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.
Every 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.
The path parameter smPolicyId is not random. HandleCreateSmPolicyRequest, in the same file, constructs it:
smPolicyID := fmt.Sprintf("%s-%d", ue.Supi, request.PduSessionId)
The format is <SUPI>-<PduSessionId>. 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.
curl -s http://pcf:8000/npcf-smpolicycontrol/v1/sm-policies/imsi-208930000000001-1
# {"context":{"supi":"imsi-208930000000001","pei":"imeisv-3556790100123456",
# "gpsi":"msisdn-33611223344","pduSessionId":1,"dnn":"internet",
# "ipv4Address":"10.60.0.2","userLocationInfo":{...},
# "servingNetwork":{"mcc":"208","mnc":"93"},...},
# "policy":{...}}
The 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.
The fix is eight lines
Commit 599803b, March 5, 2026, "fix(pcf): add missing auth middleware to smPolicyGroup and uePolicyGroup":
smPolicyRoutes := s.getSmPolicyRoutes()
smPolicyGroup := s.router.Group(factory.PcfSMpolicyCtlResUriPrefix)
+smRouterAuthorizationCheck := util.NewRouterAuthorizationCheck(models.ServiceName_NPCF_SMPOLICYCONTROL)
+smPolicyGroup.Use(func(c *gin.Context) {
+ smRouterAuthorizationCheck.Check(c, s.Context())
+})
applyRoutes(smPolicyGroup, smPolicyRoutes)
uePolicyRoutes := s.getUePolicyRoutes()
uePolicyGroup := s.router.Group(factory.PcfUePolicyCtlResUriPrefix)
+uePolicyRouterAuthorizationCheck := util.NewRouterAuthorizationCheck(models.ServiceName_NPCF_UE_POLICY_CONTROL)
+uePolicyGroup.Use(func(c *gin.Context) {
+ uePolicyRouterAuthorizationCheck.Check(c, s.Context())
+})
applyRoutes(uePolicyGroup, uePolicyRoutes)
Eight 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."
A 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.
The 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:
func (rac *RouterAuthorizationCheck) Check(c *gin.Context, pcfContext pcf_context.NFContext) {
token := c.Request.Header.Get("Authorization")
err := pcfContext.AuthorizationCheck(token, rac.serviceName)
if err != nil {
logger.UtilLog.Debugf("RouterAuthorizationCheck::Check Unauthorized: %s", err)
c.JSON(http.StatusUnauthorized, gin.H{"error": err.Error()})
c.Abort()
return
}
}
The function existed before the route registrations did. The four gated groups call it. The three unguarded groups never imported it.
Parallel implementation gap, same file, forty lines apart
This is 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.
The version we covered in CVE-2026-27771, Gitea's container module not importing GetDoerRepoPermission 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.
The 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:
func (s *Server) HTTPReadIndividualUEPolicyAssociation(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
The 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.
The thing 3GPP cryptographically conceals on the radio, free5GC handed to a TCP listener
The 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.
The 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.
free5GC 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.
PoC: GHSA-6rgm-gr97-x3j5
The patch is eight lines. They mirror eight lines already in the same function.