---
id: "CVE-2026-116742"
kind: "vulnerability"
aliases: ["CVE-2026-116742"]
title: "HTSlib: crafted .gzi index causes heap out-of-bounds write and read"
severity: "medium"
cvss: 4.8
epss: null
exploited: false
status: "open"
category: "package"
products: []
ecosystems: []
tags: ["bcftools", "bioinformatics", "c", "htslib", "package", "samtools"]
not_affected_if: ["no-gzi-indexes", "trusted-input-only"]
published_at: "2026-10-26T22:16:58+00:00"
first_seen_at: "2026-10-26T22:25:34+00:00"
updated_at: "2026-10-26T22:28:12+00:00"
sources: [{"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-116742", "first_seen_at": "2026-10-26T22:25:34+00:00"}]
---

# HTSlib: crafted .gzi index causes heap out-of-bounds write and read

HTSlib through 1.24 mishandles a .gzi index entry count of 0xFFFFFFFF in bgzf_index_load_hfile(), so noffs truncates to zero and writes go past a malloc(0) buffer. An attacker who supplies a crafted index file can corrupt heap memory, causing crashes or possibly further memory corruption in tools such as samtools and bcftools.

_Summary, check and fix written by a model from the sources; labelled as such._

## How to check

- Check the installed HTSlib or samtools version with `samtools --version` and compare it with the fixed release in the sources (unknown from the sources).
- Find whether tools process untrusted BGZF files with `.gzi` indexes, for example in pipelines that accept user-uploaded BAM, VCF or BGZF inputs.

## Fix

- Upgrade HTSlib, and the samtools and bcftools builds that link it, to a release later than 1.24 (the fixed version is unknown from the sources).
- Until patched, do not index or seek into `.gzi` files from untrusted sources.

## Timeline

- 2026-10-26T22:25:34+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-116742

## From the sources

HTSlib through 1.24 contains a heap out-of-bounds write and read vulnerability in bgzf_index_load_hfile() in bgzf.c that allows attackers to corrupt heap memory by supplying a crafted .gzi index entry count. A count of 0xFFFFFFFF truncates noffs to zero, causing writes past a malloc(0) buffer and an offs[-1] read in bgzf_useek(), resulting in heap corruption or crashes in tools like samtools and bcftools.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
