Cyber Resilience

CVE-2026-31968

Memory Safety in Htslib ≤ 1.21.1

Published
18 March 2026
Modified
19 March 2026
Patch / advisory
CVSS Score v4 8.8
Click a component to see what it means
Raw vectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/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
EPSS Score 0.0041 34th percentile
Risk Priority 44 floored blend · peak EPSS

Summary

CVE-2026-31968 is a high-severity Stack-based Buffer Overflow (CWE-121) vulnerability in Htslib Htslib. Its CVSS base score is 8.8 (High).

Operationally, exploitation aligns with the MITRE ATT&CK technique Exploitation for Privilege Escalation (T1068); ranked at the 34th percentile by exploit likelihood (below the median); it is not currently listed in the CISA KEV catalog.

The strongest mitigations our analysis identified map to SA-11 (Developer Testing and Evaluation) and SI-10 (Information Input Validation) — see the control section below for these in your framework.

Deeper analysis AI-assisted summary

Synthesised by an AI model from the NVD description and linked references — a reading aid, not an authoritative source.

HTSlib, a C library for high-throughput sequencing data storage formats including CRAM, contains a vulnerability in its handling of the VARINT and CONST encodings used in CRAM files for DNA sequence alignment data. Incomplete validation of the encoding context can result in up to eight bytes being written beyond the end of a heap allocation or overwriting a one-byte stack variable, potentially corrupting adjacent variables. This issue manifests as either a heap buffer overflow or stack overflow, affecting applications that use HTSlib to read CRAM files.

A remote attacker can exploit this vulnerability by crafting a malicious CRAM file and tricking a user into opening it with an affected HTSlib-based application, as it requires user interaction but no privileges. Successful exploitation could cause the program to crash, overwrite heap or stack data structures unexpectedly, alter program control flow, or enable arbitrary code execution, with high impact on integrity and availability per its CVSS score of 8.1.

The HTSlib security advisory and associated patch commit detail fixes in versions 1.23.1, 1.22.2, and 1.21.1, which address the validation flaws in VARINT and CONST encoding contexts. No workaround is available, so users should update to a patched version promptly. Relevant resources include the GitHub security advisory at https://github.com/samtools/htslib/security/advisories/GHSA-cgcm-c9r2-p57j and the fixing commit at https://github.com/samtools/htslib/commit/0ec436796eca7b4ce7fcc9b77270c102da29bb2e.

EU & UK References

Vulnerability Data

HTSlib is a library for reading and writing bioinformatics file formats. CRAM is a compressed format which stores DNA sequence alignment data using a variety of encodings and compression methods. For the `VARINT` and `CONST` encodings, incomplete validation of the…

more

context in which the encodings were used could result in up to eight bytes being written beyond the end of a heap allocation, or up to eight bytes being written to the location of a one byte variable on the stack, possibly causing the values to adjacent variables to change unexpectedly. Depending on the data stream this could result either in a heap buffer overflow or a stack overflow. If a user opens a file crafted to exploit this issue it could lead to the program crashing, overwriting of data structures on the heap or stack in ways not expected by the program, or changing the control flow of 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.

CWE(s)

Related Threats

MITRE ATT&CK Enterprise Techniques

T1068 Exploitation for Privilege Escalation Privilege Escalation
Adversaries may exploit software vulnerabilities in an attempt to elevate privileges.
T1190 Exploit Public-Facing Application Initial Access
Adversaries may attempt to exploit a weakness in an Internet-facing host or system to initially access a network.
T1203 Exploitation for Client Execution Execution
Adversaries may exploit software vulnerabilities in client applications to execute code.
T1210 Exploitation of Remote Services Lateral Movement
Adversaries may exploit remote services to gain unauthorized access to internal systems once inside of a network.
T1211 Exploitation for Stealth Stealth
Adversaries may exploit vulnerabilities to evade detection by hiding activity, suppressing logging, or operating within trusted or unmonitored components.
T1212 Exploitation for Credential Access Credential Access
Adversaries may exploit software vulnerabilities in an attempt to collect credentials.
Derived from this CVE’s CWE(s) via the direct CWE→ATT&CK cross-walk.

CVEs Like This One

CVE-2026-31971Same product: Htslib Htslib
CVE-2023-40465Shared CWE-121, CWE-122
CVE-2023-4756Shared CWE-121, CWE-787
CVE-2023-45225Shared CWE-121, CWE-787
CVE-2024-4494Shared CWE-121, CWE-787
CVE-2024-3758Shared CWE-122, CWE-787
CVE-2023-37294Shared CWE-122, CWE-787
CVE-2024-4236Shared CWE-121, CWE-787
CVE-2024-27374Shared CWE-122, CWE-787
CVE-2024-4118Shared CWE-121, CWE-787

Affected Assets

htslib
htslib
1.23 · ≤ 1.21.1 · 1.22 — 1.22.2

Mitigating Controls

Control response

Prevent
Stop it (NIST 800-53)

Detect
Catch it (NIST detect / respond)

Harden
Shrink the surface (DISA STIG)
  • 2 hardening rules · 2 OS baselines
Validate
Prove the fix (OWASP ASVS)
  • V1.4.1
  • V1.5.2
  • V3.2.3
  • V15.3.5

Mitigating Controls (NIST 800-53 r5) AI

Developer testing and analysis can discover stack-buffer overflows before deployment.

Input validation directly stops untrusted data from exceeding stack buffer bounds.

Memory-protection mechanisms limit the ability to execute injected code after a stack overflow.

Requiring documented secure-development standards and tools can mandate bounds-checked coding practices that avoid the weakness.

Secure-engineering principles include bounds-checked coding and safe buffer handling that avoid introducing the flaw.

Mitigating Controls (NIST CSF 2.0) AI

Derived directly from the weakness types (CWEs) cited in the NVD entry via our AI-authored CWE→CSF cross-walk (authority under review) — links open the control.

PR.PS-06 full match
prevents

Secure-development practices directly require bounds checking and safe memory handling that prevent heap overflows.

ID.RA-01 partial match
prevents

Vulnerability scanning can discover stack buffer overflows but does not prevent their introduction.

PR.PS-02 partial match
prevents

Patching eliminates known instances of the weakness after discovery.

Mitigating Controls (ISO/IEC 27001:2022 Annex A) AI

Derived directly from the weakness types (CWEs) cited in the NVD entry via our AI-authored CWE→ISO cross-walk (authority under review) — links open the control.

finds

Security testing (fuzzing, static analysis) detects stack overflows before release.

prevents

Secure SDLC mandates buffer-safety practices that directly prevent stack overflows.

prevents

Application security requirements can specify buffer-size and input-validation rules.

prevents

Secure architecture principles include memory-safety and least-privilege stack usage.

prevents

Secure coding standards explicitly forbid unsafe buffer handling that causes CWE-121.

prevents

Change management can enforce review gates that catch unsafe memory operations before deployment.

Hardening callouts derived

Configuration rules from DISA STIG baselines that bear on weaknesses of the type cited by this CVE. Each rule is shown with the relationship its mapping actually records, against the CWE it was authored against. Derived via CVE→CWE over `controls_xwalks` (authoritative rows only; rows rated `none` are excluded).

Oracle Linux 8 (1 rule)
  • V-248594 OL 8 must implement address space layout randomization (ASLR) to protect its memory from unauthorized code execution. prevents CWE-121
Oracle Linux 9 (1 rule)
  • V-271452 OL 9 must use a Linux Security Module configured to enforce limits on system services. prevents CWE-121

References