Bug 2587624
| Summary: | CVE-2026-140063 mingw-glib2: Authenticated DoS via pre-emptive 128MiB read-buffer allocation in GDBusWorker [fedora-all] | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Marco Benatto <mbenatto> |
| Component: | mingw-glib2 | Assignee: | Kalev Lember <kalevlember> |
| Status: | NEW --- | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | rawhide | CC: | fedora, kalevlember, manisandro, marcandre.lureau, rich |
| Target Milestone: | --- | Keywords: | Security, SecurityTracking |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | {"flaws": ["0bbb4380-6de2-48d4-9f9b-afbd4145503d"]} | ||
| Fixed In Version: | Doc Type: | --- | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | Type: | --- | |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | |||
| Bug Blocks: | 2471775 | ||
Disclaimer: Community trackers are created by Red Hat Product Security team on a best effort basis. Package maintainers are required to ascertain if the flaw indeed affects their package, before starting the update process. AI_ONLY_REPORT package: glib2-2.88.0-1.1.hum1 ------ Summary: Authenticated DoS via pre-emptive 128MiB read-buffer allocation in GDBusWorker: after D-Bus authentication, a peer can advertise an accepted 128MiB total message size in the initial 16-byte header and trigger immediate large per-connection allocation before any body bytes are received. Requirements to exploit: The attacker must reach a server-side GDBus peer endpoint using this package, complete D-Bus authentication and send `BEGIN`, and keep enough concurrent authenticated connections open to exhaust the target's memory. Component affected: `glib2-2.88.0-1.1.hum1`, `gio/gdbusprivate.c` (`_g_dbus_worker_do_read_cb()`, `_g_dbus_worker_do_read_unlocked()`) and `gio/gdbusmessage.c` (`g_dbus_message_bytes_needed()`). Version affected: `glib2-2.88.0-1.1.hum1`; reachability depends on applications exposing authenticated server-side GDBus peer connections. Patch available: no released package fix established; proposed patch included below Version fixed: unknown Upstream coordination: Not notified. CVSS: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H - 6.5 (MEDIUM) AV:N - Exploitation is possible over an exposed GDBus peer connection when an application makes that endpoint reachable to the attacker. AC:L - After authentication, the attack only requires sending a valid 16-byte header and stalling; no race or special environment is needed. PR:L - The vulnerable read path is entered only after the peer completes D-Bus authentication or is otherwise accepted by the service's authentication policy. UI:N - No user interaction is required. S:U - The impact is limited to the vulnerable service process. C:N - No confidentiality impact is established. I:N - No integrity impact is established. A:H - Each connection can force an immediate allocation of roughly 128MiB; repeating this across connections can exhaust memory and terminate the process. Impact: Moderate. This is a real availability issue, but it does not provide code execution or data compromise, and it depends on an application built from this package exposing server-side GDBus peer connections to authenticated clients. Under Red Hat severity guidance, the availability impact is meaningful, but the authentication and deployment prerequisites make `Moderate` more appropriate than `Important`. Embargo: no Reason: This is an availability-only issue with authentication and deployment prerequisites, and Red Hat guidance generally does not embargo moderate findings with straightforward mitigations. Acknowledgement: Aisle Research Vulnerability Details: The vulnerable path is entered after D-Bus authentication completes and message processing begins. Once `GDBusWorker` has received the first 16 bytes of a D-Bus message, it computes the full message length, stores that total in `read_buffer_bytes_wanted`, and immediately re-enters the read path. The read helper then resizes the buffer to the full advertised message size before the body is received. A minimal `GDBusServer` can accept any successfully authenticated peer unless the application enables stricter authorization. ```c message_len = g_dbus_message_bytes_needed ((guchar *) worker->read_buffer, 16, &error); ... worker->read_buffer_bytes_wanted = message_len; _g_dbus_worker_do_read_unlocked (worker); ``` ```c if (worker->read_buffer == NULL || worker->read_buffer_bytes_wanted > worker->read_buffer_allocated_size) { /* TODO: 4096 is randomly chosen; might want a better chosen default minimum */ worker->read_buffer_allocated_size = MAX (worker->read_buffer_bytes_wanted, 4096); worker->read_buffer = g_realloc (worker->read_buffer, worker->read_buffer_allocated_size); } ``` `g_dbus_message_bytes_needed()` accepts any total message length up to and including 128MiB: ```c if (blob[0] == 'l') { /* core header (12 bytes) + ARRAY of STRUCT of (BYTE,VARIANT) */ ret = 12 + 4 + GUINT32_FROM_LE (((guint32 *) blob)[3]); /* round up so it's a multiple of 8 */ ret = 8 * ((ret + 7)/8); /* finally add the body size */ ret += GUINT32_FROM_LE (((guint32 *) blob)[1]); } ... if (ret > (1<<27)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "Blob indicates that message exceeds maximum message length (128MiB)"); ret = -1; } ``` A crafted little-endian header with body length `0x07ffffe8` and header-fields array length `0x00000001` produces `12 + 4 + 1 = 17`, rounds to `24`, and then adds `134217704`, giving a `message_len` of `134217728` bytes exactly. Because only values greater than `1<<27` are rejected, that 128MiB size is accepted. The subsequent allocation uses `g_realloc()`, which is process-terminating on allocation failure in this package, so enough stalled authenticated connections can turn the per-connection pre-allocation into process-wide memory exhaustion and service termination. Steps to reproduce: 1. Run an application using server-side GDBus peer connections, such as a minimal `GDBusServer` that accepts authenticated clients. 2. Open many concurrent connections to the service. 3. On each connection, complete D-Bus authentication and send `BEGIN`. 4. Send exactly the following 16-byte little-endian D-Bus header, then stop sending data: `6c 01 00 01 e8 ff ff 07 01 00 00 00 01 00 00 00` 5. This yields `message_len == 134217728` and triggers immediate per-connection allocation growth to roughly 128MiB before any message body is transferred. 6. With enough stalled connections, memory is exhausted and the process terminates when `g_realloc()` fails. Mitigation: Until a code fix is applied, do not expose server-side GDBus peer endpoints to untrusted clients. Prefer `G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER` or a restrictive `GDBusAuthObserver` policy, enforce limits on concurrent and idle authenticated connections, and place affected services under memory limits. These measures reduce exposure but do not remove the eager allocation behavior. Proposed Fix: Grow the read buffer incrementally after header parsing instead of reallocating immediately to the full declared message size. ```diff diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c index XXXXXXX..YYYYYYY 100644 — a/gio/gdbusprivate.c +++ b/gio/gdbusprivate.c @@ -829,6 +829,8 @@ static void _g_dbus_worker_do_read_unlocked (GDBusWorker *worker) { + const gsize READ_AHEAD_CAP = 64 * 1024; + gsize to_read; /* Note that we do need to keep trying to read even if close_expected is true, because only failing a read causes us to signal 'closed'. */ @@ -842,11 +844,26 @@ _g_dbus_worker_do_read_unlocked (GDBusWorker *worker) /* ensure we have a (big enough) buffer */ if (worker->read_buffer == NULL || worker->read_buffer_bytes_wanted > worker->read_buffer_allocated_size) + if (worker->read_buffer == NULL || + worker->read_buffer_cur_size == worker->read_buffer_allocated_size) { /* TODO: 4096 is randomly chosen; might want a better chosen default minimum */ worker->read_buffer_allocated_size = MAX (worker->read_buffer_bytes_wanted, 4096); worker->read_buffer = g_realloc (worker->read_buffer, worker->read_buffer_allocated_size); + gsize target = MAX (worker->read_buffer_allocated_size, 4096); + gsize desired = worker->read_buffer_bytes_wanted; + + if (desired > READ_AHEAD_CAP) + desired = MIN (desired, worker->read_buffer_cur_size + READ_AHEAD_CAP); + + if (target < desired) + { + worker->read_buffer_allocated_size = desired; + worker->read_buffer = g_realloc (worker->read_buffer, worker->read_buffer_allocated_size); + } } + + to_read = MIN (worker->read_buffer_bytes_wanted - worker->read_buffer_cur_size, + worker->read_buffer_allocated_size - worker->read_buffer_cur_size); + g_assert (to_read > 0); if (worker->socket == NULL) g_input_stream_read_async (g_io_stream_get_input_stream (worker->stream), worker->read_buffer + worker->read_buffer_cur_size, worker->read_buffer_bytes_wanted - worker->read_buffer_cur_size, + to_read, G_PRIORITY_DEFAULT, worker->cancellable, (GAsyncReadyCallback) _g_dbus_worker_do_read_cb, @@ -861,7 +878,7 @@ _g_dbus_worker_do_read_unlocked (GDBusWorker *worker) _g_socket_read_with_control_messages (worker->socket, worker->read_buffer + worker->read_buffer_cur_size, worker->read_buffer_bytes_wanted - worker->read_buffer_cur_size, + to_read, &worker->read_ancillary_messages, &worker->read_num_ancillary_messages, G_PRIORITY_DEFAULT, ``` ------ This report was generated using AI technology. Always review AI-generated content prior to use