what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

sdl-overflow.txt

sdl-overflow.txt
Posted Jan 24, 2008
Authored by Gynvael Coldwind

SDL_Image versions 1.2.6 and below suffer from a GIF handling buffer overflow vulnerability.

tags | advisory, overflow
SHA-256 | 013e44ffbd053ccc714332adb0917f693c76ce4e1a1854c18fcc279af2d8b8e3

sdl-overflow.txt

Change Mirror Download
* Name      : SDL_Image 1.2.6 and prior GIF handling buffer overflow
* Type : (Remote) DoS / Code Execution (?)
* Impact : Low / Medium (?)
* Credits : Gynvael Coldwind / Team Vexillium
* Discovered: 2007-12-17
* Published : 2008-01-23


* Brief

SDL_Image is an open source library providing image file handling
functionality.
GIF format handling routines suffers from lack of proper buffer
size validating, which makes it vulnerable to a buffer overflow
attack. An attacker could DoS an application using SDL_Image,
or execute arbitrary code (this has not been confirmed, and
is believed to be nontrivial).
Since this is a library, in some cases the attack could be remote.


* Verbose

The problem takes place when a GIF file has invalid LWZ Minimum Code
Size in the Table Based Image Data header. The standard allows the
codes to have maximum size of 12 bits, but this is not checked in
SDL_image.
An attacker could use this for a local or remote buffer overflow
attack that may have denial of service or arbitrary code execution
effect.

SDL_image file IMG_gif.c, function ReadImage:

...
unsigned char c;
...
if (LWZReadByte(src, TRUE, c) < 0) {
RWSetMsg("error reading image");
return NULL;
}
/*
** If this is an "uninteresting picture" ignore it.
*/
if (ignore) {
while (LWZReadByte(src, FALSE, c) >= 0)
;
return NULL;
}
...

Please note that 'c' value is passed to LZWReadByte without checking
if it is OK with the standard.

Then in function LWZReadByte:

LWZReadByte(SDL_RWops *src, int flag, int input_code_size)
...
static int table[2][(1 << MAX_LWZ_BITS)];
...
set_code_size = input_code_size;
...
clear_code = 1 << set_code_size;
...
for (i = 0; i < clear_code; ++i) {
table[0][i] = 0;
table[1][i] = i;
}
...

This is the first place that is affected by this issue.


* Proof of concept

DoS proof of concept GIF file:
http://vexillium.org/dl.php?sdlgifdos


* Versions affected and vendor status

Version 1.2.6 and prior are affected.
Vendor was informed and has fixed this issue in 1.2.7.


* Disclaimer

This document and all the information it contains is provided "as is",
without any warranty. The author is not responsible for the
misuse of the information provided in this advisory. The advisory is
provided for educational purposes only.

Permission is hereby granted to redistribute this advisory, providing
that no changes are made and that the copyright notices and
disclaimers remain intact.

--
gynvael.coldwind//vx
http://vexillium.org
http://hispasec.com
Login or Register to add favorites

File Archive:

September 2023

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    2 Files
  • 2
    Sep 2nd
    21 Files
  • 3
    Sep 3rd
    0 Files
  • 4
    Sep 4th
    17 Files
  • 5
    Sep 5th
    34 Files
  • 6
    Sep 6th
    29 Files
  • 7
    Sep 7th
    11 Files
  • 8
    Sep 8th
    25 Files
  • 9
    Sep 9th
    0 Files
  • 10
    Sep 10th
    0 Files
  • 11
    Sep 11th
    26 Files
  • 12
    Sep 12th
    23 Files
  • 13
    Sep 13th
    17 Files
  • 14
    Sep 14th
    22 Files
  • 15
    Sep 15th
    16 Files
  • 16
    Sep 16th
    0 Files
  • 17
    Sep 17th
    0 Files
  • 18
    Sep 18th
    19 Files
  • 19
    Sep 19th
    60 Files
  • 20
    Sep 20th
    23 Files
  • 21
    Sep 21st
    15 Files
  • 22
    Sep 22nd
    8 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close