CVE-2026-31972
Use-After-Free in SAMtools mpileup Causes Information Leak and Crash
Publication date: 2026-03-18
Last updated on: 2026-03-19
Assigner: GitHub, Inc.
Description
Description
CVSS Scores
EPSS Scores
| Probability: | |
| Percentile: |
Meta Information
Affected Vendors & Products
| Vendor | Product | Version / Range |
|---|---|---|
| samtools | samtools | to 1.21.1 (exc) |
Helpful Resources
Exploitability
| CWE ID | Description |
|---|---|
| CWE-416 | The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. |
Attack-Flow Graph
AI Powered Q&A
Can you explain this vulnerability to me?
[{'type': 'paragraph', 'content': 'CVE-2026-31972 is a use-after-free vulnerability in the `mpileup` command of SAMtools, a bioinformatics tool used for processing DNA sequence alignment data. The vulnerability occurs because SAMtools prematurely discards reference data after printing it, which leads to attempts to read from memory that has already been freed.'}, {'type': 'paragraph', 'content': "This invalid memory access can cause the program to crash or leak information about the program's internal state. The issue affects SAMtools versions up to 1.21 and is fixed in versions 1.21.1 and 1.22."}, {'type': 'paragraph', 'content': 'The vulnerability can be exploited remotely without any privileges or user interaction, and it has a moderate severity with a CVSS v4 base score of 6.9.'}] [1]
How can this vulnerability impact me? :
[{'type': 'paragraph', 'content': 'This vulnerability can impact you by causing the SAMtools program to crash unexpectedly due to invalid memory access.'}, {'type': 'paragraph', 'content': "Additionally, it may lead to leakage of information about the program's internal state, which could potentially expose sensitive data processed by SAMtools."}, {'type': 'paragraph', 'content': 'Since the vulnerability can be exploited remotely without any privileges or user interaction, it poses a risk to systems running vulnerable versions of SAMtools, especially in automated or remote bioinformatics workflows.'}] [1]
How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:
I don't know
How can this vulnerability be detected on my network or system? Can you suggest some commands?
This vulnerability is a use-after-free bug in the mpileup command of SAMtools versions up to 1.21. It may cause program crashes or leak information about program state when processing DNA sequence alignments.
Detection involves identifying if your system is running a vulnerable version of SAMtools (version 1.21 or earlier) and if the mpileup command is used.
Since the issue manifests as crashes or memory errors during mpileup execution, you can detect it by running mpileup on representative data and monitoring for crashes or memory errors.
- Check SAMtools version: `samtools --version`
- Run mpileup on test data and observe for crashes or abnormal termination.
- Use memory debugging tools such as AddressSanitizer or Valgrind to detect use-after-free errors when running mpileup.
What immediate steps should I take to mitigate this vulnerability?
There is no workaround for this vulnerability.
The immediate and recommended mitigation is to update SAMtools to a fixed version, specifically version 1.21.1 or later.
Updating to these versions resolves the use-after-free bug by properly handling reference caching in the mpileup command.