Executive brief
stable-diffusion.cpp is a library used to run AI image generation models. A security flaw in how it processes certain model files (.ckpt) allows a malicious file to crash the application or potentially take control of the system. This risk occurs when a user downloads and opens a compromised AI model from an untrusted source.
Technical details
A heap buffer overflow exists in the pickle .ckpt parser within src/model.cpp, specifically in the GLOBAL opcode handler. The vulnerability is caused by missing validation when searching for newline-delimited fields using find_char(). If a crafted .ckpt file lacks the expected newline, find_char() returns -1, which is then passed to memcpy() as a length argument. Because memcpy() expects a size_t, the -1 is interpreted as a very large unsigned integer (SIZE_MAX), leading to immediate heap corruption. Exploitation requires a user to load a malicious model file. The issue was addressed in version master-584-0a7ae07 by implementing restricted checkpoint loading.
Affected products
- leejet stable-diffusion.cpp prior to master-584-0a7ae07
Timeline
- 2026-04-19: patched: Fix committed to master branch
- 2026-05-22: advisory: GitHub Security Advisory published
- 2026-06-16: disclosed: CVE published to NVD