Files
buildroot/package/avahi/0011-properly-randomize-query-id-of-DNS-packets.patch
Thomas Perale e728d3506b package/avahi: patch various security vulnerabilities
Please note that the fix for CVE-2024-52615 introduces CVE-2025-59529
which is not fixed yet (https://github.com/avahi/avahi/pull/808). You
can mitigate this vulnerability by setting the `enable-wide-area=no`
option.

Patch `0011-properly-randomize-query-id-of-DNS-packets.patch` modify
`configure.ac` and then `AVAHI_AUTORECONF` is set.

This commit fixes the following vulnerabilities:

- CVE-2021-3468:
    A flaw was found in avahi in versions 0.6 up to 0.8. The event used to
    signal the termination of the client connection on the avahi Unix
    socket is not correctly handled in the client_work function, allowing
    a local attacker to trigger an infinite loop. The highest threat from
    this vulnerability is to the availability of the avahi service, which
    becomes unresponsive after this flaw is triggered.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2021-3468
    - 447affe299

- CVE-2023-38469:
    A vulnerability was found in Avahi, where a reachable assertion exists
    in avahi_dns_packet_append_record.
    https://www.cve.org/CVERecord?id=CVE-2023-38469

- CVE-2023-38470:
    A vulnerability was found in Avahi. A reachable assertion exists in
    the avahi_escape_label() function.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2023-38470
    - a337a1ba7d

- CVE-2023-38471:
    A vulnerability was found in Avahi. A reachable assertion exists in
    the dbus_set_host_name function.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2023-38471
    - github.com/avahi/avahi/commit/894f085f402e023a98cbb6f5a3d117bd88d93b09

- CVE-2023-38472:
    A vulnerability was found in Avahi. A reachable assertion exists in
    the avahi_rdata_parse() function.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2023-38472
    - b024ae5749

- CVE-2023-38473:
    A vulnerability was found in Avahi. A reachable assertion exists in
    the avahi_alternative_host_name() function.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2023-38473
    - b448c9f771

- CVE-2024-52615:
    A flaw was found in Avahi-daemon, which relies on fixed source ports
    for wide-area DNS queries. This issue simplifies attacks where
    malicious DNS responses are injected.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2024-52615
    - 4e2e1ea090
    - https://github.com/avahi/avahi/issues/810 (introduce regression CVE-2025-59529)

- CVE-2024-52616:
    A flaw was found in the Avahi-daemon, where it initializes DNS
    transaction IDs randomly only once at startup, incrementing them
    sequentially after that. This predictable behavior facilitates DNS
    spoofing attacks, allowing attackers to guess transaction IDs.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2024-52616
    - f8710bdc8b

- CVE-2025-68276:
    Avahi is a system which facilitates service discovery on a local
    network via the mDNS/DNS-SD protocol suite. In 0.9-rc2 and earlier, an
    unprivileged local users can crash avahi-daemon (with wide-area
    disabled) by creating record browsers with the
    AVAHI_LOOKUP_USE_WIDE_AREA flag set via D-Bus. This can be done by
    either calling the RecordBrowserNew method directly or creating
    hostname/address/service resolvers/browsers that create those browsers
    internally themselves.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2025-68276
    - 2d48e42d44

- CVE-2025-68468:
    Avahi is a system which facilitates service discovery on a local
    network via the mDNS/DNS-SD protocol suite. In 0.9-rc2 and earlier,
    avahi-daemon can be crashed by sending unsolicited announcements
    containing CNAME resource records pointing it to resource records with
    short TTLs. As soon as they expire avahi-daemon crashes.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2025-68468
    - f66be13d7f

- CVE-2025-68471:
    Avahi is a system which facilitates service discovery on a local
    network via the mDNS/DNS-SD protocol suite. In 0.9-rc2 and earlier,
    avahi-daemon can be crashed by sending 2 unsolicited announcements
    with CNAME resource records 2 seconds apart.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2025-68471
    - 9c6eb53bf2

- CVE-2026-24401:
    Avahi is a system which facilitates service discovery on a local
    network via the mDNS/DNS-SD protocol suite. In versions 0.9rc2 and
    below, avahi-daemon can be crashed via a segmentation fault by sending
    an unsolicited mDNS response containing a recursive CNAME record,
    where the alias and canonical name point to the same domain (e.g.,
    "h.local" as a CNAME for "h.local"). This causes unbounded recursion
    in the lookup_handle_cname function, leading to stack exhaustion. The
    vulnerability affects record browsers where AVAHI_LOOKUP_USE_MULTICAST
    is set explicitly, which includes record browsers created by resolvers
    used by nss-mdns. This issue is patched in commit
    78eab31128479f06e30beb8c1cbf99dd921e2524.

For more information, see:
    - https://www.cve.org/CVERecord?id=CVE-2026-24401
    - 78eab31128

Signed-off-by: Thomas Perale <thomas.perale@mind.be>
Signed-off-by: Julien Olivain <ju.o@free.fr>
2026-02-13 09:45:23 +01:00

103 lines
3.7 KiB
Diff

From f8710bdc8b29ee1176fe3bfaeabebbda1b7a79f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Mon, 11 Nov 2024 00:56:09 +0100
Subject: [PATCH] Properly randomize query id of DNS packets
CVE: CVE-2024-52616
Upstream: https://github.com/avahi/avahi/commit/f8710bdc8b29ee1176fe3bfaeabebbda1b7a79f7
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
---
avahi-core/wide-area.c | 36 ++++++++++++++++++++++++++++--------
configure.ac | 3 ++-
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/avahi-core/wide-area.c b/avahi-core/wide-area.c
index 971f5e714..00a15056e 100644
--- a/avahi-core/wide-area.c
+++ b/avahi-core/wide-area.c
@@ -40,6 +40,13 @@
#include "addr-util.h"
#include "rr-util.h"
+#ifdef HAVE_SYS_RANDOM_H
+#include <sys/random.h>
+#endif
+#ifndef HAVE_GETRANDOM
+# define getrandom(d, len, flags) (-1)
+#endif
+
#define CACHE_ENTRIES_MAX 500
typedef struct AvahiWideAreaCacheEntry AvahiWideAreaCacheEntry;
@@ -84,8 +91,6 @@ struct AvahiWideAreaLookupEngine {
int fd_ipv4, fd_ipv6;
AvahiWatch *watch_ipv4, *watch_ipv6;
- uint16_t next_id;
-
/* Cache */
AVAHI_LLIST_HEAD(AvahiWideAreaCacheEntry, cache);
AvahiHashmap *cache_by_key;
@@ -201,6 +206,26 @@ static void sender_timeout_callback(AvahiTimeEvent *e, void *userdata) {
avahi_time_event_update(e, avahi_elapse_time(&tv, 1000, 0));
}
+static uint16_t get_random_uint16(void) {
+ uint16_t next_id;
+
+ if (getrandom(&next_id, sizeof(next_id), 0) == -1)
+ next_id = (uint16_t) rand();
+ return next_id;
+}
+
+static uint16_t avahi_wide_area_next_id(AvahiWideAreaLookupEngine *e) {
+ uint16_t next_id;
+
+ next_id = get_random_uint16();
+ while (find_lookup(e, next_id)) {
+ /* This ID is already used, get new. */
+ next_id = get_random_uint16();
+ }
+ return next_id;
+}
+
+
AvahiWideAreaLookup *avahi_wide_area_lookup_new(
AvahiWideAreaLookupEngine *e,
AvahiKey *key,
@@ -227,11 +252,7 @@ AvahiWideAreaLookup *avahi_wide_area_lookup_new(
/* If more than 65K wide area quries are issued simultaneously,
* this will break. This should be limited by some higher level */
- for (;; e->next_id++)
- if (!find_lookup(e, e->next_id))
- break; /* This ID is not yet used. */
-
- l->id = e->next_id++;
+ l->id = avahi_wide_area_next_id(e);
/* We keep the packet around in case we need to repeat our query */
l->packet = avahi_dns_packet_new(0);
@@ -604,7 +625,6 @@ AvahiWideAreaLookupEngine *avahi_wide_area_engine_new(AvahiServer *s) {
e->watch_ipv6 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv6, AVAHI_WATCH_IN, socket_event, e);
e->n_dns_servers = e->current_dns_server = 0;
- e->next_id = (uint16_t) rand();
/* Initialize cache */
AVAHI_LLIST_HEAD_INIT(AvahiWideAreaCacheEntry, e->cache);
diff --git a/configure.ac b/configure.ac
index a3211b80e..31bce3d76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -367,7 +367,8 @@ AC_FUNC_SELECT_ARGTYPES
# whether libc's malloc does too. (Same for realloc.)
#AC_FUNC_MALLOC
#AC_FUNC_REALLOC
-AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid setresgid setregid strcasecmp gettimeofday putenv strncasecmp strlcpy gethostbyname seteuid setegid setproctitle getprogname])
+AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid setresgid setregid strcasecmp gettimeofday putenv strncasecmp strlcpy gethostbyname seteuid setegid setproctitle getprogname getrandom])
+AC_CHECK_HEADERS([sys/random.h])
AC_FUNC_CHOWN
AC_FUNC_STAT