REDHAT-BUG-2587825: Use After Free
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).
Affected Software
Event History
Frequently Asked Questions
Which environments are realistically exposed to this issue?
Any environment that processes attacker-controlled or untrusted modulemd metadata is exposed. The issue was reproduced as an unprivileged user with modulemd-validator and with dnf makecache using a local repository containing crafted module metadata.
What must an attacker provide to trigger the fault?
The attacker needs to supply a modulemd document using format v1 or v2 in which buildopts.rpms is not a mapping. Processing that document reaches the affected buildopts parsing error path.
Which libmodulemd versions are affected?
The flaw was introduced in libmodulemd 2.7.0, and every release since then is affected according to the report. This includes version 2.13.0 shipped in RHEL 8 and RHEL 9, and version 2.15.0 shipped in RHEL 10.