CVE-2024-28576
Executive Summary
CVE-2024-28576 is a buffer overflow vulnerability in the open-source FreeImage library, version 3.19.0 (r1909). The flaw resides in the opj_j2k_tcp_destroy() function, which is part of the JPEG 2000 (J2K) image decoding pipeline. A local attacker can exploit this vulnerability by crafting a malicious J2K image file, leading to a denial of service (DoS) condition. The vulnerability is currently unpatched, and no public exploit code or proof-of-concept is available. The EPSS score is 0.0%, indicating a low probability of exploitation in the wild at this time.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
CVSS Breakdown & Threat Level
The CVSS score is listed as 0.0, which is unusual and likely indicates that a full CVSS vector has not been assigned by NVD. Based on the description (local attacker, DoS), a reasonable estimate would be:
- Attack Vector (AV): Local (L)
- Attack Complexity (AC): Low (L)
- Privileges Required (PR): None (N)
- User Interaction (UI): Required (R) – victim must open the file
- Scope (S): Unchanged (U)
- Confidentiality (C): None (N)
- Integrity (I): None (N)
- Availability (A): High (H)
Estimated CVSS Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Threat Level: Medium (due to local attack vector and DoS impact only)
Deep Dive & Mechanics
The vulnerability is a classic heap-based buffer overflow in the JPEG 2000 decoder component of FreeImage. The opj_j2k_tcp_destroy() function is responsible for cleaning up tile-part data structures (tcp). When parsing a malformed J2K image, the function may attempt to free or access memory outside the bounds of an allocated buffer, leading to a crash.
The root cause is likely an integer overflow or missing bounds check when calculating the size of a tile-part data buffer. When the image header contains manipulated tile dimensions or component counts, the allocation size becomes smaller than expected, and subsequent writes overflow the buffer.
The attack surface is limited to local file processing. An attacker must convince a user to open a specially crafted J2K file using an application that relies on FreeImage (e.g., image viewers, editors, or conversion tools).
Vulnerable vs. Patched Code
Vulnerable Code (FreeImage 3.19.0 r1909):
The vulnerable function opj_j2k_tcp_destroy() in src/j2k/j2k.c likely contains a loop that frees tile-part data without proper bounds checking.
// Simplified vulnerable pattern
void opj_j2k_tcp_destroy(opj_tcp_t *tcp) {
for (int i = 0; i < tcp->numtiles; i++) {
// No check if tcp->tiles[i] is valid
free(tcp->tiles[i]->data);
}
}
Patched Code (Hypothetical): A fix would add bounds checking and validate the tile count before accessing the array.
// Patched version
void opj_j2k_tcp_destroy(opj_tcp_t *tcp) {
if (tcp->numtiles > MAX_TILES) {
// Handle error
return;
}
for (int i = 0; i < tcp->numtiles; i++) {
if (tcp->tiles[i] != NULL) {
free(tcp->tiles[i]->data);
}
}
}
Exploitation & Lab Setup
Red Team
Objective: Trigger a denial of service by crafting a malicious J2K file.
Lab Setup:
- Install FreeImage 3.19.0 (r1909) on a test system.
- Use a hex editor or a fuzzer (e.g., AFL++) to modify a valid J2K file.
- Manipulate the tile-part header fields (e.g.,
SIZmarker segment) to cause an integer overflow. - Open the crafted file with a FreeImage-based application (e.g.,
FreeImage_Load).
Example Crafting (Python):
import struct
def craft_malicious_j2k():
# Minimal J2K header with overflow trigger
# This is a simplified example; actual exploitation requires deep knowledge of J2K format
data = b'\x00\x00\x00\x0c' # J2K signature
data += b'\x51\x51\x51\x51' # SIZ marker (manipulated)
# ... additional crafted data
with open('exploit.j2k', 'wb') as f:
f.write(data)
craft_malicious_j2k()
Expected Outcome: The application crashes due to a segmentation fault or access violation.
Blue Team
Detection:
- Monitor for crashes in applications using FreeImage (e.g., event ID 1000 in Windows).
- Use file integrity monitoring to detect unusual J2K files.
- Implement application whitelisting to prevent untrusted image processing.
Mitigation:
- Disable automatic image processing of J2K files if not required.
- Use a sandboxed environment for image conversion tasks.
- Apply memory protection mechanisms (ASLR, DEP).
Indicators of Compromise (IOCs)
- File Hashes (SHA256): (None available – no public PoC)
- File Names:
*.j2k,*.jp2,*.jpc(malicious variants) - Process Behavior: Crash in
FreeImage.dllorlibfreeimage.sowith access violation atopj_j2k_tcp_destroy - Network: None (local file-based attack)
Detection Engineering
YARA Rule
rule CVE_2024_28576_FreeImage_J2K_Overflow {
meta:
description = "Detects malicious J2K files targeting CVE-2024-28576"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-28576"
strings:
$j2k_magic = { 00 00 00 0C 51 51 51 51 } // Example magic bytes
$siz_marker = { FF 51 } // SIZ marker
condition:
$j2k_magic at 0 and $siz_marker
}
Sigma Rule
title: FreeImage J2K Buffer Overflow Detection
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects crashes in applications using FreeImage when processing J2K files
author: Valters IT
logsource:
category: application
product: windows
service: application
detection:
selection:
EventID: 1000
ApplicationName: '*FreeImage*'
FaultingModule: '*FreeImage.dll*'
condition: selection
falsepositives:
- Legitimate crashes due to corrupted files
level: medium
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-28576 FreeImage J2K File Download"; flow:to_client,established; filemagic:"J2K"; content:"|00 00 00 0C|"; distance:0; within:4; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
- Patch Status: No official patch is available. Monitor the FreeImage project for updates.
- Workaround: Disable J2K support in applications using FreeImage, or use an alternative library (e.g., OpenJPEG).
- User Awareness: Educate users not to open J2K files from untrusted sources.
- Network Controls: Block J2K file downloads at the perimeter if not business-required.
- Application Hardening: Run image processing in a sandboxed environment with limited privileges.
Valters IT
Securing Digital Frontiers