Read the docs
TI-2024-39122 Aliases GHSA-wrw7-89jp-8q8g

Unsoundness in `Iterator` and `DoubleEndedIterator` impls for `glib::VariantStrIter`

Priority LOW 38Published · Updated

Key facts

Attack vector
—
Privileges required
—
User interaction
—
Attack complexity
—
Impact type
—
Confidentiality · integrity · availability
—
Fix status
Fixed

No CVSS vector from any source. Fix status from GitHub.

Summary

The `VariantStrIter::impl_get` function (called internally by implementations of the `Iterator` and `DoubleEndedIterator` traits for this type) was unsound, resulting in undefined behaviour. An immutable reference `&p` to a `*mut libc::c_char` pointer initialized to `NULL` was passed as an argument to a C function that that mutates the pointer behind `&p` in-place (i.e. as an out-argument), which was unsound. After changes in recent versions of the Rust compiler, these unsound writes through `&p` now seem to be completely disregarded when building the `glib` crate with optimizations. This subsequently caused all calls of `VariantStrIter::impl_get` to violate the safety requirements of the `std::ffi::CStr::from_ptr` function - which requires its argument to be a valid pointer to a C-style string - resulting in crashes due to `NULL` pointer dereferences. This was fixed by passing the out-argument pointer explitly as `&mut p` instead of `&p`. This issue has been present since this code was initially added in `glib` v0.15.0. The mismatch in mutability was likely missed (and not raised as an error by the compiler) because the C function wrapped by `VariantStrIter::impl_get` is variadic (`glib_sys::g_variant_get_child`), and the pointer in question is one of the variadic arguments.

Why it matters now

Fix Fixed glib (crates.io): 0.20.0

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—glib (crates.io)0.15.0 to before 0.20.00.20.0Patch availableGHSA-wrw7-89jp-8q8g
  • glib (crates.io) Vendor— Affected 0.15.0 to before 0.20.0 Fixed in 0.20.0 Patch available GHSA-wrw7-89jp-8q8g

Remediation

  • Fix · GHSA-wrw7-89jp-8q8g glib (crates.io) Fixed in 0.20.0 Advisory →

Timeline

  1. 2026-10-03 Threatist record created from GHSA-wrw7-89jp-8q8g

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences