HtslibApplication

CVE-2026-31970

HIGH · 8.1 CVSS v3.1 Published 2026-03-18
Fix available
A fix is available. Upgrade to 1.21 / 1.22.2 or later.
See remediation →
88/100
Remediation priority · High
Remotely reachable No privileges Patch available

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
HTSlib is a library for reading and writing bioinformatics file formats. GZI files are used to index block-compressed GZIP [BGZF] files. In the GZI loading function, `bgzf_index_load_hfile()`, it was possible to trigger an integer overflow, leading to an under- or zero-sized buffer being allocated to store the index. Sixteen zero bytes would then be written to this buffer, and, depending on the result of the overflow the rest of the file may also be loaded into the buffer as well. If the function did attempt to load the data, it would eventually fail due to not reading the expected number of records, and then try to free the overflowed 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. The easiest work-around is to discard any `.gzi` index files from untrusted sources, and use the `bgzip -r` option to recreate them.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis
How this class of weakness works · CWE-122

Data overflows a buffer allocated on the heap, corrupting neighbouring heap structures and allocator metadata that a patient attacker can groom into control of execution. It is subtler than a stack overflow but just as dangerous. The fix is validating lengths before every write and using safe allocators and bounded operations.

General guidance for the heap-based buffer overflow class — the official description and references above are authoritative for this specific CVE. Want a bespoke review and a reviewed fix? Ask our team →

Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.

NVD · CPE data
HtslibApplication
Affected:< 1.21>= 1.22, < 1.22.2= 1.23

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
None
User interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

dbcve · scoped
Upgrade available Upgrade to 1.21 / 1.22.2 or later
Fixed in 1.211.22.2
Vendor patch github.com →
Recommended fix High confidence

htslib 1.23.1 (or minimum 1.22.2 / 1.21.1 depending on your branch)

  1. Identify the current htslib version in your environment by checking your project's dependencies or running `htsversion` if available
  2. For package managers: update htslib to version 1.21.1, 1.22.2, or 1.23.1 (preferably 1.23.1 for latest fixes)
  3. If building from source: download htslib 1.23.1 from https://github.com/samtools/htslib/releases/tag/1.23.1 or clone and checkout that tag, then rebuild
  4. Recompile any applications that link against htslib to ensure they use the updated library
  5. As a configuration workaround for untrusted files: avoid using .gzi index files from untrusted sources; instead use `bgzip -r` to regenerate index files from trusted data
  6. Verify the upgrade was successful by confirming the new library version loads correctly
Caveat Minor version upgrades within the same major series typically have no breaking API changes; however, recompilation of dependent applications is required

Generated from the published advisory — verify against the referenced sources before acting.

We can perform the upgrade in your staging environment and verify nothing breaks — typical engagement from $1,950. Get the upgrade done

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2026-31970 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2026-31970 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data