# CVE-2025-8058: Use after free in glibc

> A double free vulnerability in glibc's regcomp function allows attackers to manipulate buffers and potentially execute code via crafted regex inputs.

- **Severity:** Medium 5.9 (`CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:P/VC:L/VI:L/VA:H/SC:L/SI:L/SA:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 23 Jul 2025
- **Updated:** 4 Nov 2025
- **Also known as:** ALSA-2025:12980, ALSA-2025:13240, AZL-68609, BELL-CVE-2025-8058, CLSA-2025-1755005189, CLSA-2025-1755007232, CLSA-2025-1756930773, DEBIAN-CVE-2025-8058, ECHO-086f-bae8-9025, GHSA-8xjp-c72j-67q8, MGASA-2025-0220, MINI-97x6-gw34-4w84, MINI-j2q3-3cmf-f92w, MINI-rpf9-4p9f-qx57, OESA-2025-2043, OESA-2025-2044, OESA-2025-2045, OESA-2025-2046, OESA-2025-2047, OESA-2025-2064, RHSA-2025:12748, RHSA-2025:12980, RHSA-2025:13240, RLSA-2025:12748, RLSA-2025:12980, RLSA-2025:13240, SUSE-SU-2025:02964-1, UBUNTU-CVE-2025-8058, USN-7760-1, openSUSE-SU-2025:15459-1

## What is CVE-2025-8058?

CVE-2025-8058 is a medium-severity use after free vulnerability in The GNU C Library glibc, published on 23 Jul 2025. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

The regcomp function in the GNU C library version from 2.4 to 2.41 is 
subject to a double free if some previous allocation fails. It can be 
accomplished either by a malloc failure or by using an interposed malloc
 that injects random malloc failures. The double free can allow buffer 
manipulation depending of how the regex is constructed. This issue 
affects all architectures and ABIs supported by the GNU C library.

Weakness: CWE-415 (Double Free)

## Which versions are affected by CVE-2025-8058?


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `glibc-doc` | AlmaLinux:10 | All versions | 2.39-46.el10_0.alma.1 |
| `compat-libpthread-nonshared` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-all-langpacks` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-benchtests` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-common` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-devel` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-doc` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-gconv-extra` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-headers` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-aa` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-af` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-agr` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-ak` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-am` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-an` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-anp` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-ar` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-as` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-ast` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-ayc` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-az` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-be` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-bem` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-ber` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-bg` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-bhb` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-bho` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-bi` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-bn` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-bo` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-br` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-brx` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-bs` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-byn` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-ca` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-ce` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-chr` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-cmn` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |
| `glibc-langpack-crh` | AlmaLinux:8 | All versions | 2.28-251.el8_10.25 |

## How do I fix CVE-2025-8058?

Upgrade to a fixed version.

## Is CVE-2025-8058 being exploited?

There is no known exploitation of CVE-2025-8058 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-8058 and fix it if it is affected.

What it is: CVE-2025-8058 is a medium-severity use after free vulnerability in The GNU C Library glibc, published on 23 Jul 2025. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2025-8058 in the wild and no public exploit code.

Affected product: The GNU C Library glibc. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-8058/ (Markdown: https://insights.sbomify.com/CVE-2025-8058/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-8058
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-8058
- OSV: https://osv.dev/vulnerability/CVE-2025-8058

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-8058/
Summaries are generated and may contain mistakes; the official description above is the record.
