# CVE-2026-70659: stable-diffusion.cpp heap out-of-bounds write in imatrix loading

Source: https://junglewise.ai/threats/cve-2026-70659-stable-diffusion-cpp-is-a-pure-c-c-library-for-running-diffusion  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-11-05. Updated: 2026-11-05  
License: CC BY 4.0 with a link back

CVE-2026-70659 · Severity: high · CVSS 7.8 · Published 2026-11-05

stable-diffusion.cpp is a library that runs AI image generation models on local systems. An attacker can craft a malicious imatrix file that causes the library to write beyond allocated memory when loading it, corrupting the heap or crashing the application. This allows code execution or denial of service through a single untrusted file.

Technologies: [Leejet Stable-Diffusion.Cpp](https://junglewise.ai/threats/technologies/stable-diffusion-cpp). Vendors: [Leejet](https://junglewise.ai/threats/vendors/leejet).

## Quick answers

**Is CVE-2026-70659 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-70659 being exploited in the wild.

**How severe is CVE-2026-70659?** High severity, with a CVSS score of 7.8, published 5 November 2026.

**Which products and versions are affected?** Leejet Stable-Diffusion.Cpp master-742-1a13107 until master-763-4fcc6fe.

**Is there a fix for CVE-2026-70659?** Yes: fixed in master-763-4fcc6fe. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-70659 attacked?** It is attacked with local access, in a software library.

**Am I affected by CVE-2026-70659?** Check whether you run Leejet Stable-Diffusion.Cpp at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- Fixed in master-763-4fcc6fe

## Technical details

A heap out-of-bounds write occurs in IMatrixCollector::load_imatrix (src/runtime/imatrix.cpp) when processing a .imatrix file with duplicate tensor entries that have mismatched value counts. The vulnerable code resizes vectors only on the first occurrence of a name, then writes beyond the allocated buffer when a second entry with the same name but larger nval is encountered. Local file input via the --imat-in conversion path is the attack vector; no authentication or network access is required.

## Affected products

- leejet stable-diffusion.cpp master-742-1a13107 until master-763-4fcc6fe

## Timeline

- 2026-11-05: disclosed
- 2026-07-06: patched

## References

- [https://github.com/leejet/stable-diffusion.cpp/commit/4fcc6fef10c6f686801c6e257b22cd6a3deb906b](https://github.com/leejet/stable-diffusion.cpp/commit/4fcc6fef10c6f686801c6e257b22cd6a3deb906b)
- [https://github.com/leejet/stable-diffusion.cpp/pull/1750](https://github.com/leejet/stable-diffusion.cpp/pull/1750)

## Related threats

- [stable-diffusion.cpp safetensors buffer overflow [data offset validation]](https://junglewise.ai/threats/cve-2026-70660-stable-diffusion-cpp-is-a-pure-c-c-library-for-running-diffusion)
- [leejet stable-diffusion.cpp heap buffer overflow in .ckpt parser](https://junglewise.ai/threats/cve-2026-47750-leejet-stable-diffusion-cpp-heap-buffer-overflow-in-ckpt-parser)
- [leejet stable-diffusion.cpp heap buffer overflow in .ckpt parser](https://junglewise.ai/threats/cve-2026-47747-leejet-stable-diffusion-cpp-heap-buffer-overflow-in-ckpt-parser)
- [leejet stable-diffusion.cpp heap buffer overflow in .ckpt parser](https://junglewise.ai/threats/cve-2026-47749-leejet-stable-diffusion-cpp-heap-buffer-overflow-in-ckpt-parser)
- [leejet stable-diffusion.cpp out-of-bounds read in pickle parser](https://junglewise.ai/threats/cve-2026-47748-leejet-stable-diffusion-cpp-out-of-bounds-read-in-pickle-parser)
