Stb Image.hApplication · Nothings

CVE-2023-45664

HIGH · 8.8 CVSS v3.1 Published 2023-10-21
Mitigation only
No fix yet — a mitigation exists. There is no fixed release. A documented workaround reduces exposure in the meantime.
See remediation →
95/100
Remediation priority · Urgent
Remotely reachable No privileges

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 · unedited
stb_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 confidence

A 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.

MitigationUpdate 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.

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
Stb Image.hApplication
Affected:= 2.28

CVSS 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 checks

Work through these to decide whether this CVE applies to you.

  1. Locate stb_image.h in your codebase
    Search 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
  2. Identify GIF loading usage
    Search 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 time
    Affected if Your code calls any GIF loading functions from stb_image
  3. Verify multi-threaded context
    Examine 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 routines
    Affected if GIF files are loaded or processed in more than one thread simultaneously
  4. Confirm zero-sized allocation scenario is possible
    Review 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 zero
    Affected 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.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

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 · scoped
Mitigation available No clean upgrade yet — mitigate in the meantime
Mitigation

Update 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.

Recommended fix Moderate confidence

Latest stb_image.h release (2.29 or later) from github.com/nothings/stb

  1. 1. Obtain the latest version of stb_image.h from the official repository (github.com/nothings/stb)
  2. 2. Replace the existing stb_image.h version 2.28 file in your project with the updated version
  3. 3. Rebuild and test your application to ensure the library functions correctly
  4. 4. Verify that the double-free vulnerability in stbi__load_gif_main is resolved
Caveat Minimal risk - stb_image is a single-header library with backward-compatible API; verify any custom image processing functionality after upgrade

Generated from the published advisory — verify against the referenced sources before acting.

Fix this in Stb Image.h Scoped from the published advisory
  • Consultation2.0 h
  • Implementation2.0 h
  • Testing6.0 h
  • Review / QA2.0 h
12.0 hours of engineering $2,020
Get help mitigating

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 locally
dbcve dependency scanner

Check 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 sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2023-45664 in production — separate from our analysis above.

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.

What this is

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.

What belongs here
  • 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