CVE-2023-45662
High · 8.1CVSS
8.1
EPSS
0.8%
Published
Oct 21, 2023
CISA due date
—
Cloudanix analysis
A bug in an image processing library can let a specially made picture file read or crash parts of a program's memory when the program tries to flip the image upside down.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Low
- Impact
- Data Exposure
- Component
- Library
- Class
- Memory Corruption
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Out-of-bounds read during vertical image flip when stbi_set_flip_vertically_on_load is enabled and req_comp mismatches actual pixel components, causing memcpy to use incorrect bytes_per_pixel for bytes_per_row calculation.
Why it matters to the business
Applications that load untrusted images with the library risk crashes or leakage of adjacent memory contents, potentially exposing sensitive data processed by image-handling code.
How an attack unfolds
An attacker crafts an image file with mismatched component counts, delivers it to a vulnerable application that calls stbi_set_flip_vertically_on_load(TRUE) before loading, and triggers the out-of-bounds memcpy read during vertical flip processing.
How to fix it
Update to a patched version of stb_image.h that corrects the bytes_per_pixel calculation in the flip logic; if no update is available, avoid enabling stbi_set_flip_vertically_on_load or validate component counts before loading.
How to confirm the fix worked
Recompile with the updated library, retest image loading under the flip and req_comp conditions using both valid and malformed inputs, and confirm absence of out-of-bounds access via memory sanitizer or bounds checking.
Typical attack path
- Identify target application using stb_image that enables vertical flip on load
- Craft malicious image with component count mismatch
- Deliver image via upload, download, or file system access
- Trigger image load path that sets flip flag and mismatched req_comp
- Observe crash or memory disclosure from out-of-bounds read
How to detect it
Review application logs for abnormal termination or memory errors during image loading with flip enabled; inspect source for calls to stbi_set_flip_vertically_on_load combined with req_comp parameters; scan for use of stb_image in image ingestion paths.
What your security team should do
- Inventory all products and dependencies using stb_image.h
- Prioritize patching or disabling the flip feature in internet-facing image processors
- Add runtime validation of image component counts before enabling vertical flip
- Monitor upstream stb_image releases for the corrective patch
The record
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.
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-45666 stb_image is a single file MIT licensed library for processing images. Also affects libstb