CVE-2026-31972: Samtools Mplp Ref Undersized Lru Cache Uaf

The mpileup reference cache struct uses only 2 slots (char *ref[2] / int ref_id[2] / hts_pos_t ref_len[2]), but the pileup pipeline with `-a` can require 3 concurrent live references (current contig, previous contig still being flushed for -a, and a look-ahead loaded by bam_mplp64_auto). With only 2 slots, mplp_get_ref() evicts and free()s a reference buffer

Provally CuratedPublic repositoryHighHigh confidenceVerifiedApache-2.0C
greprules fetch cve-2026-31972-samtools-mplp-ref-undersized-lru-cache-uaf --engine opengrep

Description

The mpileup reference cache struct uses only 2 slots (char *ref[2] / int ref_id[2] / hts_pos_t ref_len[2]), but the pileup pipeline with `-a` can require 3 concurrent live references (current contig, previous contig still being flushed for -a, and a look-ahead loaded by bam_mplp64_auto). With only 2 slots, mplp_get_ref() evicts and free()s a reference buffer