CVE-2026-47748: Out-of-Bounds Read in stable-diffusion.cpp Checkpoint Parser
A flaw in stable-diffusion.cpp allows attackers to crash applications or potentially read sensitive memory by providing a malformed or intentionally truncated model checkpoint (.ckpt) file. The vulnerability exists in how the library parses PyTorch checkpoint files—it fails to validate that sufficient data remains before reading, so a crafted file can cause the parser to read past the end of its buffer. An attacker would need to trick a user or application into loading a malicious .ckpt file, typically from an untrusted model repository. The practical risk is limited to environments that load external model files, but the impact on those systems can be significant.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 5.5 MEDIUM · CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
- Weaknesses (CWE)
- CWE-125
- 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. Versions prior to master-584-0a7ae07 are vulnerable to an out-of-bounds reads error through PyTorch checkpoint pickle opcode parsing. The pickle .ckpt parser in src/model.cpp did not consistently check that enough input remained before reading opcode arguments or advancing the parser buffer with a crafted or truncated .ckpt file. Throughout the pickle parser, opcode handlers advanced the parser position with expressions such as buffer += N without first checking that buffer + N <= buffer_end. A truncated file could therefore cause reads past the end of the metadata buffer. LibFuzzer found crashes in under one second using malformed checkpoint inputs. Any application using affected stable-diffusion.cpp releases to load untrusted .ckpt model files could be vulnerable. 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. This issue has been fixed in version master-584-0a7ae07. If developers are unable to immediately update their applications, they can work around this issue by ensuring they do not load .ckpt checkpoint files from untrusted sources. They should prefer trusted model sources and safer formats such as .safetensors where possible.
3 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The pickle parser in src/model.cpp of stable-diffusion.cpp performs buffer arithmetic without bounds checking. Specifically, opcode handlers advance the parser position using expressions like buffer += N without first validating that buffer + N remains within buffer_end. When a truncated or malformed .ckpt file is parsed, this leads to out-of-bounds reads (CWE-125). LibFuzzer discovered crashes in under one second using malformed inputs, demonstrating the ease of triggering the condition. The library supports inference for Stable Diffusion, Flux, Wan, Qwen Image, Z-Image, and other diffusion models. Versions prior to master-584-0a7ae07 are affected.
Business impact
Applications embedding stable-diffusion.cpp for local model inference face a denial-of-service risk if they accept model files from external sources—such as public model-sharing platforms (Hugging Face, Civitai, etc.) or user uploads. A crash could interrupt AI pipelines, disrupt services, or in multi-tenant environments, cause collateral impact to other workloads. Information disclosure risk is lower but non-zero; memory reads could theoretically leak sensitive data if the application or system holds secrets in memory. Organizations running stable-diffusion.cpp in production should prioritize assessment of their model-loading workflow and trust boundaries.
Affected systems
Any application or service using stable-diffusion.cpp versions prior to master-584-0a7ae07 is potentially affected, provided it loads .ckpt checkpoint files. This primarily impacts: (1) AI/ML applications performing local diffusion model inference; (2) image generation services or plugins that accept user-provided or downloaded models; (3) development and research environments using stable-diffusion.cpp for prototyping. Systems that load only internally vetted, pre-distributed model files face significantly lower risk. The vulnerability does not affect applications using .safetensors or other non-pickle-based model formats.
Exploitability
Exploitation requires user interaction or social engineering. An attacker must convince a user or automated system to load a malicious .ckpt file, typically by hosting it on a model repository or social-engineering a direct file transfer. The attack surface is broad if the application accepts model uploads or downloads from public sources; it is narrow if models are curated internally. Once a malicious file is loaded, the crash is nearly guaranteed and immediate (fuzzing confirmed sub-second discovery). Remote code execution is not indicated by this vulnerability; the impact is limited to denial of service and potential information disclosure through memory reads.
Remediation
Update stable-diffusion.cpp to version master-584-0a7ae07 or later. For organizations unable to update immediately, implement compensating controls: restrict .ckpt file loading to trusted, internally vetted sources; prefer .safetensors format where available; run inference in sandboxed or isolated processes to limit blast radius of a crash; validate file integrity and provenance before loading. End users should avoid downloading models from untrusted sources and report suspicious files to model repository maintainers.
Patch guidance
Consult the leejet stable-diffusion.cpp repository for commit master-584-0a7ae07 and merge into your dependency. Verify that your build system correctly incorporates the updated src/model.cpp with bounds-checking logic in all pickle opcode handlers. Test with your application's existing model file collection to ensure compatibility. If using stable-diffusion.cpp as a library in another project, update the library version and rebuild dependent code.
Detection guidance
Monitor for crashes or segmentation faults in applications using stable-diffusion.cpp, particularly when loading .ckpt files from external or user-controlled sources. Log all model file load attempts and validate file headers and metadata before parsing. Implement fuzz testing in your CI/CD pipeline for any model-loading code path. Use memory sanitizers (ASAN, MSAN) during development and testing to surface out-of-bounds access earlier. In production, enable core dumps or crash reporting to investigate failures post-incident.
Why prioritize this
This is a medium-severity vulnerability (CVSS 5.5) because it requires user interaction and affects the availability of the application rather than enabling remote code execution or widespread data exfiltration. However, it should not be dismissed: any service accepting external model files faces genuine risk. Prioritize patching if your application downloads or allows uploads of .ckpt files. For isolated research or development environments using only curated models, risk is lower but mitigation is still recommended.
Risk score, explained
CVSS 3.1 score of 5.5 (Medium) reflects: (1) low attack vector (local file load, user interaction required); (2) low complexity (malformed file triggers crash consistently); (3) no privilege escalation needed; (4) no confidentiality or integrity impact in the typical case; (5) high availability impact (denial of service via crash). The score does not account for downstream business context—organizations relying on continuous model inference may assign higher internal risk.
Frequently asked questions
Can this vulnerability lead to remote code execution?
No. This is an out-of-bounds read flaw that causes crashes and potential information disclosure through unintended memory access. Remote code execution is not indicated. The attack surface is limited to local file parsing.
Do I need to patch if I only use pre-bundled, official models?
Your risk is significantly lower if models are internally managed and not downloaded from external sources. However, patching is still recommended as a precaution, since model files can be inadvertently substituted or intercepted. At minimum, implement file integrity checks (hashes or signatures) on all model files.
What formats are safe to use instead of .ckpt?
The advisory specifically recommends .safetensors, which uses a safer, non-pickle-based serialization format. This eliminates the pickle parsing vulnerability entirely. When possible, convert or request models in .safetensors format from repository maintainers.
How can I tell if my application is vulnerable?
Check the version of stable-diffusion.cpp you are using. If it is earlier than master-584-0a7ae07 and your code loads .ckpt files from any source other than hardcoded, immutable local bundles, you are at risk. Audit your model-loading code paths to determine your threat exposure.
This analysis is provided for informational purposes and does not constitute legal or professional security advice. CVSS scores, vulnerability details, and patch information are derived from the CVE record and vendor advisories. Organizations must validate all information against their environment and official vendor guidance before taking remediation actions. No exploit code or weaponized proof-of-concept is provided. Always consult the leejet stable-diffusion.cpp repository and your vendor's official security advisories for authoritative patch and mitigation information. Source: NVD (public-domain), retrieved 2026-07-24. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2025-70101MEDIUMlwext4 1.0.0 Out-of-Bounds Read Denial of Service
- CVE-2026-0127MEDIUMAndroid Out-of-Bounds Read in Communication Processor – Impact & Patch Guidance
- CVE-2026-0128MEDIUMAndroid RTCP Out-of-Bounds Read Information Disclosure
- CVE-2026-0136MEDIUMAndroid Modem Out-of-Bounds Read Denial of Service
- CVE-2026-0140MEDIUMAndroid RTP Integer Overflow Information Disclosure Vulnerability
- CVE-2026-0141MEDIUMAndroid RTCP Out-of-Bounds Read Information Disclosure
- CVE-2026-0155MEDIUMAndroid ImsMediaBitReader OOB Read Information Disclosure
- CVE-2026-0157MEDIUMAndroid RTCP Header Buffer Overflow – Remote Information Disclosure