Use-after-free in c-ares can crash Envoy via compromised or malfunctioning DNS
Key facts
- Attack vector
- Adjacent network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- High
- Impact type
- Denial of service
- Confidentiality · integrity · availability
- None · None · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · GHSA-fg9g-pvc4-776f. Fix status from GitHub. Impact type from CWE-416 and the CVSS impact.
Summary
A heap use-after-free in c-ares occurs in ares_getaddrinfo when a search domain retry fails with a connection refusal after an NXDOMAIN response. end_query() invalidates a server connection that read_answers() still references, so a resent query that succeeds corrupts memory. An attacker who controls local DNS infrastructure can cause a denial of service in Envoy or any application linked against affected c-ares versions. Affected versions run up to and including 1.36.3.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
Description from the GitHub advisory
### Summary A heap use-after-free vulnerability has been identified in c-ares (`<1.34.6`). For more information see [CVE-2025-62408](https://github.com/c-ares/c-ares/security/advisories/GHSA-jq53-42q6-pqr5). The issue occurs during the `ares_getaddrinfo` query lifecycle when processing a specific sequence of DNS responses. If a trusted adjacent DNS resolver returns an `NXDOMAIN` response followed by a connection refusal during a search domain retry, it triggers a memory corruption error. This vulnerability can be exploited by an attacker controlling the local DNS infrastructure to cause a Denial of Service (DoS) in Envoy or any application linked against affected versions of c-ares. ### Details The vulnerability is triggered when `ares_getaddrinfo` processes a non-FQDN query that follows a specific transaction sequence: 1. **Initial Query:** A query is sent for a non-FQDN (e.g. `www.google.com`). 2. **Trigger Response:** The upstream DNS server replies with `NXDOMAIN`. 3. **Search Domain Retry:** `c-ares` attempts to retry the query by appending a search domain. 4. **Connection Failure:** The retry attempt fails with a local or network error (e.g., `ECONNREFUSED`). 5. **Requeue:** `c-ares` requeues the query and resends it immediately. 6. **Use-After-Free:** If the resent query succeeds, the function `end_query()` is called. This invalidates the server connection while it is still being referenced in the call stack by `read_answers()`, resulting in a heap use-after-free. This behavior is reproducible in c-ares `main` (`ee2a1c3e`) and c-ares release `1.34.5` (`d3a507e9`). **Relevant source code:** * `ares_process.c` → `read_answers()` / `process_answer()` → `end_query()` ### PoC The following test case demonstrates the underlying memory corruption mechanics. It simulates the specific network topology and response sequence required to trigger the use-after-free condition. **Note:** This PoC uses a mock server to deterministically replicate the crash state (`NXDOMAIN` followed by connection refusal). In a real-world scenario, this sequence would need to be triggered by a compromised or malfunctioning adjacent DNS resolver manipulating the response stream, limiting potential exploitability. Possible scenarios: * The operator has configured a compromised DNS resolver. * The DNS traffic is being intercepted/manipulated (Man-in-the-Middle). * A legitimate provider malfunctions in a very specific way. ```cpp TEST_P(MockUDPChannelTestAI, ConnectionRefusedOnSearchDomainRetry) { DNSPacket badrsp4; badrsp4.set_response().set_aa() .add_question(new DNSQuestion("www.google.com", T_A)) .set_rcode(NXDOMAIN); // Simulate trusted resolver returning NXDOMAIN EXPECT_CALL(server_, OnRequest("www.google.com", T_A)) .WillOnce(SetReplyAndFailSend(&server_, &badrsp4)); DNSPacket goodrsp4; goodrsp4.set_response().set_aa() .add_question(new DNSQuestion("www.google.com.first.com", T_A)) .add_answer(new DNSARR("www.google.com.first.com", 0x0100, {0x01,0x02,0x03,0x04})); // Simulate subsequent search domain query logic EXPECT_CALL(server_, OnRequest("www.google.com.first.com", T_A)) .WillOnce(SetReply(&server_, &goodrsp4)); ares_socket_functions sock_funcs = {0}; sock_funcs.asendv = ares_sendv_fail; ares_set_socket_functions(channel_, &sock_funcs, NULL); AddrInfoResult result; struct ares_addrinfo_hints hints = {0,0,0,0}; hints.ai_family = AF_INET; hints.ai_flags = ARES_AI_NOSORT; ares_getaddrinfo(channel_, "www.google.com", NULL, &hints, AddrInfoCallback, &result); Process(); } ``` ### Mitigation Update c-ares library >= 1.34.6
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | c-ares (envoy) | <= 1.36.3 | 1.36.4, 1.35.8, 1.34.12, 1.33.14 | Patch available | GHSA-fg9g-pvc4-776f |
- c-ares (envoy) Vendor— Affected <= 1.36.3 Fixed in 1.36.4, 1.35.8, 1.34.12, 1.33.14 Patch available GHSA-fg9g-pvc4-776f
Remediation
Upgrade c-ares to 1.36.4, 1.35.8, 1.34.12 or 1.33.14, matching the release line in use.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
- Fix · GHSA-fg9g-pvc4-776f c-ares (envoy) Fixed in 1.36.4, 1.35.8, 1.34.12, 1.33.14 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-fg9g-pvc4-776f
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences