CVE-2026-31963: CWE-122: Heap-based Buffer Overflow in samtools htslib
HTSlib is a library for reading and writing bioinformatics file formats. CRAM is a compressed format which stores DNA sequence alignment data. As one method of removing redundant data, CRAM uses reference-based compression so that instead of storing the full sequence for each alignment record it stores a location in an external reference sequence along with a list of differences to the reference at that location as a sequence of "features". When decoding these features, an out-by-one error in a test for CRAM features that appear beyond the extent of the CRAM record sequence could result in an invalid write of one attacker-controlled byte beyond the end of a heap buffer. Exploiting this bug causes a heap buffer overflow. If a user opens a file crafted to exploit this issue, it could lead to the program crashing, or overwriting of data and heap structures in ways not expected by the program. It may be possible to use this to obtain arbitrary code execution. Versions 1.23.1, 1.22.2 and 1.21.1 include fixes for this issue. There is no workaround for this issue.
AI Analysis
Technical Summary
The vulnerability CVE-2026-31963 affects the htslib library, a core component of samtools widely used for reading and writing bioinformatics file formats such as CRAM, which compresses DNA sequence alignment data by referencing external sequences and encoding differences as features. The issue stems from an out-of-bounds write caused by an off-by-one error during the decoding of CRAM features that extend beyond the actual sequence length. This results in a heap-based buffer overflow where one attacker-controlled byte is written beyond the allocated heap buffer. Such memory corruption can lead to program instability, crashes, or more critically, arbitrary code execution if exploited successfully. The vulnerability requires no privileges or user interaction, making it remotely exploitable simply by opening a maliciously crafted CRAM file. The affected versions are those prior to 1.21.1, between 1.22 and 1.22.2, and version 1.23.1. The developers have released patches in versions 1.21.1, 1.22.2, and 1.23.1 to address this flaw. No alternative mitigations or workarounds are available, emphasizing the need for timely patching. The CVSS 4.0 base score is 8.8, reflecting its high severity due to ease of exploitation and potential impact on confidentiality and integrity of systems processing genomic data.
Potential Impact
This vulnerability can have severe consequences for organizations that utilize samtools and htslib for genomic data processing, including research institutions, healthcare providers, pharmaceutical companies, and biotech firms. Exploitation could lead to denial of service through application crashes or, more dangerously, arbitrary code execution, potentially allowing attackers to execute malicious payloads within the context of the vulnerable application. This could compromise sensitive genomic data confidentiality and integrity, disrupt critical bioinformatics workflows, and potentially serve as a foothold for further network intrusion. Given the specialized nature of the software, the impact is concentrated in sectors handling DNA sequencing data but can affect any organization relying on vulnerable versions. The lack of required authentication or user interaction increases the risk, especially in automated pipelines processing untrusted data. The absence of workarounds further elevates the urgency to apply patches promptly to avoid exploitation.
Mitigation Recommendations
Organizations should immediately identify and inventory all instances of samtools and htslib in their environments, especially those processing CRAM files. They must upgrade to fixed versions 1.21.1, 1.22.2, or 1.23.1 or later as soon as possible. For environments where immediate patching is challenging, consider isolating systems that process external or untrusted CRAM files to limit exposure. Implement strict input validation and scanning of bioinformatics data files before processing to detect potentially malformed or malicious CRAM files. Employ runtime protections such as heap memory protection mechanisms (e.g., ASLR, heap canaries) and sandboxing of bioinformatics tools to reduce the impact of exploitation. Monitor systems for unusual crashes or behavior indicative of exploitation attempts. Additionally, maintain up-to-date threat intelligence feeds to detect any emerging exploit activity targeting this vulnerability. Finally, establish secure data handling policies and restrict access to bioinformatics processing environments to trusted personnel and systems.
Affected Countries
United States, United Kingdom, Germany, France, Japan, China, South Korea, Canada, Australia, Netherlands, Switzerland, Singapore
CVE-2026-31963: CWE-122: Heap-based Buffer Overflow in samtools htslib
Description
HTSlib is a library for reading and writing bioinformatics file formats. CRAM is a compressed format which stores DNA sequence alignment data. As one method of removing redundant data, CRAM uses reference-based compression so that instead of storing the full sequence for each alignment record it stores a location in an external reference sequence along with a list of differences to the reference at that location as a sequence of "features". When decoding these features, an out-by-one error in a test for CRAM features that appear beyond the extent of the CRAM record sequence could result in an invalid write of one attacker-controlled byte beyond the end of a heap buffer. Exploiting this bug causes a heap buffer overflow. If a user opens a file crafted to exploit this issue, it could lead to the program crashing, or overwriting of data and heap structures in ways not expected by the program. It may be possible to use this to obtain arbitrary code execution. Versions 1.23.1, 1.22.2 and 1.21.1 include fixes for this issue. There is no workaround for this issue.
AI-Powered Analysis
Technical Analysis
The vulnerability CVE-2026-31963 affects the htslib library, a core component of samtools widely used for reading and writing bioinformatics file formats such as CRAM, which compresses DNA sequence alignment data by referencing external sequences and encoding differences as features. The issue stems from an out-of-bounds write caused by an off-by-one error during the decoding of CRAM features that extend beyond the actual sequence length. This results in a heap-based buffer overflow where one attacker-controlled byte is written beyond the allocated heap buffer. Such memory corruption can lead to program instability, crashes, or more critically, arbitrary code execution if exploited successfully. The vulnerability requires no privileges or user interaction, making it remotely exploitable simply by opening a maliciously crafted CRAM file. The affected versions are those prior to 1.21.1, between 1.22 and 1.22.2, and version 1.23.1. The developers have released patches in versions 1.21.1, 1.22.2, and 1.23.1 to address this flaw. No alternative mitigations or workarounds are available, emphasizing the need for timely patching. The CVSS 4.0 base score is 8.8, reflecting its high severity due to ease of exploitation and potential impact on confidentiality and integrity of systems processing genomic data.
Potential Impact
This vulnerability can have severe consequences for organizations that utilize samtools and htslib for genomic data processing, including research institutions, healthcare providers, pharmaceutical companies, and biotech firms. Exploitation could lead to denial of service through application crashes or, more dangerously, arbitrary code execution, potentially allowing attackers to execute malicious payloads within the context of the vulnerable application. This could compromise sensitive genomic data confidentiality and integrity, disrupt critical bioinformatics workflows, and potentially serve as a foothold for further network intrusion. Given the specialized nature of the software, the impact is concentrated in sectors handling DNA sequencing data but can affect any organization relying on vulnerable versions. The lack of required authentication or user interaction increases the risk, especially in automated pipelines processing untrusted data. The absence of workarounds further elevates the urgency to apply patches promptly to avoid exploitation.
Mitigation Recommendations
Organizations should immediately identify and inventory all instances of samtools and htslib in their environments, especially those processing CRAM files. They must upgrade to fixed versions 1.21.1, 1.22.2, or 1.23.1 or later as soon as possible. For environments where immediate patching is challenging, consider isolating systems that process external or untrusted CRAM files to limit exposure. Implement strict input validation and scanning of bioinformatics data files before processing to detect potentially malformed or malicious CRAM files. Employ runtime protections such as heap memory protection mechanisms (e.g., ASLR, heap canaries) and sandboxing of bioinformatics tools to reduce the impact of exploitation. Monitor systems for unusual crashes or behavior indicative of exploitation attempts. Additionally, maintain up-to-date threat intelligence feeds to detect any emerging exploit activity targeting this vulnerability. Finally, establish secure data handling policies and restrict access to bioinformatics processing environments to trusted personnel and systems.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-03-10T15:40:10.484Z
- Cvss Version
- 4.0
- State
- PUBLISHED
Threat ID: 69baf24a771bdb1749bb3c57
Added to database: 3/18/2026, 6:43:22 PM
Last enriched: 3/18/2026, 6:57:40 PM
Last updated: 3/18/2026, 7:44:22 PM
Views: 4
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console in Console -> Billing for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.