CVE-2025-48945
pycares has a Use-After-Free Vulnerability
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- None
- User interaction
- None
What an attacker can affect
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Exploit likelihood
What each source reports
CVE List Score used
8.2
pycares has a Use-After-Free Vulnerability
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
- Record
CVE-2025-48945- CVSS 4.0
- 8.2 High
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N - Weakness
- CWE-416
- Updated
- 2026-11-02
EUVDEUVD-2025-28273
8.2
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
- Record
EUVD-2025-28273- CVSS 4.0
- 8.2 High
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-5qpg-rh4j-qp35 No score
pycares has a Use-After-Free Vulnerability
Summary
pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash.
Details
Root Cause
The vulnerability stems from improper handling of callback references when the Channel object is destroyed:
- When a DNS query is initiated, pycares stores a callback reference using
ffi.new_handle() - If the Channel object is garbage collected while queries are pending, the callback references become invalid
- When c-ares attempts to invoke the callback, it accesses freed memory, causing a fatal error
This issue was much more likely to occur when using event_thread=True but could happen without it under the right circumstances.
Technical Details
The core issue is a race condition between Python's garbage collector and c-ares's callback execution:
- When
__del__is called from within a c-ares callback context, we cannot immediately callares_destroy()because c-ares is still executing code after the callback returns - c-ares needs to execute cleanup code after our Python callback returns (specifically at lines 1422-1429 in ares_process.c)
- If we destroy the channel too quickly, c-ares accesses freed memory
Impact
Applications using pycares can be crashed remotely by triggering DNS queries that result in Channel objects being garbage collected before query completion. This is particularly problematic in scenarios where:
- Channel objects are created per-request
- Multiple failed DNS queries are processed rapidly
- The application doesn't properly manage Channel lifecycle
The error manifests as:
Fatal Python error: b_from_handle: ffi.from_handle() detected that the address passed points to garbage
Fix
The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism
Mitigation
For Application Developers
- Upgrade to pycares >= 4.9.0 - This version includes the fix and requires no code changes
- Best practices (optional but recommended):
# Explicit cleanup channel.close() # Or use context manager with pycares.Channel() as channel: # ... use channel ... # Automatically closed - Avoid creating Channel objects per-request - Prefer long-lived instances for better performance and safety
The fix is completely transparent - no API changes or code modifications are required.
Credit
This vulnerability was reported by @vEpiphyte through the aio-libs security program.
- Record
GHSA-5qpg-rh4j-qp35- Weakness
- CWE-416
- Updated
- 2026-11-02
NVD
8.2
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
- Record
CVE-2025-48945- CVSS 4.0
- 8.2 High
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X - Weakness
- CWE-416
- Updated
- 2026-11-02
OSV
8.2
pycares has a Use-After-Free Vulnerability
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
- Record
CVE-2025-48945- CVSS 4.0
- 8.2 High
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N - Weakness
- CWE-416
- Updated
- 2026-11-02
OSVDEBIAN-CVE-2025-48945
8.2
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
- Record
DEBIAN-CVE-2025-48945- CVSS 4.0
- 8.2 High
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X - Updated
- 2026-11-02
Show 11 moreShow less
OSVOESA-2025-1810
5.5
python-pycares security update
pycares is a Python module which provides an interface to c-ares.c-ares is a C library that performs DNS requests and name resolutions asynchronously.
Security Fix(es):
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.(CVE-2025-48945)
- Record
OESA-2025-1810- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVOESA-2025-1811
5.5
python-pycares security update
pycares is a Python module which provides an interface to c-ares.c-ares is a C library that performs DNS requests and name resolutions asynchronously.
Security Fix(es):
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.(CVE-2025-48945)
- Record
OESA-2025-1811- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVOESA-2025-1812
5.5
python-pycares security update
pycares is a Python module which provides an interface to c-ares.c-ares is a C library that performs DNS requests and name resolutions asynchronously.
Security Fix(es):
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.(CVE-2025-48945)
- Record
OESA-2025-1812- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVOESA-2025-1813
5.5
python-pycares security update
pycares is a Python module which provides an interface to c-ares.c-ares is a C library that performs DNS requests and name resolutions asynchronously.
Security Fix(es):
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.(CVE-2025-48945)
- Record
OESA-2025-1813- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVOESA-2025-1858
5.5
python-pycares security update
pycares is a Python module which provides an interface to c-ares.c-ares is a C library that performs DNS requests and name resolutions asynchronously.
Security Fix(es):
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.(CVE-2025-48945)
- Record
OESA-2025-1858- CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H - Updated
- 2026-11-02
OSVUBUNTU-CVE-2025-48945
8.2
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
- Record
UBUNTU-CVE-2025-48945- CVSS 4.0
- 8.2 High
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N - Updated
- 2026-11-02
OSVAZL-64307 No score
CVE-2025-48945 affecting package python-pycares 3.1.1-3
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
- Record
AZL-64307- Updated
- 2026-11-02
OSVAZL-67074 No score
CVE-2025-48945 affecting package python3-pycares 4.5.0-1
pycares is a Python module which provides an interface to c-ares. c-ares is a C library that performs DNS requests and name resolutions asynchronously. Prior to version 4.9.0, pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash. The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism.
- Record
AZL-67074- Updated
- 2026-11-05
OSVGHSA-5qpg-rh4j-qp35 No score
pycares has a Use-After-Free Vulnerability
Summary
pycares is vulnerable to a use-after-free condition that occurs when a Channel object is garbage collected while DNS queries are still pending. This results in a fatal Python error and interpreter crash.
Details
Root Cause
The vulnerability stems from improper handling of callback references when the Channel object is destroyed:
- When a DNS query is initiated, pycares stores a callback reference using
ffi.new_handle() - If the Channel object is garbage collected while queries are pending, the callback references become invalid
- When c-ares attempts to invoke the callback, it accesses freed memory, causing a fatal error
This issue was much more likely to occur when using event_thread=True but could happen without it under the right circumstances.
Technical Details
The core issue is a race condition between Python's garbage collector and c-ares's callback execution:
- When
__del__is called from within a c-ares callback context, we cannot immediately callares_destroy()because c-ares is still executing code after the callback returns - c-ares needs to execute cleanup code after our Python callback returns (specifically at lines 1422-1429 in ares_process.c)
- If we destroy the channel too quickly, c-ares accesses freed memory
Impact
Applications using pycares can be crashed remotely by triggering DNS queries that result in Channel objects being garbage collected before query completion. This is particularly problematic in scenarios where:
- Channel objects are created per-request
- Multiple failed DNS queries are processed rapidly
- The application doesn't properly manage Channel lifecycle
The error manifests as:
Fatal Python error: b_from_handle: ffi.from_handle() detected that the address passed points to garbage
Fix
The vulnerability has been fixed in pycares 4.9.0 by implementing a safe channel destruction mechanism
Mitigation
For Application Developers
- Upgrade to pycares >= 4.9.0 - This version includes the fix and requires no code changes
- Best practices (optional but recommended):
# Explicit cleanup channel.close() # Or use context manager with pycares.Channel() as channel: # ... use channel ... # Automatically closed - Avoid creating Channel objects per-request - Prefer long-lived instances for better performance and safety
The fix is completely transparent - no API changes or code modifications are required.
Credit
This vulnerability was reported by @vEpiphyte through the aio-libs security program.
- Record
GHSA-5qpg-rh4j-qp35- Weakness
- CWE-416
- Updated
- 2026-11-02
OSVopenSUSE-SU-2025:15324-1 No score
python311-pycares-4.9.0-1.1 on GA media
These are all security issues fixed in the python311-pycares-4.9.0-1.1 package on the GA media of openSUSE Tumbleweed.
- Record
openSUSE-SU-2025:15324-1- Updated
- 2026-11-02
OSVSUSE-SU-2025:03354-1 No score
Security update for python-pycares
This update for python-pycares fixes the following issues:
Update to version 4.10.0 (jsc#PED-13442):
- CVE-2025-48945: Fixed use-after-free vulnerability may have led to a crash (bsc#1244691).
- Record
SUSE-SU-2025:03354-1- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
pycaresPyPI |
through 4.8.0 | 4.9.0 |
python-pycaresAzure Linux:2 |
through 3.1.1-3 | None known |
python3-pycaresAzure Linux:3 |
through 4.5.0-1 | None known |
pycaresDebian:12 |
All versions, plus listed versions 4.3.0-24.4.0-14.4.0-24.9.0-15.0.0-1 Show 5 moreShow less5.0.0-25.0.0-35.0.1-15.0.1-25.0.1-3 |
None known |
pycaresDebian:13 |
All versions, plus listed versions 4.4.0-24.9.0-15.0.0-15.0.0-25.0.0-35.0.1-15.0.1-25.0.1-3 |
None known |
pycaresDebian:14 |
before 4.9.0-1, plus listed versions 4.4.0-2 |
4.9.0-1 |
pycaresPyPI |
before 4.9.0, plus listed versions 0.1.00.2.00.3.00.4.00.5.0 Show 37 moreShow less0.6.00.6.10.6.20.6.30.7.01.0.02.0.02.0.12.1.02.1.12.2.02.3.02.4.03.0.03.0.0b03.0.0b13.0.0b23.0.0b33.0.0b43.0.0b53.1.03.1.13.2.03.2.34.0.04.1.14.1.24.2.04.2.14.2.24.3.04.4.04.5.04.6.04.6.14.7.04.8.0 |
4.9.0 |
python-pycaresopenEuler:24.03-LTS-SP1 |
before 4.9.0-1.oe2403sp1 | 4.9.0-1.oe2403sp1 |
python-pycaresopenEuler:22.03-LTS-SP3 |
before 4.9.0-1.oe2203sp3 | 4.9.0-1.oe2203sp3 |
python-pycaresopenEuler:22.03-LTS-SP4 |
before 4.9.0-1.oe2203sp4 | 4.9.0-1.oe2203sp4 |
Show 21 moreShow less
| Package | Affected | Fixed |
|---|---|---|
python-pycaresopenEuler:24.03-LTS |
before 4.9.0-1.oe2403 | 4.9.0-1.oe2403 |
python-pycaresopenEuler:24.03-LTS-SP2 |
before 4.9.0-1.oe2403sp2 | 4.9.0-1.oe2403sp2 |
python-pycaresSUSE:Linux Enterprise Module for Python 3 15 SP6 |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise Module for Python 3 15 SP7 |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise High Performance Computing 15 SP4-ESPOS |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise High Performance Computing 15 SP4-LTSS |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise High Performance Computing 15 SP5-ESPOS |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise High Performance Computing 15 SP5-LTSS |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise Server 15 SP4-LTSS |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise Server 15 SP5-LTSS |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise Server for SAP Applications 15 SP4 |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresSUSE:Linux Enterprise Server for SAP Applications 15 SP5 |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
python-pycaresopenSUSE:Leap 15.6 |
before 4.10.0-150400.9.8.1 | 4.10.0-150400.9.8.1 |
pycaresUbuntu:18.04:LTS |
All versions, plus listed versions 2.1.1-2build2 |
None known |
pycaresUbuntu:20.04:LTS |
All versions, plus listed versions 2.1.1-2build42.1.1-2build52.1.1-2.13.1.0-33.1.0-43.1.1-13.1.1-1build1 |
None known |
pycaresUbuntu:22.04:LTS |
All versions, plus listed versions 3.1.1-1build33.1.1-1build54.1.2-24.1.2-2build1 |
None known |
pycaresUbuntu:24.04:LTS |
All versions, plus listed versions 4.3.0-24.3.0-2build14.4.0-14.4.0-1build14.4.0-1build2 |
None known |
pycaresUbuntu:25.10 |
All versions, plus listed versions 4.4.0-2build2 |
None known |
pycaresUbuntu:26.10 |
All versions, plus listed versions 5.0.1-3 |
None known |
pycaresUbuntu:26.04:LTS |
All versions, plus listed versions 4.4.0-2build24.4.0-2build34.9.0-15.0.0-25.0.1-25.0.1-3 |
None known |
python-pycaresopenSUSE:Tumbleweed |
before 4.9.0-1.1 | 4.9.0-1.1 |
History
| Recorded | Changed | Sources |
|---|---|---|
| facts | OSV | |
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2025-48945 is a high vulnerability (CVSS 8.2) in Aio-libs Aiodns, published June 16, 2025. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.48%, the 41st percentile. Fixed in pycares 4.9.0.
References
github.com/saghul/pycares/security/advisories/GHSA-5qpg-rh4j-qp35
github.com/aio-libs/aiodns/commit/f259a6e3650555157af53ac2b39f2ff545321d55
github.com/saghul/pycares/commit/ebfd7d71eb8e74bc1057a361ea79a5906db510d4
github.com/aio-libs/aiodns/releases/tag/v3.5.0
github.com/saghul/pycares/releases/tag/v4.9.0
github.com/advisories/GHSA-5qpg-rh4j-qp35
Show 14 moreShow less
nvd.nist.gov/vuln/detail/CVE-2025-48945
github.com/CVEProject/cvelistV5/tree/main/cves/2025/48xxx/CVE-2025-48945.json
security-tracker.debian.org/tracker/CVE-2025-48945
github.com/saghul/pycares
openeuler.org/zh/security/security-bulletins/detail?id=openEuler-SA-2025-1810
openeuler.org/zh/security/security-bulletins/detail?id=openEuler-SA-2025-1811
openeuler.org/zh/security/security-bulletins/detail?id=openEuler-SA-2025-1812
openeuler.org/zh/security/security-bulletins/detail?id=openEuler-SA-2025-1813
openeuler.org/zh/security/security-bulletins/detail?id=openEuler-SA-2025-1858
suse.com/support/update/announcement/2025/suse-su-202503354-1
bugzilla.suse.com/1244691
suse.com/security/cve/CVE-2025-48945
ubuntu.com/security/CVE-2025-48945
cve.org/CVERecord?id=CVE-2025-48945