//nefariousplan

CVE-2026-8222: Open5GS's PCF Asserts on the Same Zero It Just Initialized

vendor

pattern

cve

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.

The cleanup label asserts on a sentinel the developer was supposed to overwrite

The function lives in src/pcf/nbsf-handler.c. The shape is unremarkable on first read:

bool pcf_nbsf_management_handle_register(
    pcf_sess_t *sess, ogs_sbi_stream_t *stream, ogs_sbi_message_t *recvmsg)
{
    int rv, status = 0;
    char *strerror = NULL;
    /* ... */

    /* validation, header parsing, client setup */

    return rc;

cleanup:
    ogs_assert(strerror);
    ogs_assert(status);
    ogs_error("%s", strerror);
    ogs_assert(true == ogs_sbi_server_send_error(
                stream, status, recvmsg, strerror, NULL, NULL));
    ogs_free(strerror);

    return false;
}

ogs_assert is not a logging macro. The definition lives in lib/core/ogs-log.h:

#define ogs_assert(expr) \
    do { \
        if (ogs_likely(expr)) ; \
        else { \
            ogs_fatal("%s: Assertion `%s' failed.", OGS_FUNC, #expr); \
            ogs_abort(); \
        } \
    } while(0)

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.

The 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.

The contract int status = 0 encodes is the opposite. It says: until something else sets it, the value is zero.

Both contracts apply to the same variable. The assertion fires when only the second one has run.

Four of six paths leave the sentinel intact

Here is the full set of goto cleanup jumps in the function, with the relevant code shown.

Path 1, lines 56 through 60. No Location header at all:

if (!recvmsg->http.location) {
    strerror = ogs_msprintf("[%s:%d] No http.location",
            pcf_ue_sm->supi, sess->psi);
    status = OGS_SBI_HTTP_STATUS_BAD_REQUEST;
    goto cleanup;
}

Path 2, lines 63 through 67. No PcfBinding body:

if (!recvmsg->PcfBinding) {
    strerror = ogs_msprintf("[%s:%d] No PcfBinding",
            pcf_ue_sm->supi, sess->psi);
    status = OGS_SBI_HTTP_STATUS_BAD_REQUEST;
    goto cleanup;
}

Path 3, lines 80 through 84. URI parse failure:

rv = ogs_sbi_parse_header(&message, &header);
if (rv != OGS_OK) {
    strerror = ogs_msprintf("[%s:%d] Cannot parse http.location [%s]",
            pcf_ue_sm->supi, sess->psi, recvmsg->http.location);
    goto cleanup;
}

Path 4, lines 87 through 93. No binding ID component in the parsed URI:

if (!message.h.resource.component[1]) {
    strerror = ogs_msprintf("[%s:%d] No Binding ID [%s]",
            pcf_ue_sm->supi, sess->psi, recvmsg->http.location);

    ogs_sbi_header_free(&header);
    goto cleanup;
}

Path 5, lines 95 through 102. Invalid URI in the location header:

rc = ogs_sbi_getaddr_from_uri(
        &scheme, &fqdn, &fqdn_port, &addr, &addr6, header.uri);
if (rc == false || scheme == OpenAPI_uri_scheme_NULL) {
    strerror = ogs_msprintf("[%s:%d] Invalid URI [%s]",
            pcf_ue_sm->supi, sess->psi, header.uri);
    ogs_sbi_header_free(&header);
    goto cleanup;
}

Path 6, lines 105 through 118. Client allocation failure:

client = ogs_sbi_client_find(scheme, fqdn, fqdn_port, addr, addr6);
if (!client) {
    /* ... */
    client = ogs_sbi_client_add(scheme, fqdn, fqdn_port, addr, addr6);
    if (!client) {
        strerror = ogs_msprintf("[%s:%d] ogs_sbi_client_add() failed",
                pcf_ue_sm->supi, sess->psi);
        /* free locals */
        goto cleanup;
    }
}

Paths 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.

LinZiyuu'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:

Location: http://10.33.33.1:18080/nbsf-management/v1/pcfBindings/binding-ok

Crashing-case URI:

Location: http://10.33.33.1:18080/nbsf-management/v1/pcfBindings

The 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:

FATAL: pcf_nbsf_management_handle_register:
       Assertion `status' failed. (../src/pcf/nbsf-handler.c:139)

Paths 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.

ogs_expect is in the same file, in the same function

Two lines above the return rc; that exits on the success path, the code does this:

rc = pcf_sbi_send_smpolicycontrol_create_response(sess, stream);
ogs_expect(rc == true);

ogs_expect is the non-fatal twin of ogs_assert. Its definition is a few lines below ogs_assert in the same header:

#define ogs_expect(expr) \
    do { \
        if (ogs_likely(expr)) ; \
        else { \
            ogs_error("%s: Expectation `%s' failed.", OGS_FUNC, #expr); \
        } \
    } while (0)

When 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.

Every other handler in Open5GS gets the discipline right

The 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:

  • src/pcf/npcf-handler.c (43 goto-cleanup paths)
  • src/udr/nudr-handler.c (18 paths)
  • src/pcf/nudr-handler.c (5 paths)
  • src/bsf/nbsf-handler.c (5 paths)
  • src/pcf/sbi-path.c (4 paths)

Seventy-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.

The 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.

This 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.

The reporter named the function and the line. The vendor has not replied.

The disclosure timeline lives entirely in the public record.

  • 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.
  • 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.
  • 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.
  • 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.

Thirty 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.

PoC: open5gs/open5gs#4437

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.