CVE-2026-141180: Libmodulemd: libmodulemd: double free when parsing crafted module metadata
A flaw was found in libmodulemd. When parsing a module metadata document containing a malformed build options entry, an error object is freed twice, causing the application parsing the document to crash. An attacker able to control repository metadata consumed by a system using dnf can use this flaw to cause a denial of service of the package management tooling.
Other sources
An external researcher reported (via JSM PSIRTSUPT-31690, with PoC, sanitizer output, backtraces and a proposed fix) a double free of a GError in libmodulemd's buildopts parsing. modulemdbuildoptsparseyaml() in modulemd/modulemd-buildopts.c declares nestederror as gautoptr(GError) and calls gpropagateerror(error, nestederror) without gstealpointer() (line 374 on main 2f75d47, identical in 2.13.0 and 2.15.0), so the autoptr cleanup frees the GError while the caller holds it; the caller then reads it via gerrorcopy (use-after-free read) and frees it again (double free). Trigger: a modulemd document (v1 or v2) whose buildopts.rpms entry is not a mapping. Introduced in 2.7.0 (commit 1df0553, 2019); every release since is affected, including the versions shipped in RHEL 8 (2.13.0), RHEL 9 (2.13.0) and RHEL 10 (2.15.0). Reproduced by Product Security on Rocky Linux 10.2 with the shipped libmodulemd-2.15.0-12.el10 as an unprivileged user: modulemd-validator segfaults, and dnf makecache against a local repository whose modules metadata carries the crafted document segfaults with the chain dnf -> libdnf ModuleMetadata::addMetadataFromString -> modulemdmoduleindexupdatefromstring -> gerrorcopy. Valgrind on the unmodified RPM attributes both the use-after-free read in gerrorcopy and the double free from the caller's autoptr to the buildopts autoptr cleanup; without the memory error the input is handled as an ordinary validation failure. Reachability: dnf parses repository modules metadata on every metadata refresh and dnf-makecache.timer is enabled by default, with repogpgcheck off by default, so an attacker controlling repository metadata (compromised mirror, network position on a plain-HTTP mirror path, or an administrator-added repository) can crash the process parsing it; on EL8/EL9 the reporter additionally observed glib slice freelist corruption with repeated crashes from cached metadata until dnf clean all (reporter evidence only). No code execution demonstrated; impact is denial of service. Fix: gpropagateerror(error, gstealpointer(&nestederror)) (reporter's patch, applies cleanly); four additional same-class sites in modulemd-yaml-util.c (gpropagateprefixederror with un-stolen autoptr on emitter error paths) should be fixed in the same commit. Proposed CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H = 5.9 (Moderate).
— Red Hat
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In libmodulemd, change the buildopts error propagation to g_propagate_error(error, g_steal_pointer(&nested_error)); in the same commit, fix the four corresponding modulemd-yaml-util.c error paths that call g_propagate_prefixed_error with an un-stolen autoptr.
Event History
Frequently Asked Questions
Which systems are realistically exposed?
Systems using dnf that consume repository metadata controlled by an attacker are exposed. The issue affects libmodulemd releases from 2.7.0 onward, including versions identified as shipped in RHEL 8, RHEL 9, and RHEL 10.
What does an attacker need to trigger the issue?
The attacker must be able to provide or alter repository module metadata that the target system parses. The triggering document is module metadata version 1 or 2 with a buildopts.rpms entry that is not a mapping; no privileges or user interaction are required on the target according to the supplied vector.
What is the operational impact of a successful trigger?
The application parsing the malicious metadata can crash because an error object is used after it has been freed and then freed again. In the described dnf scenario, this results in denial of service of package-management tooling.
How can I determine whether an environment is affected?
Determine the installed libmodulemd version and whether it is 2.7.0 or later; every release since 2.7.0 is described as affected. Exposure additionally depends on whether the system parses untrusted or attacker-controlled repository metadata through dnf.