CVE-2023-45664
Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.
NVD · uneditedstb_image is a single file MIT licensed library for processing images. A crafted image file can trigger `stbi__load_gif_main_outofmem` attempt to double-free the out variable. This happens in `stbi__load_gif_main` because when the `layers * stride` value is zero the behavior is implementation defined, but common that realloc frees the old memory and returns null pointer. Since it attempts to double-free the memory a few lines below the first “free”, the issue can be potentially exploited only in a multi-threaded environment. In the worst case this may lead to code execution.
Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.
dbcve analysis · high confidenceA double-free vulnerability exists in stb_image's GIF loading code (stbi__load_gif_main). When processing a crafted GIF with layers*stride equal to zero, realloc() exhibits implementation-defined behavior—commonly freeing memory and returning NULL. The subsequent code attempts to free the same pointer again, causing the double-free. This is only exploitable in multi-threaded contexts due to the race condition required.
Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.
Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.
NVD · CPE data= 2.28CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.
From the vector- Attack vector
- Network
- Complexity
- Low
- Privileges
- None
- User interaction
- Required
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.
dbcve checksWork through these to decide whether this CVE applies to you.
-
Locate stb_image.h in your codebaseSearch for the file stb_image.h or stb_image.c and note its path. Open the file and search for a version string near the top (often in a comment like 'stb_image v2.28')Affected if The file exists and declares version 2.28 specifically
-
Identify GIF loading usageSearch your codebase for calls to stb_image GIF loading functions such as stbi_load_gif_from_memory, stbi_loadgif, or stbi__load_gif_main. Also check if STB_IMAGE_GIF is defined or if GIF support was enabled at compile timeAffected if Your code calls any GIF loading functions from stb_image
-
Verify multi-threaded contextExamine your application to determine if it processes GIF files in a multi-threaded environment. Look for thread creation (pthread_create, std::thread, CreateThread) handling GIF loading, or concurrent GIF decoding routinesAffected if GIF files are loaded or processed in more than one thread simultaneously
-
Confirm zero-sized allocation scenario is possibleReview the GIF loading code path in stbi__load_gif_main in your copy of stb_image.h. Check if your application could ever pass a GIF with dimensions or layer configuration that results in layers*stride equaling zeroAffected if Your GIF processing could produce zero-sized memory allocations (layers*stride == 0)
You are affected if you use stb_image.h version 2.28, load GIF files, process them in multiple threads, and can encounter GIFs that cause zero-sized allocations in the GIF loading routine.
Generated from the published advisory. Verify against your own configuration.
Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.
dbcve · scopedUpdate stb_image to a version containing the fix for CVE-2023-45664, or add a explicit check for zero-sized allocations before the realloc call in stbi__load_gif_main to prevent the implementation-defined behavior.
Latest stb_image.h release (2.29 or later) from github.com/nothings/stb
- 1. Obtain the latest version of stb_image.h from the official repository (github.com/nothings/stb)
- 2. Replace the existing stb_image.h version 2.28 file in your project with the updated version
- 3. Rebuild and test your application to ensure the library functions correctly
- 4. Verify that the double-free vulnerability in stbi__load_gif_main is resolved
Generated from the published advisory — verify against the referenced sources before acting.
- Consultation2.0 h
- Implementation2.0 h
- Testing6.0 h
- Review / QA2.0 h
An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $3,232.
Scan for this in your stack
Free · runs locallyCheck whether your project pulls in CVE-2023-45664 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.
References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.
Primary sourcesPractitioner notes
ContributedPeer-ranked notes from engineers who’ve handled CVE-2023-45664 in production — separate from our analysis above.
The advisory tells you what broke. It rarely tells you what actually worked. If you’ve dealt with this one, that detail is what the next engineer is searching for.
- The version that genuinely resolved it — not the one the vendor claimed
- A config change or rule that shut the vector down
- A gotcha in the upgrade path that cost you an afternoon
No notes yet
Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.
A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.
- Verified mitigations, workarounds, and config changes
- Version or environment caveats, and links to real fixes
- No weaponised exploit code, or anything meant to cause harm
- No spam, self-promotion, credentials, or personal data