CVE-2023-45662
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. 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 confidenceWhen 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).
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
- 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 checksWork through these to decide whether this CVE applies to you.
-
Check stb_image.h versionSearch 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.
-
Identify vertical flip configurationSearch 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.
-
Find stbi_load calls with req_comp parameterSearch 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.
-
Check req_comp against actual image formatFor 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.
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 · scopedAvoid 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.
stb_image.h version 2.29 or later
- 1. Locate the stb_image.h header file in your project
- 2. Check the current version by looking at the version comment at the top of the file (likely shows version 2.28)
- 3. Obtain the latest version of stb_image.h from the official repository at https://github.com/nothings/stb
- 4. Replace the existing stb_image.h file with the newer version
- 5. Rebuild and test your application to ensure the image loading functionality still works correctly
Generated from the published advisory — verify against the referenced sources before acting.
- Consultation2.0 h
- Implementation4.0 h
- Testing3.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,088.
Scan for this in your stack
Free · runs locallyCheck 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 sourcesPractitioner notes
ContributedPeer-ranked notes from engineers who’ve handled CVE-2023-45662 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