Executive brief
libsixel is a library used to encode and decode images in the SIXEL format, often used for displaying graphics in terminal emulators. A flaw in how the library handles memory during image resizing can cause it to accidentally delete data that still belongs to the calling application. This can lead to application crashes or allow an attacker to potentially take control of the affected program.
Technical details
A use-after-free vulnerability exists in libsixel versions 1.8.7 and prior within the sixel_encoder_encode_bytes() function. The root cause is in sixel_frame_init(), which stores a pointer to the caller-provided pixel buffer directly in frame->pixels without a defensive copy. If a resize operation is triggered (e.g., via SIXEL_OPTFLAG_WIDTH), sixel_frame_convert_to_rgb888() unconditionally frees this caller-owned buffer and replaces it with an internal allocation. This leaves the caller with a dangling pointer; subsequent access to the original buffer results in a use-after-free. An attacker providing specially crafted frames can trigger this reliably, leading to a crash or potential arbitrary code execution. The issue is fixed in version 1.8.7-r1.
Affected products
- saitoha libsixel <= 1.8.7
Timeline
- 2026-04-14: disclosed
- 2026-04-14: advisory
- 2026-04-14: patched: Fixed in version 1.8.7-r1