-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The cleanup label asserts on a sentinel the developer was supposed to overwrite\n\nThe function lives in `src/pcf/nbsf-handler.c`. The shape is unremarkable on first read:\n\n```c\nbool pcf_nbsf_management_handle_register(\n pcf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg)\n{\n int rv, status = 0;\n char *strerror = NULL;\n /* ... */\n\n /* validation, header parsing, client setup */\n\n return rc;\n\ncleanup:\n ogs_assert(strerror);\n ogs_assert(status);\n ogs_error(\"%s\", strerror);\n ogs_assert(true == ogs_sbi_server_send_error(\n stream, status, recvmsg, strerror, NULL, NULL));\n ogs_free(strerror);\n\n return false;\n}\n```\n\n`ogs_assert` is not a logging macro. The definition lives in `lib/core/ogs-log.h`:\n\n```c\n#define ogs_assert(expr) \\\n do { \\\n if (ogs_likely(expr)) ; \\\n else { \\\n ogs_fatal(\"%s: Assertion `%s' failed.\", OGS_FUNC, #expr); \\\n ogs_abort(); \\\n } \\\n } while(0)\n```\n\n`ogs_abort()` calls the libc `abort()`. The PCF process dies, the policy plane disappears from the 5G core, and every active session that was waiting on a policy decision gets nothing.\n\nThe contract `ogs_assert(status)` encodes is straightforward in isolation. Before any code path jumps to `cleanup:`, that code path must assign a non-zero HTTP status code to `status`. The cleanup label uses `status` to build the error response back to whichever client kicked off the chain. A zero value would produce a malformed response. The assertion enforces that the developer wrote the line.\n\nThe contract `int status = 0` encodes is the opposite. It says: until something else sets it, the value is zero.\n\nBoth contracts apply to the same variable. The assertion fires when only the second one has run.\n\n## Four of six paths leave the sentinel intact\n\nHere is the full set of `goto cleanup` jumps in the function, with the relevant code shown.\n\nPath 1, lines 56 through 60. No `Location` header at all:\n\n```c\nif (!recvmsg->http.location) {\n strerror = ogs_msprintf(\"[%s:%d] No http.location\",\n pcf_ue_sm->supi, sess->psi);\n status = OGS_SBI_HTTP_STATUS_BAD_REQUEST;\n goto cleanup;\n}\n```\n\nPath 2, lines 63 through 67. No `PcfBinding` body:\n\n```c\nif (!recvmsg->PcfBinding) {\n strerror = ogs_msprintf(\"[%s:%d] No PcfBinding\",\n pcf_ue_sm->supi, sess->psi);\n status = OGS_SBI_HTTP_STATUS_BAD_REQUEST;\n goto cleanup;\n}\n```\n\nPath 3, lines 80 through 84. URI parse failure:\n\n```c\nrv = ogs_sbi_parse_header(&message, &header);\nif (rv != OGS_OK) {\n strerror = ogs_msprintf(\"[%s:%d] Cannot parse http.location [%s]\",\n pcf_ue_sm->supi, sess->psi, recvmsg->http.location);\n goto cleanup;\n}\n```\n\nPath 4, lines 87 through 93. No binding ID component in the parsed URI:\n\n```c\nif (!message.h.resource.component[1]) {\n strerror = ogs_msprintf(\"[%s:%d] No Binding ID [%s]\",\n pcf_ue_sm->supi, sess->psi, recvmsg->http.location);\n\n ogs_sbi_header_free(&header);\n goto cleanup;\n}\n```\n\nPath 5, lines 95 through 102. Invalid URI in the location header:\n\n```c\nrc = ogs_sbi_getaddr_from_uri(\n &scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);\nif (rc == false || scheme == OpenAPI_uri_scheme_NULL) {\n strerror = ogs_msprintf(\"[%s:%d] Invalid URI [%s]\",\n pcf_ue_sm->supi, sess->psi, header.uri);\n ogs_sbi_header_free(&header);\n goto cleanup;\n}\n```\n\nPath 6, lines 105 through 118. Client allocation failure:\n\n```c\nclient = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);\nif (!client) {\n /* ... */\n client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);\n if (!client) {\n strerror = ogs_msprintf(\"[%s:%d] ogs_sbi_client_add() failed\",\n pcf_ue_sm->supi, sess->psi);\n /* free locals */\n goto cleanup;\n }\n}\n```\n\nPaths 1 and 2 assign `status = OGS_SBI_HTTP_STATUS_BAD_REQUEST`. Paths 3 through 6 do not. Every one of paths 3 through 6 reaches `ogs_assert(status)` with `status == 0`.\n\nLinZiyuu's reproduction in issue #4437 picks Path 4. The setup runs a fake BSF on port 18080 and answers the PCF's `POST /nbsf-management/v1/pcfBindings` with `201 Created` and a `Location` header whose value is the URI with the `{bindingId}` segment stripped off. Control-case URI:\n\n```\nLocation: http://10.33.33.1:18080/nbsf-management/v1/pcfBindings/binding-ok\n```\n\nCrashing-case URI:\n\n```\nLocation: http://10.33.33.1:18080/nbsf-management/v1/pcfBindings\n```\n\nThe SBI parser at line 80 succeeds, because the URI is still a valid URI. Line 87 then reads `message.h.resource.component[1]`, the path segment after `pcfBindings`. There is none. The branch enters, `strerror` is set, the header is freed, and the function jumps to cleanup with `status` still zero. The crash signature, copied from the issue, is:\n\n```\nFATAL: pcf_nbsf_management_handle_register:\n Assertion `status' failed. (../src/pcf/nbsf-handler.c:139)\n```\n\nPaths 3, 5, and 6 each end the same way. A peer BSF that returns a Location header the SBI parser refuses outright, a Location header pointing at an unparseable URI, or a Location header pointing at an address the SBI client layer cannot construct an outbound socket for, all reach `ogs_assert(status)` with `status == 0`. The reporter named one of four equivalent triggers.\n\n## ogs_expect is in the same file, in the same function\n\nTwo lines above the `return rc;` that exits on the success path, the code does this:\n\n```c\nrc = pcf_sbi_send_smpolicycontrol_create_response(sess, stream);\nogs_expect(rc == true);\n```\n\n`ogs_expect` is the non-fatal twin of `ogs_assert`. Its definition is a few lines below `ogs_assert` in the same header:\n\n```c\n#define ogs_expect(expr) \\\n do { \\\n if (ogs_likely(expr)) ; \\\n else { \\\n ogs_error(\"%s: Expectation `%s' failed.\", OGS_FUNC, #expr); \\\n } \\\n } while (0)\n```\n\nWhen the success-path response send to the SMF fails, the PCF logs and continues. When `status == 0` at cleanup because a developer forgot to write one line, the PCF aborts. The author knew there were two macros. The author picked one for \"the network might fail\" and the other for \"the local variable might be wrong.\" The one that fires on local-variable bugs is the fatal one.\n\n## Every other handler in Open5GS gets the discipline right\n\nThe `ogs_assert(strerror); ogs_assert(status)` cleanup epilogue is not specific to `pcf_nbsf_management_handle_register`. It is the codebase's standard idiom for SBI handlers. The same shape appears in:\n\n- `src/pcf/npcf-handler.c` (43 goto-cleanup paths)\n- `src/udr/nudr-handler.c` (18 paths)\n- `src/pcf/nudr-handler.c` (5 paths)\n- `src/bsf/nbsf-handler.c` (5 paths)\n- `src/pcf/sbi-path.c` (4 paths)\n\nSeventy-five `goto cleanup` sites across those five files. Every one of them sets `status` to a real HTTP status code before jumping. A scripted pass over each file finds zero missing assignments outside of `pcf/nbsf-handler.c`. The convention is universal across the codebase. The only function that fails to maintain it is the one this CVE names.\n\nThe convention exists nowhere except in the maintainer's hand and the reviewer's eye. `int status = 0` is a legal C declaration. `goto cleanup` followed eventually by `ogs_assert(status)` is a legal C control flow. A compiler with `-Wuninitialized` cannot warn, because `status` is initialized. A static analyzer that does not know the project's convention has no way to flag the four missing assignments as wrong. The discipline runs on the same enforcement budget as a comment.\n\nThis is the substrate. The patch for CVE-2026-8222, when the maintainer writes it, will be four lines. Each line will assign an appropriate `OGS_SBI_HTTP_STATUS_*` value to `status` in one of the four bare branches. The four lines will close the four paths. They will not change the shape of the cleanup epilogue. They will not retire `int status = 0`. They will not replace `ogs_assert(status)` with a comparison that handles the zero case explicitly. Every future handler that copies this idiom, and Open5GS's SBI layer is largely written by copying this idiom, will inherit the same fatal-on-developer-oversight design. This is what makes the construction a **design-debt-driver**: the patch closes instances; the substrate produces them.\n\n## The reporter named the function and the line. The vendor has not replied.\n\nThe disclosure timeline lives entirely in the public record.\n\n- April 20, 2026: GitHub user `LinZiyuu` opens issue #4437 against `open5gs/open5gs`. Title: \"PCF crash on malformed BSF register `Location` during `POST /npcf-smpolicycontrol/v1/sm-policies`.\" The body includes a complete reproduction: the fake BSF on `10.33.33.1:18080`, the JSON payload that drives the SM Policy Association request, the exact `Location` header that triggers the abort, the file path, the line number, and the crash output.\n- May 10, 2026: VulDB cuts CVE-2026-8222 and publishes the entry. NVD ingests the same day. The CVSS vector is `AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L`, score 5.3, CWE-404.\n- May 19, 2026: The Open5GS master branch ships a commit titled `sbi: reject invalid discovery parameters`. The commit touches other files. `src/pcf/nbsf-handler.c` is not modified.\n- May 20, 2026: Issue #4437 is still labeled `triage`. It has zero comments from the project's maintainers. The four bare `goto cleanup` paths in `pcf_nbsf_management_handle_register` are in the same state on `main` they were in on April 20.\n\nThirty days from a reproduction-complete bug report against the policy plane of a widely deployed open-source 5G core to no maintainer touch on the function. The VulDB record notes the gap in its own boilerplate: *\"The project was informed of the problem early through an issue report but has not responded yet.\"* That sentence is the disclosure record's most-stamped phrasing; it appears on roughly every fourth VulDB entry. It also happens, on this CVE, to be accurate.\n\nPoC: [open5gs/open5gs#4437](https://github.com/open5gs/open5gs/issues/4437)","closing_line":"The patch will set `status` on the four paths the reporter named. The convention that produced this bug will sit in the codebase, untouched, ready for the fifth.","hook_md":"Open5GS's PCF handles a BSF registration callback in `pcf_nbsf_management_handle_register`. The function opens with `int status = 0`. It ends with a `cleanup:` label whose first executable line after a `strerror` check is `ogs_assert(status)`. The initial value of `status` is precisely the value that makes that assertion fail. The function has six error paths that reach the cleanup label. Two of them set `status` before jumping. Four of them do not. Any one of those four converts a malformed HTTP response from a peer 5G network function into a process abort. CVE-2026-8222 is the path the reporter happened to trigger first.","post_id":370,"slug":"open5gs-cve-2026-8222-cleanup-asserts-the-init-value","title":"CVE-2026-8222: Open5GS's PCF Asserts on the Same Zero It Just Initialized","type":"initial","unreadable_sentence":"The default value of `status` is the value that makes `ogs_assert(status)` fail. The PCF aborts because the function's first line and the function's last line are the same number."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCak1HWAAKCRDeZjl4jgkQ Jje/AQDBvvykxB4b5GZGgjDPVOhE/50Xlc+cmpYA8Js1GuJ9XwEA1aK6Wu0U+xHW MF56Gw2aSweCOhP8AqTFYhuSSD7Odwk= =K3x0 -----END PGP SIGNATURE-----