Use-After-Free Vulnerability in c-ares Library (CVE-2025-31498)

c-ares Updated 02 Oct 2025

Summary

08/04/2025
N/A
Yes i
Unrated
Not published

CVE-2025-31498: c-ares is an asynchronous resolver library. Affects c-ares across 2 version ranges.

< 1.34.5-r0 < 29d38719112639d8c0ba910254a3dd4f482ea2d1

Fixed in 1.34.5-r0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

c-ares is an asynchronous resolver library designed for DNS queries. It allows applications to perform DNS lookups without blocking the main thread, making it suitable for high-performance applications. The library is widely used in various software projects due to its efficiency and non-blocking nature. However, certain versions of c-ares, specifically from 1.32.3 to 1.34.4, are vulnerable to a use-after-free issue that can lead to unexpected behavior or security risks.

Vulnerability Detail

The vulnerability arises in the read_answers() function, where a use-after-free condition occurs if process_answer() re-enqueues a query due to DNS Cookie Failure or improper EDNS support from the upstream server. This can happen if the remote server closes the connection immediately after sending a response. An attacker could exploit this by flooding the target with ICMP UNREACHABLE packets, provided they control the upstream nameserver. This vulnerability poses a risk of denial of service or unintended behavior in applications using the affected versions of c-ares.

How To Fix

Minimum fixed version

1.34.5-r0

This is the first release that contains the fix.

sudo apk add --upgrade c-ares

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

Currently, there are no specific workarounds mentioned for this vulnerability. It is recommended to update to the patched version as soon as possible to mitigate any potential risks.

Conclusion

The CVE-2025-31498 vulnerability in the c-ares library poses significant risks due to a use-after-free condition. Users of affected versions should promptly update to version 1.34.5 or later to mitigate these risks. Regular monitoring for vulnerabilities using tools like Vulert can help maintain application security.

See every vulnerability recorded for c-ares →

Share this vulnerability

FAQ

CVE-2025-31498 is a vulnerability in the c-ares library that allows for a use-after-free condition, potentially leading to security risks.

Versions 1.32.3 through 1.34.4 of c-ares are affected by this vulnerability.

You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected without any signup.

If exploited, this vulnerability could lead to denial of service or unintended behavior in applications that rely on the c-ares library.

Yes, the vulnerability is fixed in c-ares version 1.34.5. It is recommended to update to this version or later.

Related vulnerabilities

Recent vulnerabilities recorded for c-ares.

How To Fix

Minimum fixed version

1.34.5-r0

This is the first release that contains the fix.

sudo apk add --upgrade c-ares

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback