Heap-based Buffer Overflow Affecting samtools/htslib package, versions [,1.21.1)[1.22,1.22.2)[1.23,1.23.1)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.52% (45th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Heap-based Buffer Overflow vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-UNMANAGED-SAMTOOLSHTSLIB-15762291
  • published24 Mar 2026
  • disclosed18 Mar 2026
  • creditHarrison Green

Introduced: 18 Mar 2026

CVE-2026-31970  (opens in a new tab)
CWE-122  (opens in a new tab)

How to fix?

Upgrade samtools/htslib to version 1.21.1, 1.22.2, 1.23.1 or higher.

Overview

Affected versions of this package are vulnerable to Heap-based Buffer Overflow in the bgzf_index_load_hfile function. An attacker can cause a program crash or potentially achieve arbitrary code execution by providing a specially crafted .gzi index file that triggers an integer overflow, leading to improper buffer allocation and subsequent heap buffer overflow.

Workaround

This vulnerability can be mitigated by discarding .gzi index files from untrusted sources and recreating them using the bgzip -r option.

CVSS Base Scores

version 4.0
version 3.1