-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The PoC is one curl\n\nLinZiyuu filed `free5gc/free5gc#858` on March 11, 2026 against a NEF deployed from free5GC v4.2.0. The issue is now CVE-2026-44315. The proof fits in a single command:\n\n```bash\ncurl -H 'Authorization: Bearer not-a-real-token' \\\n -H 'Content-Type: application/json' \\\n --data '{\"pfdDatas\":{\"app-poc-pfd2\":{\"externalAppId\":\"app-poc-pfd2\",\"pfds\":{\"pfd-poc\":{\"pfdId\":\"pfd-poc\",\"urls\":[\"^http://poc.example.com(/\\\\S*)?$\"]}}}}}' \\\n http://10.100.200.19:8000/3gpp-pfd-management/v1/af-poc-pfd2/transactions\n```\n\nThe bearer token is the literal string `not-a-real-token`. The response is `201 Created`. NEF writes a Packet Flow Description transaction to UDR; SMF and UPF will pick it up on their next poll and apply the new traffic-classification rule. The token's contents do not matter because the token is never read.\n\nThe same curl with `GET` returns `200 OK`, and with `DELETE` returns `204 No Content`. Three operations, three responses, one bearer token that does not exist. PR #30, which closes this issue, closes four others in the same filing: `free5gc/free5gc#858` through `#862`, one per route group NEF exposes. The traffic-influence API, the PFD-management API, the SBI PFDF API, the OAM API, and the inbound SMF callback API were all mounted without inbound middleware. All five were unauthenticated. The researcher filed one issue per route group and waited.\n\nA Packet Flow Description is the rule SMF and UPF consult to decide which traffic belongs to which application, which charging counter to increment, which QoS class to apply, which firewall policy to enforce. An attacker who writes PFDs to UDR through the NEF rewrites the network's understanding of which application traffic is which. The PoC creates a rule that matches `^http://poc.example.com(/\\\\S*)?$`; a real campaign creates a rule that matches the bank traffic of a target subscriber and rewrites its application identity to a free-tier app, or a free-tier app's traffic and rewrites it to the lawful-intercept rule's identity, or the operator's own VoLTE control plane and rewrites it to whatever class the firewall does not inspect. The transaction is durable. SMF and UPF will read it on every relevant flow until someone deletes it. The same `not-a-real-token` deletes it.\n\n## The fix removes four TODO comments\n\nPR #30 lands as commit `c38a82f` on May 13, 2026. The diff against `internal/sbi/processor/pfd.go` is four hunks. Each hunk deletes one line:\n\n```diff\n@@ -67,8 +67,6 @@ func (p *Processor) PostPFDManagementTransactions(\n \tlogger.PFDManageLog.Infof(\"PostPFDManagementTransactions - scsAsID[%s]\", scsAsID)\n \n-\t// TODO: Authorize the AF\n-\n \tnefCtx := p.Context()\n```\n\nThe same removal appears in `PutIndividualPFDManagementTransaction`, `PutIndividualApplicationPFDManagement`, and `PatchIndividualApplicationPFDManagement`. Four handlers, four comments, four deletions. The patch author added no authorization logic in `pfd.go`. The four TODOs were not made true; they were made irrelevant by middleware introduced upstream.\n\n`git blame` resolves the four comments to four separate commits in late 2020. The earliest, `371e4b8`, is dated November 24, 2020 and is titled `feat(nef): Implement PFD Management Transactions GET and POST methods`. The latest is December 18, 2020. The five-week window in which all four TODOs were written corresponds exactly to the period the PFD-management handlers were first implemented. The TODOs are not maintenance debt. They are notes the original author wrote to themselves while implementing the feature, acknowledging that authorization was the thing they were not implementing.\n\nThe note went to production. It stayed there for five years, five months, and nineteen days. Across that span the file was touched by refactors that renamed `pkg` to `app`, moved processor and consumer under `sbi`, simplified mutex handling, added OpenAPI updates for r17, fixed a nil pointer in `PatchIndividualApplicationPFDManagement`, fixed a 204-no-body bug, added inbound and outbound metrics, and added a panic guard on malicious UDR multipart responses. Every one of those passes opened the file in an editor, scrolled past the four `// TODO: Authorize the AF` lines, and saved without acting on them. The TODO was not invisible. The TODO was furniture.\n\n## The flag the startup log advertises is consulted in one direction\n\nThe PFD-management API was added in November 2020. OAuth2 for outbound calls landed in April 2024, in `c8aaef0 feat: NRF consumer Oauth Support`. That commit introduced `OAuth2Required` on the NEF context and the `GetTokenCtx` helper:\n\n```go\nfunc (c *NefContext) GetTokenCtx(\n serviceName models.ServiceName,\n targetNF models.NrfNfManagementNfType,\n) (context.Context, *models.ProblemDetails, error) {\n if !c.OAuth2Required {\n return context.TODO(), nil, nil\n }\n return oauth.GetTokenCtx(models.NrfNfManagementNfType_NEF, targetNF,\n c.nfInstID, c.Config().NrfUri(), string(serviceName))\n}\n```\n\n`OAuth2Required` is set when NEF registers with NRF and reads `oauth2: true` from the NRF response's `CustomInfo` field, in `internal/sbi/consumer/nrf_service.go`:\n\n```go\noauth2 := false\nif nf.CustomInfo != nil {\n v, ok := nf.CustomInfo[\"oauth2\"].(bool)\n if ok {\n oauth2 = v\n logger.MainLog.Infoln(\"OAuth2 setting receive from NRF:\", oauth2)\n }\n}\ns.consumer.Context().OAuth2Required = oauth2\n```\n\nThat is the log line. The operator who reads `OAuth2 setting receive from NRF: true` is reading the value of `OAuth2Required` as it is being set. The value from that moment forward gates every NEF outbound call to UDR or PCF; the call will carry a bearer token NRF signed for the destination service.\n\nInbound, pre-patch, the flag is referenced nowhere. The pre-patch `internal/sbi/server.go` registers five route groups without middleware:\n\n```go\nendpoints := s.getTrafficInfluenceRoutes()\ngroup := s.router.Group(factory.TraffInfluResUriPrefix)\napplyRoutes(group, endpoints)\n\nendpoints = s.getPFDManagementRoutes()\ngroup = s.router.Group(factory.PfdMngResUriPrefix)\napplyRoutes(group, endpoints)\n\nendpoints = s.getPFDFRoutes()\ngroup = s.router.Group(factory.NefPfdMngResUriPrefix)\napplyRoutes(group, endpoints)\n\nendpoints = s.getOamRoutes()\ngroup = s.router.Group(factory.NefOamResUriPrefix)\napplyRoutes(group, endpoints)\n\nendpoints = s.getCallbackRoutes()\ngroup = s.router.Group(factory.NefCallbackResUriPrefix)\napplyRoutes(group, endpoints)\n```\n\nFive `s.router.Group(...)` calls. Zero `group.Use(...)` calls. The route groups mount, the handlers register, the server starts. Every entry the operator sees in the NEF log indicating successful registration is consistent with a network that fully advertises OAuth2 and never enforces it on a single inbound request. free5GC's NEF logged `OAuth2 setting receive from NRF: true` for two years while accepting bearer `not-a-real-token`.\n\n## The TODO named the handler. The bug was the route.\n\nThe TODO comment in `pfd.go` was misleading. It located the missing authorization at the handler. A reader who saw the TODO and decided to fix it would have reached for an authorization decision inside `PostPFDManagementTransactions`. That kind of inline check does not fit the OpenAPI-generated handler shape free5GC's NFs use; the generator emits per-route handlers that assume the surrounding framework gates calls before they arrive.\n\nThe pre-patch server registered routes with no surrounding framework gating calls. The fix is in `server.go`, not in `pfd.go`. The patch adds per-route-group middleware that calls `nef_util.NewRouterAuthorizationCheck(serviceName).Check(c, s.Context())` before any handler runs, and that middleware calls `oauth.VerifyOAuth(token, string(serviceName), c.Config().NrfCertPem())`. `VerifyOAuth` is a function in `free5gc/openapi/oauth`, the same package the outbound consumer code has imported since April 2024. The package exports the inbound check and the outbound issuance side by side. The outbound side has been called for two years. The inbound side, until May 13, was never called by NEF.\n\nThe capability free5GC named OAuth2 is two halves of one library. The consumer half was wired in April 2024 and the log line above announces it. The provider half was named in the same library, available the same way, and was not imported. The four TODOs in `pfd.go` did not document a missing function. They documented a missing import.\n\nThis is the shape our catalog names [Todo That Shipped](/patterns/todo-that-shipped): a comment in security-sensitive code names a control that the adjacent code operates without, and the project lets the combination ship. The Zabbix audit-log primitive we covered as [CVE-2024-22120](/posts/zabbix-cve-2024-22120-audit-log-is-the-read-primitive) is the same shape on a shorter clock: the TODO landed inside the security commit naming the next gap. The free5GC NEF exhibit for CVE-2026-44315 is the longer-clock variant. The TODO landed five years before the security commit and waited.\n\n## The fix is opt-in\n\nThe patched `AuthorizationCheck` reads:\n\n```go\nfunc (c *NefContext) AuthorizationCheck(\n token string,\n serviceName models.ServiceName,\n) error {\n if !c.OAuth2Required {\n logger.CtxLog.Debugf(\"NefContext::AuthorizationCheck: OAuth2 not required\")\n return nil\n }\n logger.CtxLog.Debugf(\n \"NefContext::AuthorizationCheck: tokenPresent[%t] tokenLen[%d] serviceName[%s]\",\n token != \"\", len(token), serviceName,\n )\n return oauth.VerifyOAuth(token, string(serviceName), c.Config().NrfCertPem())\n}\n```\n\n`OAuth2Required` defaults to false. It is set true only if the operator's NRF returns `oauth2: true` in its registration response. The default `nrfcfg.yaml` shipped by free5GC's NRF reference deployment does not set this field; an operator who deploys the reference stack as-is gets `OAuth2Required = false` on every NF in the network. After PR #30, the inbound check runs and returns nil. The behavior is identical to the pre-patch behavior. The audit log writes `OAuth2 not required` at debug level, where most production deployments have the log level set above debug.\n\nThe operator who reads `OAuth2 setting receive from NRF: false` in their startup log and assumes that means their NEF is unauthenticated is correct. The operator who reads `OAuth2 setting receive from NRF: true` after applying the patch is, finally, also correct. The operator who is still on `nef v1.2.3` and earlier reads either value with the same outcome.\n\nGHSA-5f62-53r8-qrqf was published by free5GC maintainer Alonza0314 on May 7, 2026, six days before the PR was merged. The advisory's affected-versions field reads `<= 1.2.3`. The patched-versions field is empty. There is no tagged release containing the fix as of the advisory's publication; an operator clicking through to the project to obtain the patched version for CVE-2026-44315 finds none. The advisory cites a CVSS of 9.4, which is the only quantitative claim in the record that is not a citation of LinZiyuu's curl. The 9.4 is the number a 5G operator's procurement team reads when they decide whether the testbed they are evaluating can move to a pilot deployment.\n\nPoC: [free5gc/free5gc#858](https://github.com/free5gc/free5gc/issues/858)","closing_line":"The PoC could have been written the day after the November 2020 commit. The five-and-a-half years before anyone wrote it are the years no one inside the project tried.","hook_md":"free5GC's NEF startup log includes the line `OAuth2 setting receive from NRF: true`. It is the line a 5G testbed operator reads to confirm that the NEF instance just registered with NRF will participate in the network's OAuth2 token flow. The flag the log describes is consulted on every outbound call NEF makes to UDR or PCF, signing each request with a bearer token NRF authorizes. It is not consulted on inbound calls. There is no code path that consults it on inbound calls. The middleware that would have done so existed in the codebase as `// TODO: Authorize the AF` on November 24, 2020 and shipped as exactly that comment until May 13, 2026.","post_id":355,"slug":"free5gc-cve-2026-44315-oauth-outbound-todo-inbound","title":"CVE-2026-44315: free5GC's NEF Wired OAuth Outbound. The Inbound Path Was a TODO.","type":"initial","unreadable_sentence":"free5GC's NEF logged `OAuth2 setting receive from NRF: true` for two years while accepting bearer `not-a-real-token`."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaj65xAAKCRDeZjl4jgkQ Jq1hAQCQhvDeq3AMYcWWUqg5le4Q1QcoRijmwD07n7OXp5972gEAmakw15CKSsH0 kT3MRT1zqG6uvPJAHi0/vw+HFCncJwM= =h2Mo -----END PGP SIGNATURE-----