Menu

#199 Buffer Overflow vulnerability in giflib

v1.0_(example)
closed
nobody
None
1
2026-06-11
2026-04-21
No

There is a CVE https://cve-searcher.ipws.mathworks.com/?list=CVE-2026-26740 existing in v6.1.3.

More details and PoC can be found here - https://github.com/zakkanijia/POC/blob/main/giflib/giftool/giflib_giftool_gce_len_heap_oobwrite_disclosure.md

It is a heap-based out-of-bounds write in EGifGCBToExtension() within egif_lib.c. A crafted GIF with a truncated Graphics Control Extension (GCE) block (e.g., length 1 instead of the expected 4) causes the code to write 4 bytes into a 1-byte heap allocation.

Discussion

  • Michal Hlavinka

    Michal Hlavinka - 2026-04-21

    I can confirm that with provided poc.gif the problem can be reproduced by running giftool with valgrind:

    ==56559== Invalid write of size 1
    ==56559==    at 0x488933B: EGifGCBToExtension (in /usr/lib64/libgif.so.7.1.0)
    ==56559==    by 0x488D93A: EGifGCBToSavedExtension (in /usr/lib64/libgif.so.7.1.0)
    ==56559==    by 0x4000F03: ??? (in /usr/bin/giftool)
    ==56559==    by 0x48985B4: (below main) (libc_start_call_main.h:58)
    ...
    

    I've added a fix to my build - same check as is in the reverse function DGifExtensionToGCB in dgif_lib.c to return GIF_ERROR if ep->ByteCount != 4. With this change, there are no valgrind errors.

     
  • Eric S. Raymond

    Eric S. Raymond - 2026-06-11
    • status: open --> closed
     
  • Eric S. Raymond

    Eric S. Raymond - 2026-06-11

    Fix applied and pushed

     

Log in to post a comment.