CVE-2026-47747: CWE-122: Heap-based Buffer Overflow in leejet stable-diffusion.cpp
stable-diffusion.cpp is a pure C/C++ library for running diffusion model (Stable Diffusion, Flux, Wan, Qwen Image, Z-Image, and more) inference. In versions prior to master-584-0a7ae07, the pickle .ckpt parser in src/model.cpp contained a heap buffer overflow vulnerability in the BINUNICODE opcode handler. The issue was caused by sign confusion on the opcode length field. A crafted .ckpt file could trigger memcpy with a very large length derived from a negative signed value, causing immediate heap corruption. The issue has been resolved in version master-584-0a7ae07. If developers are unable to immediately update their applications they can work around this issue by only loading .ckpt checkpoint files from trusted sources and preferring trusted model sources and safer formats such as .safetensors where possible.
AI Analysis
Technical Summary
The stable-diffusion.cpp library, used for diffusion model inference, contained a heap buffer overflow in its pickle .ckpt file parser within src/model.cpp. Specifically, the BINUNICODE opcode handler misinterpreted the opcode length field due to sign confusion, leading to a potentially very large length passed to memcpy. This could cause immediate heap corruption when processing a maliciously crafted .ckpt file. The vulnerability is identified as CWE-122 (Heap-based Buffer Overflow) and CWE-787 (Out-of-bounds Write). The issue was resolved in commit master-584-0a7ae07. No official patch or remediation level is explicitly stated beyond this commit. Users are advised to restrict .ckpt file sources and use safer formats if immediate patching is not feasible.
Potential Impact
Successful exploitation of this vulnerability could lead to heap corruption, resulting in potential arbitrary code execution, denial of service, or other impacts affecting confidentiality, integrity, and availability. The CVSS 3.1 score of 7.8 reflects high severity with local attack vector, low attack complexity, no privileges required, user interaction required, and high impact on confidentiality, integrity, and availability.
Mitigation Recommendations
A fix is available in stable-diffusion.cpp at commit master-584-0a7ae07. Users and developers should update to this version to remediate the vulnerability. If immediate updating is not possible, only load .ckpt checkpoint files from trusted sources and prefer safer model formats such as .safetensors to reduce risk.
CVE-2026-47747: CWE-122: Heap-based Buffer Overflow in leejet stable-diffusion.cpp
Description
stable-diffusion.cpp is a pure C/C++ library for running diffusion model (Stable Diffusion, Flux, Wan, Qwen Image, Z-Image, and more) inference. In versions prior to master-584-0a7ae07, the pickle .ckpt parser in src/model.cpp contained a heap buffer overflow vulnerability in the BINUNICODE opcode handler. The issue was caused by sign confusion on the opcode length field. A crafted .ckpt file could trigger memcpy with a very large length derived from a negative signed value, causing immediate heap corruption. The issue has been resolved in version master-584-0a7ae07. If developers are unable to immediately update their applications they can work around this issue by only loading .ckpt checkpoint files from trusted sources and preferring trusted model sources and safer formats such as .safetensors where possible.
CVSS v3.1
Score 7.8high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The stable-diffusion.cpp library, used for diffusion model inference, contained a heap buffer overflow in its pickle .ckpt file parser within src/model.cpp. Specifically, the BINUNICODE opcode handler misinterpreted the opcode length field due to sign confusion, leading to a potentially very large length passed to memcpy. This could cause immediate heap corruption when processing a maliciously crafted .ckpt file. The vulnerability is identified as CWE-122 (Heap-based Buffer Overflow) and CWE-787 (Out-of-bounds Write). The issue was resolved in commit master-584-0a7ae07. No official patch or remediation level is explicitly stated beyond this commit. Users are advised to restrict .ckpt file sources and use safer formats if immediate patching is not feasible.
Potential Impact
Successful exploitation of this vulnerability could lead to heap corruption, resulting in potential arbitrary code execution, denial of service, or other impacts affecting confidentiality, integrity, and availability. The CVSS 3.1 score of 7.8 reflects high severity with local attack vector, low attack complexity, no privileges required, user interaction required, and high impact on confidentiality, integrity, and availability.
Mitigation Recommendations
A fix is available in stable-diffusion.cpp at commit master-584-0a7ae07. Users and developers should update to this version to remediate the vulnerability. If immediate updating is not possible, only load .ckpt checkpoint files from trusted sources and prefer safer model formats such as .safetensors to reduce risk.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-05-19T22:16:39.504Z
- Cvss Version
- 3.1
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a31a4690b89be68881528e0
Added to database: 06/16/2026, 19:30:49 UTC
Last enriched: 06/24/2026, 16:12:46 UTC
Last updated: 07/31/2026, 19:22:59 UTC
Views: 281
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.