REDHAT-BUG-2478395: Use After Free

Published May 18, 2026
·
Updated

AIONLYREPORT package: gcc-toolset-15-gcc-15.2.1-7.el10 ------ Summary: gnupbds::detail::binaryheap::eraseif use-after-free and stale-pointer free in reallocation path: calling eraseif on a binaryheaptag-backed pbds priority queue can leave the internal entry-array pointer dangling, leading to heap use-after-free during makeheap() and a later stale-pointer free during cleanup. Requirements to exploit: An attacker needs a path to make an application built from this SRPM instantiate gnupbds::priorityqueue<..., binaryheaptag> and call eraseif; once that public API path is exercised, subsequent heap operations or object teardown can act on freed storage. Component affected: gcc-toolset-15-gcc-15.2.1-7.el10, libstdc++-v3/include/ext/pbds/detail/binaryheap/erasefnimps.hpp, gnupbds::detail::binaryheap::eraseif Version affected: gcc-toolset-15-gcc-15.2.1-7.el10 Patch available: no released package fix established; proposed patch included below Version fixed: unknown Upstream coordination: Not notified. CVSS: CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H - 7.8 (HIGH) AV:L - Exploitation requires reaching this local library API in a process using the affected pbds container path. AC:L - Once binaryheaptag and eraseif are in use, the vulnerable sequence is straightforward to trigger. PR:N - No privileges are required beyond reaching the affected call path in the target process. UI:N - No separate user interaction is required. S:U - The resulting corruption stays within the security scope of the calling process. C:L - In-process memory misuse could expose some data, but broader disclosure is not established here. I:L - Heap corruption can alter in-process state, but arbitrary code execution is not demonstrated by the available evidence. A:H - Use-after-free and stale-pointer free conditions are likely to crash or seriously destabilize the affected process. Impact: Moderate. This is a real memory-corruption flaw with likely process-level availability impact and some in-process integrity or confidentiality risk, but exploitability is limited to consumers that opt into the pbds binaryheaptag backend and invoke eraseif on that path. Under Red Hat's severity guidance, that narrower, non-default reachability fits Moderate more closely than Important or Critical. Embargo: no Reason: The issue is local and API-specific, with no evidence of default remote exposure in the shipped package. Public coordination without extended embargo is proportionate unless a broadly exposed consumer of this path is identified. Acknowledgement: Aisle Research Vulnerability Details: The pbds binary heap backend reallocates the entry array inside eraseif, but does not update maentries to the new allocation before continuing. The vulnerable block is: cpp const sizetype newsize = resizepolicy::getnewsizeforarbitrary(left); entrypointer newentries = sentryallocator.allocate(newsize); std::copy(maentries, maentries + left, newentries); sentryallocator.deallocate(maentries, mactualsize); mactualsize = newsize; resizepolicy::notifyarbitrary(mactualsize); After that, eraseif rebuilds the heap: cpp msize = left; makeheap(); makeheap() uses maentries directly: cpp entrypointer end = maentries + msize; std::makeheap(maentries, end, mcmp); Because maentries = newentries; is missing, makeheap() operates on freed storage after successful reallocation. Later cleanup may deallocate the stale maentries again, leading to an invalid free or double-free condition. Nearby reallocation paths in the same component do update maentries, which supports that this omission is unintended. Steps to reproduce: 1. Build a small C++ test with AddressSanitizer enabled and use pbds priorityqueue with binaryheaptag. 2. Insert enough elements to force dynamic storage growth. 3. Call eraseif with a predicate that removes entries. 4. Continue heap activity, or allow the object to destruct. 5. Observe invalid memory behavior, typically a use-after-free during heap repair and potentially an invalid free during teardown. Minimal PoC: cpp #include <ext/pbds/priorityqueue.hpp> using namespace gnupbds; int main() { priorityqueue<int, std::less<int>, binaryheaptag> q; for (int i = 0; i < 1000; ++i) q.push; q.eraseif( { return (v % 2) == 0; }); q.push(42); q.pop(); } Mitigation: Until a fixed package is available, avoid calling eraseif on gnupbds::priorityqueue instances that use binaryheaptag in code built from this SRPM. If predicate-based removal is required, use an alternative container or backend, or rebuild with the patch below applied. Proposed Fix: Store the replacement entry array in maentries before freeing the old array, and copy from the saved old pointer. diff diff --git a/libstdc++-v3/include/ext/pbds/detail/binaryheap/erasefnimps.hpp b/libstdc++-v3/include/ext/pbds/detail/binaryheap/erasefnimps.hpp @@ -118,9 +118,11 @@ PBDSCLASSCDEC::eraseif(Pred pred) const sizetype newsize = resizepolicy::getnewsizeforarbitrary(left); + entrypointer oldentries = maentries; entrypointer newentries = sentryallocator.allocate(newsize); std::copy(maentries, maentries + left, newentries);

sentryallocator.deallocate(maentries, mactualsize); + std::copy(oldentries, oldentries + left, newentries); + maentries = newentries; + sentryallocator.deallocate(oldentries, mactualsize); mactualsize = newsize; resizepolicy::notifyarbitrary(mactualsize);

------ This report was generated using AI technology. Always review AI-generated content prior to use

Affected Software

1 affected component
redhat/gcc-toolset-15-gcc=15.2.1-7.el10

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Compensating control

    Until a fixed package is available, avoid calling `erase_if` on `__gnu_pbds::priority_queue` instances using `binary_heap_tag`; use an alternative container or backend instead.

  2. Compensating control

    Rebuild the affected component with the proposed source patch: in `libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp`, assign `m_a_entries = new_entries` before deallocating `old_entries` and copying entries.

Event History

May 18, 2026
Data Sourced
via Red Hat·03:33 AM
DescriptionSeverityAffected Software

Frequently Asked Questions

1

Which applications are exposed to this issue?

Applications built from the affected SRPM that instantiate __gnu_pbds::priority_queue with binary_heap_tag and expose a path that calls erase_if are affected. The issue is in the libstdc++ pb_ds binary-heap implementation.

2

What must an attacker be able to do to trigger the flaw?

An attacker must be able to reach an application path that invokes erase_if on a binary_heap_tag-backed pb_ds priority queue. Subsequent heap operations or destruction of the queue can then use or free already-freed storage.

3

How can I determine whether my application is at risk?

Review the application source and reachable runtime paths for use of __gnu_pbds::priority_queue configured with binary_heap_tag, especially calls to erase_if. Systems using gcc-toolset-15-gcc-15.2.1-7.el10 should be prioritized for that review.

4

What should I do if a package update is not available?

No released package fix has been established. Until a validated fix is available, avoid or remove reachable erase_if calls on binary_heap_tag-backed pb_ds priority queues where possible.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203