---
id: "CVE-2026-70659"
kind: "vulnerability"
aliases: ["CVE-2026-70659"]
title: "stable-diffusion.cpp: crafted imatrix file corrupts heap during model conversion"
severity: "high"
cvss: 7.8
epss: null
exploited: false
status: "open"
category: "ai-tooling"
products: []
ecosystems: []
tags: ["ai-tooling", "diffusion-models", "ggml", "stable-diffusion.cpp"]
not_affected_if: ["no-imat-in-usage", "trusted-imatrix-files-only"]
published_at: "2026-11-05T16:17:48+00:00"
first_seen_at: "2026-11-05T16:40:03+00:00"
updated_at: "2026-11-05T16:41:28+00:00"
sources: [{"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-70659", "first_seen_at": "2026-11-05T16:40:03+00:00"}]
exploit_sources: []
---

# stable-diffusion.cpp: crafted imatrix file corrupts heap during model conversion

stable-diffusion.cpp is a C/C++ library for running image diffusion models such as Stable Diffusion and Flux. A crafted .imatrix file loaded through the --imat-in conversion path can make the loader write past heap buffers, corrupting memory or crashing the process.

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

## How to check

- Check whether the build includes a version from `master-742-1a13107` up to but not including `master-763-4fcc6fe`
- Check whether the conversion tool is run with `--imat-in` on any .imatrix file that is not trusted

## Fix

- Move to `master-763-4fcc6fe` or later

## Timeline

- 2026-11-05T16:40:03+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-70659

## Documents

- [advisory] Vendor advisory: github.com https://github.com/leejet/stable-diffusion.cpp/security/advisories/GHSA-6q7q-2v9c-x8m7
- [fix] Patch: github.com https://github.com/leejet/stable-diffusion.cpp/commit/4fcc6fef10c6f686801c6e257b22cd6a3deb906b
- [fix] Release notes: github.com https://github.com/leejet/stable-diffusion.cpp/releases/tag/master-763-4fcc6fe

## From the sources

stable-diffusion.cpp is a pure C/C++ library for running diffusion model (Stable Diffusion, Flux, Wan, Qwen Image, Z-Image, and more) inference. From master-742-1a13107 until master-763-4fcc6fe, IMatrixCollector::load_imatrix in src/runtime/imatrix.cpp reuses the values and counts vectors for entries with the same tensor name but resizes them only when they are empty. An untrusted .imatrix file can provide a small nval for the first entry and a larger nval for a second entry with the same name, causing the accumulation loop to write attacker-controlled floating-point and integer values beyond both heap buffers. Loading the file through the --imat-in conversion path can corrupt the heap or crash the process before a model is required. This issue is fixed in master-763-4fcc6fe.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
