CVE-2023-45666
Critical · 9.8CVSS
9.8
EPSS
1.1%
Published
Oct 21, 2023
CISA due date
—
Cloudanix analysis
A flaw in a popular image-handling component can let attackers crash programs or potentially seize control when users open certain GIF files.
- Exploitation
- Remote Unauthenticated
- Attacker needs
- None
- Complexity
- Low
- Impact
- Full Compromise
- Component
- Library
- Class
- Memory Corruption
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Improper handling of the delays pointer in stbi__load_gif_main allows a memory leak when stbi__convert_format fails after allocation, or a double-free when the caller unconditionally frees the pointer on a null return value, resulting in heap corruption.
Why it matters to the business
Applications that process untrusted images can crash, leak memory under sustained load, or be compromised for remote code execution, leading to service outages, data breaches, and regulatory exposure especially in image-heavy workflows.
How an attack unfolds
An attacker supplies a crafted GIF that passes initial recognition but triggers an internal allocation of the delays array followed by a failure in stbi__convert_format; depending on the caller's free logic this produces either a double-free primitive usable for heap shaping and arbitrary write or persistent memory exhaustion.
How to fix it
Update the stb_image.h single-file library to a version containing the corrected stbi__load_gif_main logic that always resets *delays on every failure path; recompile and redeploy all dependent binaries; where immediate patching is impossible, wrap calls with explicit delays=NULL after every failure and add heap-integrity checks.
How to confirm the fix worked
Rebuild with the fixed header, run the library's existing test suite plus additional GIFs that exercise the convert_format failure path, and verify that *delays is always zero or freed exactly once on every return path using address-sanitizer or valgrind.
Typical attack path
- Deliver malicious GIF via network upload, email attachment, or web page
- Victim application invokes stbi__load_gif_main on the file
- Library allocates delays buffer then fails in format conversion
- Caller either double-frees or leaks the pointer according to its error-handling pattern
- Double-free is leveraged for heap metadata corruption and eventual code execution
How to detect it
Monitor process crash logs for repeated heap-related faults during GIF decoding, inspect memory-leak reports from long-running services that call the library, and review application source for call sites that free a delays pointer after a null return from the GIF loader.
What your security team should do
- Inventory all products statically linking or shipping stb_image.h and prioritize update within 30 days given the 9.8 CVSS and public availability of the library
- Add image-processing sandboxes or seccomp filters around any use of the library until patched
- Enable compiler and runtime mitigations (ASLR, heap canaries, -fsanitize=address) in builds that consume the library
The record
stb_image is a single file MIT licensed library for processing images. It may look like `stbi__load_gif_main` doesn’t give guarantees about the content of output value `*delays` upon failure. Although it sets `*delays` to zero at the beginning, it doesn’t do it in case the image is not recognized as GIF and a call to `stbi__load_gif_main_outofmem` only frees possibly allocated memory in `*delays` without resetting it to zero. Thus it would be fair to say the caller of `stbi__load_gif_main` is responsible to free the allocated memory in `*delays` only if `stbi__load_gif_main` returns a non null value. However at the same time the function may return null value, but fail to free the memory in `*delays` if internally `stbi__convert_format` is called and fails. Thus the issue may lead to a memory leak if the caller chooses to free `delays` only when `stbi__load_gif_main` didn’t fail or to a double-free if the `delays` is always freed
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Debian:11 | libstb | 0 | No fix |
| Debian:12 | libstb | 0 | No fix |
| Debian:13 | libstb | 0 | No fix |
| Ubuntu:20.04:LTS | libstb | 0 | No fix |
| Ubuntu:22.04:LTS | libstb | 0 | No fix |
| Ubuntu:24.04:LTS | libstb | 0 | No fix |
| Ubuntu:24.10 | libstb | 0 | No fix |
| Ubuntu:25.04 | libstb | 0 | No fix |
| Ubuntu:25.10 | libstb | 0 | No fix |
| Ubuntu:Pro:20.04:LTS | libstb | 0 | No fix |
Related vulnerabilities
- CVE-2023-47212 A heap-based buffer overflow vulnerability exists in the comment functionality of stb… Also affects libstb
- CVE-2023-43281 Double Free vulnerability in Nothings Stb Image.h v.2.28 allows a remote attacker to… Also affects libstb
- CVE-2023-45664 stb_image is a single file MIT licensed library for processing images. Also affects libstb
- CVE-2023-45676 stb_vorbis is a single file MIT licensed library for processing ogg vorbis files. Also affects libstb
- CVE-2023-45682 stb_vorbis is a single file MIT licensed library for processing ogg vorbis files. Also affects libstb
- CVE-2023-45679 stb_vorbis is a single file MIT licensed library for processing ogg vorbis files. Also affects libstb
- CVE-2023-45675 stb_vorbis is a single file MIT licensed library for processing ogg vorbis files. Also affects libstb
- CVE-2023-45667 stb_image is a single file MIT licensed library for processing images. Also affects libstb