HIGH 7.8

CVE-2026-47750: Heap Buffer Overflow in stable-diffusion.cpp .ckpt Parser

stable-diffusion.cpp, a C/C++ library for running AI image generation models locally, contains a critical flaw in how it parses checkpoint (.ckpt) files. When processing a specially crafted malicious .ckpt file, the parser can fail to validate the expected structure, causing it to write beyond allocated memory boundaries. An attacker could exploit this by distributing a poisoned model file through public model-sharing platforms, tricking users or applications into loading it. Once loaded, the memory corruption could lead to a complete system compromise—data theft, unauthorized changes, or denial of service. The vulnerability requires user interaction (loading the file) but no special privileges to trigger.

Source data · NVD / CISA · public domain

CVSS
3.1 · 7.8 HIGH · CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Weaknesses (CWE)
CWE-787
Affected products
1 configuration(s)
Published / Modified
2026-06-16 / 2026-06-25

NVD description (verbatim)

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 GLOBAL opcode handler. The issue was caused by missing validation when searching for newline-delimited fields. A crafted .ckpt file without the expected newline could cause the parser to use -1 as a copy length, resulting in immediate heap corruption. The attack requires the victim or application to load a .ckpt file from an untrusted source, such as a downloaded model from a model sharing site. 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 following these instructions: do not load .ckpt checkpoint files from untrusted sources, and prefer trusted model sources and safer formats such as .safetensors where possible.

4 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The vulnerability exists in the GLOBAL opcode handler within the pickle .ckpt parser located in src/model.cpp. The root cause is insufficient validation of newline-delimited fields during parsing. When a .ckpt file lacks the expected newline delimiter, the search logic returns -1, which is then passed as a copy length to a memory operation, causing heap buffer overflow. This type of memory corruption can be leveraged to read or write arbitrary data on the affected system. The flaw was patched in commit master-584-0a7ae07, which presumably adds proper bounds checking and validation logic to handle malformed input gracefully.

Business impact

Organizations and individuals using stable-diffusion.cpp for local model inference face significant operational risk. Compromised machine learning pipelines could leak proprietary training data or inference results, corrupt generated outputs, or disable services entirely. Supply chain risk is notable: model-sharing communities (Hugging Face, GitHub, etc.) are common attack distribution vectors. If your application automatically fetches or accepts user-uploaded models without sandboxing, the blast radius extends to end users. For enterprises embedding this library into products, patch delays translate to customer vulnerability windows and potential breach notifications.

Affected systems

All versions of stable-diffusion.cpp prior to master-584-0a7ae07 are vulnerable. The library itself is open-source and lightweight, so exposure depends on downstream adoption: command-line tools, web applications, desktop software, and embedded systems using this library are all at risk. The attack surface is specifically when loading .ckpt format checkpoints; other formats like .safetensors are not affected by this particular vulnerability. Verify your application's pinned version against the fixed commit hash provided by the maintainer.

Exploitability

Exploitation requires two conditions: (1) the vulnerable code must be active and used to parse .ckpt files, and (2) a user or automated system must be convinced to load a malicious .ckpt file. This is a realistic attack in open-source AI communities where models are freely shared. No network component is needed; the attack is entirely local to the parsing process. Exploit complexity is relatively low for a skilled attacker who understands pickle format semantics. The CVSS score of 7.8 (HIGH) reflects the memory corruption severity and local-execution barrier; it is not currently tracked as actively exploited in the wild.

Remediation

Immediate action: upgrade stable-diffusion.cpp to version master-584-0a7ae07 or later. If immediate patching is infeasible, implement application-level mitigations: (1) restrict .ckpt file loading to trusted, cryptographically verified sources only; (2) migrate to the safer .safetensors format, which does not have this parser vulnerability; (3) run model loading in a sandboxed environment (container, VM, or isolated user account) to limit blast radius; (4) disable automatic model downloads or implement human review workflows.

Patch guidance

Consult the stable-diffusion.cpp project repository (github.com/leejet/stable-diffusion.cpp) for the specific commit master-584-0a7ae07 and release notes. Apply the patch by updating your dependency to the fixed version or building from the patched commit. Developers should audit any local modifications to src/model.cpp that may conflict with the patch. After patching, validate that your application continues to parse .ckpt files correctly by testing against known good models. Consider adopting .safetensors as the default checkpoint format going forward.

Detection guidance

Monitor for unusual crashes or memory access violations when loading .ckpt files, particularly if error logs show segmentation faults or heap corruption messages. If you cannot immediately patch, implement a validation step before parsing: scan incoming .ckpt files for proper pickle opcode formatting and presence of expected delimiters. In production, enable address sanitizer (ASAN) or similar memory safety tooling during testing to catch heap overflow attempts. Log all .ckpt file sources and sha256 hashes; compare against known-good model checksums to detect tampering.

Why prioritize this

This vulnerability warrants HIGH priority for any team using stable-diffusion.cpp in production or accepting external model files. The combination of high CVSS (7.8), reliable exploitability via file distribution, and severe consequence (memory corruption leading to RCE or data exfiltration) creates substantial risk. Organizations in regulated industries or handling sensitive training data should prioritize patching within one business day. The current lack of known public exploits is not a reason for delay; the exploit is trivial for motivated attackers familiar with pickle format internals.

Risk score, explained

CVSS 7.8 (HIGH) is justified by: Attack Vector Local (AV:L) — the file must be parsed locally, but no prior system compromise is needed; Attack Complexity Low (AC:L) — any .ckpt file missing a newline can trigger it; Privileges Required None (PR:N); User Interaction Required (UI:R) — user must load the file, but malware or deceptive UX can facilitate this; Scope Unchanged (S:U); Confidentiality High (C:H), Integrity High (I:H), Availability High (A:H) — heap overflow can read, modify, or crash the process. The score does not account for active exploitation or KEV listing, which remain absent as of the publication date.

Frequently asked questions

Can this vulnerability be exploited remotely without user interaction?

No. The vulnerability requires local execution of the parser and user or application-level interaction to load a malicious .ckpt file. However, a remote attacker can distribute the poisoned file via public model repositories, and many users may download and load it without inspection, making it a practical attack vector in practice.

Are other checkpoint formats like .pt or .safetensors affected?

No. This specific vulnerability is in the pickle .ckpt parser. The .safetensors format uses a different, safer serialization method and is not vulnerable to this buffer overflow. Migrating to .safetensors is a recommended long-term mitigation.

If I only load models from Hugging Face official accounts, am I safe?

Significantly safer, but not guaranteed. While Hugging Face scans uploads, a compromised official account or a subtle attack targeting a niche model could still distribute a malicious .ckpt file. The safest approach is to patch immediately and use .safetensors format whenever possible.

What should I do if I've already loaded untrusted .ckpt files with the vulnerable version?

Assume potential system compromise. Isolate the affected machine from the network, review logs for unauthorized access or data exfiltration, rebuild or restore from clean backups, and patch before resuming normal operation. If the system processes sensitive data, engage your incident response team.

This analysis is based on publicly available CVE data and official vendor advisories as of June 2026. CVSS scores and vulnerability details are provided for informational purposes and should be validated against your specific environment and threat model. No liability is assumed for decisions made based on this intelligence. Always verify patch availability and compatibility with your systems before deployment. This report does not constitute a formal security audit or risk assessment for your organization. Source: NVD (public-domain), retrieved 2026-07-24. Analysis generated by SEC.co (claude-haiku-4-5).