Fedora Account System
Red Hat Associate
Red Hat Customer
AI_ONLY_REPORT package: grub2-2.12-44.el10_2 ------ Summary: Out-of-Bounds Write in DNS Answer Parsing (`recv_hook`) via Reparse Accumulation: a crafted DNS response can cause repeated A/AAAA appends across CNAME-triggered reparses until `*data->naddresses` exceeds the allocation derived from `ancount`, resulting in a heap out-of-bounds write. Requirements to exploit: An attacker must be able to supply or interfere with DNS responses received by GRUB during a boot path that actually performs DNS resolution, and must craft the answer section so reparsing appends additional A/AAAA records before the existing CNAME loop check aborts processing. Component affected: `grub2-2.12-44.el10_2`, DNS response parsing in `grub-core/net/dns.c`, function `recv_hook` Version affected: `grub2-2.12-44.el10_2`, when deployed in a configuration that enables GRUB networking and performs DNS lookups during boot Patch available: no released package fix established; proposed patch included below Version fixed: unknown Upstream coordination: Not notified. CVSS: CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:H - 6.5 (MEDIUM) AV:A - The attacker must influence DNS traffic seen by GRUB on the local network path rather than reach the target over the general Internet. AC:H - Triggering the overflow appears to require careful DNS RR ordering and enough successful reparses before the existing CNAME loop detection stops processing. PR:N - No prior authentication or local account is required. UI:N - No user action is required at trigger time once the affected boot flow performs the DNS lookup. S:U - The impact is within the GRUB execution context. C:L - Memory corruption in the bootloader may expose limited data in some scenarios, but broader confidentiality impact is not established by the available evidence. I:L - The write corrupts heap state and could alter GRUB behavior, but reliable integrity compromise beyond that is not demonstrated here. A:H - The most clearly supported impact is a crash or boot failure during DNS parsing. Impact: Moderate. The issue is a real memory-safety flaw in boot-time DNS parsing, but the available evidence indicates a configuration-dependent attack path and a non-trivial trigger. Exploitation requires GRUB networking to be in use, attacker influence over DNS replies, and carefully structured answer records to accumulate writes across reparses before loop detection fires. That makes the issue less easily exploitable than a typical remotely reachable denial of service, and the current evidence supports memory corruption and likely availability impact more strongly than easy system compromise. Embargo: no Reason: The issue appears security-relevant, but the currently supported impact is primarily denial of service or boot disruption in a constrained boot-time networking scenario, and exploitation depends on specific deployment and packet-shaping conditions. Acknowledgement: Aisle Research Vulnerability Details: `recv_hook` allocates the address array once using the DNS header answer count, then may restart parsing from the same answer section when a matching CNAME is seen. The A and AAAA cases append to `*data->addresses` using `*data->naddresses`, but there is no capacity check tying that counter back to the original `ancount` allocation. ```c *data->addresses = grub_calloc (grub_be_to_cpu16 (head->ancount), sizeof ((*data->addresses)[0])); ... reparse: for (i = 0, ptr = reparse_ptr; i < grub_be_to_cpu16 (head->ancount); i++) { ... case DNS_CLASS_A: if (length != 4) break; (*data->addresses)[*data->naddresses].type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; grub_memcpy (&(*data->addresses)[*data->naddresses].ipv4, ptr, 4); ... (*data->naddresses)++; ... case DNS_CLASS_CNAME: ... data->name = get_name (ptr, nb->data, nb->tail); ... goto reparse; ``` The existing CNAME redirection tracking (`redirect_save` and `redirect_cnt`) is not a bound on `*data->naddresses`. A crafted answer section can therefore cause multiple reparse passes and repeated A/AAAA insertions while capacity remains fixed to the initial `ancount`. This supports a heap out-of-bounds write. The available material supports memory corruption and likely crash or boot failure; it does not establish reliable code execution for this package. Steps to reproduce: 1. Use a system or test environment running this SRPM's GRUB build in a configuration that enables networking and performs `grub_net_dns_lookup`, such as a PXE or other DNS-dependent boot flow, or by invoking `nslookup` from the GRUB shell if that command is present in the build. 2. Configure GRUB to use a DNS server under tester control, or otherwise position the tester to supply forged DNS replies on the boot network path. 3. Return a DNS response with a small-to-moderate `ancount` and an answer section containing a CNAME loop across multiple names, with at least one valid A or AAAA record for the currently matched name before the next CNAME forces `goto reparse`. 4. Ensure the record ordering allows `*data->naddresses` to increase across several reparse passes before the CNAME loop check aborts processing. 5. Observe heap corruption at the A or AAAA write sites using an instrumented build, or observe a crash or boot failure during DNS parsing. Mitigation: Avoid GRUB-time DNS resolution where practical. Boot paths that use numeric addresses or a trusted, locally controlled DNS service reduce exposure. Systems that do not enable GRUB networking or do not perform DNS lookups in GRUB do not reach this code path. Proposed Fix: Cache `ancount` once and reject further A/AAAA appends after `*data->naddresses` reaches that capacity. ```diff diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index XXXXXXX..YYYYYYY 100644 — a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -261,6 +261,7 @@ recv_hook (grub_net_udp_socket_t sock _attribute_ ((unused)), int i, j; grub_uint8_t *ptr, *reparse_ptr; int redirect_cnt = 0; + grub_size_t ancount; char *redirect_save = NULL; grub_uint32_t ttl_all = ~0U; @@ -299,13 +300,14 @@ recv_hook (grub_net_udp_socket_t sock _attribute_ ((unused)), *data->addresses = grub_calloc (grub_be_to_cpu16 (head->ancount), + ancount = grub_be_to_cpu16 (head->ancount); + *data->addresses = grub_calloc (ancount, sizeof ((*data->addresses)[0])); @@ -308,7 +310,7 @@ recv_hook (grub_net_udp_socket_t sock _attribute_ ((unused)), for (i = 0, ptr = reparse_ptr; i < grub_be_to_cpu16 (head->ancount); i++) + for (i = 0, ptr = reparse_ptr; i < ancount; i++) @@ -346,6 +348,11 @@ recv_hook (grub_net_udp_socket_t sock _attribute_ ((unused)), case DNS_CLASS_A: + if (*data->naddresses >= ancount) + { + data->dns_err = 1; + goto out; + } if (length != 4) break; @@ -357,6 +364,11 @@ recv_hook (grub_net_udp_socket_t sock _attribute_ ((unused)), case DNS_CLASS_AAAA: + if (*data->naddresses >= ancount) + { + data->dns_err = 1; + goto out; + } if (length != 16) break; ``` ------ This report was generated using AI technology. Always review AI-generated content prior to use