# UAF from shared container state

Container storage freed or resized while another holder still points into it

_Area: Memory corruption and native code. Seen in 4 disclosed reports; latest 2026-11-24. Updated 2026-12-01._

## How it works
A container (hash table, reference table, wait queue, connection pool) is shared between two holders that assume different lifetimes. One holder frees or resizes the backing storage — buckets, entries, the queue head, a pooled connection — while the other still holds a pointer into it. The break is a lifetime assumption: the code assumes the entry or queue lives as long as the reference, but a second path (thread exit, recursive parse, election cleanup, connection drain) ends it first. The stale pointer is then read, unlinked, or freed again.

## Where it shows up
- Poll handlers passing a wait queue embedded in a struct whose lifetime is shorter than the file's, freed without POLLFREE [E1](https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md)
- Recursive or re-entrant parsers that share one reference/bucket table across nested calls [E2](https://bugbountylibrary.com/r/blog%3Ablog-calif-io-p-the-wordpress-chain-massacre.md)
- Pre-auth commands that register persistent server-side state (waiters, cursors) surviving past the request [E3](https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free.md)
- Cleanup paths that can run twice on the same state (catch-up abort, thread exit) [E1](https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md)[E3](https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free.md)
- Reusability flags set on an early-return path and not cleared when a live object is later created on the same connection [E4](https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md)

## How to review
For each container, name every holder and its lifetime. The invariant: no holder may free or resize storage while any other holder retains a pointer into it, and every teardown path must notify all registered holders (POLLFREE, lock, refcount). Check that recursive/re-entrant entry takes the same lock or uses a separate table. Check that cleanup is idempotent and cannot run twice. For pooled or reusable resources, check that every flag marking an object reclaimable is cleared on the path that makes it live, and that no allocation inside a live request can trigger a drain of its own connection [E4](https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md).

## How finders spotted it
- Started from a KASAN crash in remove_wait_queue, then asked whether the wait queue outlives the struct; inferred exploitation constraints from config descriptions (DEBUG_LIST, ARM64_UAO) [E1](https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md)
- Noted PHP execution was boxed by disable_functions and read-only mounts, then sought a memory-corruption bug triggerable from pure PHP and chose a UAF for its arbitrary-read and fake-object primitives [E2](https://bugbountylibrary.com/r/blog%3Ablog-calif-io-p-the-wordpress-chain-massacre.md)
- Reasoned that ping is pre-auth and readConcern.afterOpTime creates persistent waiters, hypothesized survival into catch-up cleanup, reproduced with induced lag and failover in a lab replica set [E3](https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free.md)
- Read ngx_http_v2_create_stream() and noticed it returns with the reusable mark still set after a partial frame header; reasoned that a request-time DNS socket allocation under connection pressure would drain the live connection and free resolver state [E4](https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md)

## Variants seen
- Wait queue embedded in a freed thread struct, retained by epoll [E1](https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md)
- Shared reference table across recursive unserialize; inner resize frees buckets the outer parser still references (inferred from the shared-table root cause) [E2](https://bugbountylibrary.com/r/blog%3Ablog-calif-io-p-the-wordpress-chain-massacre.md)
- Persistent waiters outliving requests, cleanup running twice at election catch-up [E3](https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free.md)
- Connection marked reusable during stream creation; connection drain frees resolver state under a live request [E4](https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md)

## Impact and severity
Kernel read/write to root via an epoll-driven unlink primitive, chained with DAC/SELinux/Knox/RKP bypass [E1](https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md); PHP-level RCE to native code bypassing disable_functions, then page-cache overwrite of a setuid binary to root [E2](https://bugbountylibrary.com/r/blog%3Ablog-calif-io-p-the-wordpress-chain-massacre.md); unauthenticated crash of a new primary [E3](https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free.md); pre-auth RCE as www-data when combined with a libc pointer disclosure to defeat ASLR [E4](https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md). Impact rises with pre-auth reachability [E3](https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free.md)[E4](https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md), primitive quality (arbitrary write/read) [E1](https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md)[E2](https://bugbountylibrary.com/r/blog%3Ablog-calif-io-p-the-wordpress-chain-massacre.md), and chaining with sandbox, ASLR or privilege bypasses [E1](https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md)[E2](https://bugbountylibrary.com/r/blog%3Ablog-calif-io-p-the-wordpress-chain-massacre.md)[E4](https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md).

## Seen in real software
Open-source packages and projects, and products, where this pattern was found. If the target runs one, compare the version it runs with the fix.
- **nginx** (HTTP/2 stream creation (ngx_http_v2_create_stream)) 1.19.7 through 1.30.6 and 1.31.0 through 1.31.8, fixed in 1.30.7 and 1.31.9: NGINX HTTP/2 Use-After-Free: CVE-2026-123633 (CVE-2026-123633). Report: https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md
- **MongoDB Server** (CatchupState::abort_inlock()) 8.0.34, fixed in 8.0.37: CVE-2026-118383: Use-after-free vulnerability in MongoDB (CVE-2026-118383). Report: https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free.md
- **PHP** (legacy Serializable unserialize path) (version not stated): The WordPress Chain Massacre. Report: https://bugbountylibrary.com/r/blog%3Ablog-calif-io-p-the-wordpress-chain-massacre.md
- **Google Android** (Binder kernel driver) Pre-Oct 6 2019 SPL for devices released prior to Fall 2019, fixed in 6 Oct 2019 SPL+: CVE-2019-2215: Android use-after-free in Binder (CVE-2019-2215). Report: https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md

## Evidence
- E1: https://bugbountylibrary.com/r/p0%3ACVE-2019-2215.md
- E2: https://bugbountylibrary.com/r/blog%3Ablog-calif-io-p-the-wordpress-chain-massacre.md
- E3: https://bugbountylibrary.com/r/blog%3Asecuritylabs-datadoghq-com-articles-cve-2026-118383-mongodb-server-use-after-free.md
- E4: https://bugbountylibrary.com/r/blog%3Aunit42-paloaltonetworks-com-cve-2026-123633-nginx-http2-vulnerability.md
