2026-03-18 18:22CVE-2026-31963GitHub_M
PUBLISHED5.2CWE-122CWE-129CWE-787

HTSlib CRAM reader has heap buffer overflow due to improper validation of input

HTSlib is a library for reading and writing bioinformatics file formats. CRAM is a compressed format which stores DNA sequence alignment data. As one method of removing redundant data, CRAM uses reference-based compression so that instead of storing the full sequence for each alignment record it stores a location in an external reference sequence along with a list of differences to the reference at that location as a sequence of "features". When decoding these features, an out-by-one error in a test for CRAM features that appear beyond the extent of the CRAM record sequence could result in an invalid write of one attacker-controlled byte beyond the end of a 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. There is no workaround for this issue.

Problem type

Affected products

samtools

htslib

< 1.21.1 - AFFECTED

>= 1.22, < 1.22.2 - AFFECTED

= 1.23 - AFFECTED

References

JSON source

https://cveawg.mitre.org/api/cve/CVE-2026-31963
Click to expand
{
  "dataType": "CVE_RECORD",
  "dataVersion": "5.2",
  "cveMetadata": {
    "cveId": "CVE-2026-31963",
    "assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
    "assignerShortName": "GitHub_M",
    "dateUpdated": "2026-03-18T18:52:43.260Z",
    "dateReserved": "2026-03-10T15:40:10.484Z",
    "datePublished": "2026-03-18T18:22:58.440Z",
    "state": "PUBLISHED"
  },
  "containers": {
    "cna": {
      "providerMetadata": {
        "orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
        "shortName": "GitHub_M",
        "dateUpdated": "2026-03-18T18:22:58.440Z"
      },
      "title": "HTSlib CRAM reader has heap buffer overflow due to improper validation of input",
      "descriptions": [
        {
          "lang": "en",
          "value": "HTSlib is a library for reading and writing bioinformatics file formats. CRAM is a compressed format which stores DNA sequence alignment data. As one method of removing redundant data, CRAM uses reference-based compression so that instead of storing the full sequence for each alignment record it stores a location in an external reference sequence along with a list of differences to the reference at that location as a sequence of \"features\". When decoding these features, an out-by-one error in a test for CRAM features that appear beyond the extent of the CRAM record sequence could result in an invalid write of one attacker-controlled byte beyond the end of a 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. There is no workaround for this issue."
        }
      ],
      "affected": [
        {
          "vendor": "samtools",
          "product": "htslib",
          "versions": [
            {
              "version": "< 1.21.1",
              "status": "affected"
            },
            {
              "version": ">= 1.22, < 1.22.2",
              "status": "affected"
            },
            {
              "version": "= 1.23",
              "status": "affected"
            }
          ]
        }
      ],
      "problemTypes": [
        {
          "descriptions": [
            {
              "lang": "en",
              "description": "CWE-122: Heap-based Buffer Overflow",
              "cweId": "CWE-122",
              "type": "CWE"
            }
          ]
        },
        {
          "descriptions": [
            {
              "lang": "en",
              "description": "CWE-129: Improper Validation of Array Index",
              "cweId": "CWE-129",
              "type": "CWE"
            }
          ]
        },
        {
          "descriptions": [
            {
              "lang": "en",
              "description": "CWE-787: Out-of-bounds Write",
              "cweId": "CWE-787",
              "type": "CWE"
            }
          ]
        }
      ],
      "references": [
        {
          "url": "https://github.com/samtools/htslib/security/advisories/GHSA-qgqh-h2q9-7w3c",
          "name": "https://github.com/samtools/htslib/security/advisories/GHSA-qgqh-h2q9-7w3c",
          "tags": [
            "x_refsource_CONFIRM"
          ]
        },
        {
          "url": "https://github.com/samtools/htslib/commit/8bcc9907be0f945ddc31796d64f078fa05456acd",
          "name": "https://github.com/samtools/htslib/commit/8bcc9907be0f945ddc31796d64f078fa05456acd",
          "tags": [
            "x_refsource_MISC"
          ]
        }
      ],
      "metrics": [
        {}
      ]
    },
    "adp": [
      {
        "providerMetadata": {
          "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
          "shortName": "CISA-ADP",
          "dateUpdated": "2026-03-18T18:52:43.260Z"
        },
        "title": "CISA ADP Vulnrichment",
        "metrics": [
          {}
        ]
      }
    ]
  }
}