Stb Image.hApplication · Nothings

CVE-2023-45662

HIGH · 8.1 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 →
88/100
Remediation priority · High
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. When `stbi_set_flip_vertically_on_load` is set to `TRUE` and `req_comp` is set to a number that doesn’t match the real number of components per pixel, the library attempts to flip the image vertically. A crafted image file can trigger `memcpy` out-of-bounds read because `bytes_per_pixel` used to calculate `bytes_per_row` doesn’t match the real image array dimensions.

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

When stb_image's vertical flip feature is enabled (stbi_set_flip_vertically_on_load=TRUE) and req_comp is set to a value that doesn't match the actual components per pixel in a crafted image, the library miscalculates bytes_per_row using an incorrect bytes_per_pixel value. This causes memcpy to read beyond the image buffer boundaries, resulting in out-of-bounds memory read (CWE-125).

MitigationAvoid using req_comp to request a component count that differs from the actual image format; validate that req_comp matches the target image's actual component count before loading, or ensure image sources are trusted and untrusted images are processed in sandboxed environments.

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
None
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/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. Check stb_image.h version
    Search for the version definition in stb_image.h (typically around line 10-20) - look for '#define STB_IMAGE_VERSION' or similar version macros. Compare against version 2.28.
    Affected if The installed version is stb_image.h version 2.28 exactly.
  2. Identify vertical flip configuration
    Search codebase for calls to 'stbi_set_flip_vertically_on_load(1)' or 'stbi_set_flip_vertically_on_load(TRUE)' to determine if vertical flipping is enabled.
    Affected if Vertical flip is enabled via stbi_set_flip_vertically_on_load set to TRUE.
  3. Find stbi_load calls with req_comp parameter
    Search for all calls to stbi_load, stbi_load_from_memory, stbi_load_from_file, and related functions. Identify any that pass a non-zero value for the req_comp (requested components) parameter.
    Affected if Any stbi_load* function calls use a non-zero req_comp value.
  4. Check req_comp against actual image format
    For each stbi_load* call with req_comp, trace what image formats (JPEG, PNG, BMP, etc.) are being loaded and verify whether the req_comp value matches the actual component count for that format (e.g., 1 for grayscale, 3 for RGB, 4 for RGBA).
    Affected if req_comp value does not match the actual components per pixel in the loaded image format, and vertical flip is also enabled.

Environment is affected only if using stb_image.h v2.28 with vertical flip enabled AND loading images using a req_comp value that mismatches the actual image format's component count.

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

Avoid using req_comp to request a component count that differs from the actual image format; validate that req_comp matches the target image's actual component count before loading, or ensure image sources are trusted and untrusted images are processed in sandboxed environments.

Recommended fix Moderate confidence

stb_image.h version 2.29 or later

  1. 1. Locate the stb_image.h header file in your project
  2. 2. Check the current version by looking at the version comment at the top of the file (likely shows version 2.28)
  3. 3. Obtain the latest version of stb_image.h from the official repository at https://github.com/nothings/stb
  4. 4. Replace the existing stb_image.h file with the newer version
  5. 5. Rebuild and test your application to ensure the image loading functionality still works correctly
Caveat Minimal risk - stb_image is a single-header library and updates are typically backward compatible; verify any custom req_comp usage matches actual image component counts

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
  • Implementation4.0 h
  • Testing3.0 h
  • Review / QA2.0 h
11.0 hours of engineering $1,930
Get help mitigating

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $3,088.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2023-45662 — 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-45662 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