Cyber Resilience

CVE-2026-31971

Memory Safety in Htslib ≤ 1.21.1

Published
18 March 2026
Modified
19 March 2026
Patch / advisory
CVSS Score v4 7.1
Click a component to see what it means
Raw vectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/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.0034 26th percentile
Risk Priority 55 floored blend · peak EPSS

Summary

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

Operationally, exploitation aligns with the MITRE ATT&CK technique Exploitation for Privilege Escalation (T1068); ranked at the 26th 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 reading and writing high-throughput sequencing data formats including CRAM, is affected by CVE-2026-31971, published on 2026-03-18. The vulnerability occurs in the cram_byte_array_len_decode() function when processing data encoded with the BYTE_ARRAY_LEN method in CRAM files, which store compressed DNA sequence alignment data. This function fails to validate that the unpacked data size matches the output buffer, resulting in either a heap buffer overflow or stack overflow using attacker-controlled bytes. The issue is rated 8.1 on the CVSS 3.1 scale (AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H) and maps to CWEs 121 (stack-based buffer overflow), 122 (heap-based buffer overflow), 787 (out-of-bounds write), and 1284 (buffer underwrite).

Exploitation requires an attacker to craft a malicious CRAM file and convince a user to open it in an application linked to a vulnerable HTSlib version, such as bioinformatics tools processing sequencing data. No privileges are needed (PR:N), and attacks can originate remotely (AV:N) with low complexity (AC:L), though user interaction is required (UI:R). Outcomes include program crashes, unexpected overwriting of heap or stack data structures, control flow hijacking, or potential arbitrary code execution, with high impacts on integrity and availability but no confidentiality loss.

Mitigation is available via patches in HTSlib versions 1.23.1, 1.22.2, and 1.21.1; no workaround exists. The GitHub security advisory (GHSA-jvx4-4wq7-6fmh) and fixing commit (01cd003b46fa2ebea4d9be5475b11217eb4c11be) provide full details on the changes. Security practitioners should prioritize updating affected bioinformatics pipelines and scanning for vulnerable HTSlib instances.

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. When reading data encoded using the `BYTE_ARRAY_LEN` method, the `cram_byte_array_len_decode()`…

more

failed to validate that the amount of data being unpacked matched the size of the output buffer where it was to be stored. Depending on the data series being read, this could result either in a heap or a stack overflow with attacker-controlled bytes. 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-31968Same product: Htslib Htslib
CVE-2024-5931Shared CWE-121, CWE-1284
CVE-2023-40465Shared CWE-121, CWE-122
CVE-2025-55095Shared CWE-121, CWE-787
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

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)
  • V6.7.2
  • V1.4.1
  • V1.4.2
  • V2.1.1

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