elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
14 Febrero 2012, 06:57  


+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Bugs y Exploits (Moderador: berz3k)
| | |-+  CVE-2009-0385: FFmpeg Type Conversion Vulnerability
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: CVE-2009-0385: FFmpeg Type Conversion Vulnerability  (Leído 2,186 veces)
AlbertoBSD
Estudiante y
Colaborador
***
Desconectado Desconectado

Mensajes: 1.955


Anonymous & Paranoid


Ver Perfil WWW
CVE-2009-0385: FFmpeg Type Conversion Vulnerability
« en: 19 Marzo 2009, 00:49 »

Original Advisory
:http://www.trapkit.de/advisories/TKADV2009-004.txt


Citar
==================
Technical Details:
==================

Source code file: libavformat/4xm.c

[..]
 93 static int fourxm_read_header(AVFormatContext *s,
 94                               AVFormatParameters *ap)
 95 {
 ..
103 [8]  int current_track = -1;
 ..
106 [9]  fourxm->track_count = 0;
107 [10] fourxm->tracks = NULL;
 ..
160      } else if (fourcc_tag == strk_TAG) {
161          /* check that there is enough data */
162          if (size != strk_SIZE) {
163              av_free(header);
164              return AVERROR_INVALIDDATA;
165          }
166 [1]      current_track = AV_RL32(&header[i + 8]);
167 [2]      if (current_track + 1 > fourxm->track_count) {
168             fourxm->track_count = current_track + 1;
169             if((unsigned)fourxm->track_count >= UINT_MAX /
                           sizeof(AudioTrack))
170               return -1;
171 [3]         fourxm->tracks = av_realloc(fourxm->tracks,
172                 fourxm->track_count * sizeof(AudioTrack));
173             if (!fourxm->tracks) {
174               av_free(header);
175               return AVERROR(ENOMEM);
176             }
177         }
178 [4] fourxm->tracks[current_track].adpcm = AV_RL32(&header[i + 12]);
179 [5] fourxm->tracks[current_track].channels = AV_RL32(&header[i + 36]);
180 [6] fourxm->tracks[current_track].sample_rate = AV_RL32(&header[i+40]);
181 [7] fourxm->tracks[current_track].bits = AV_RL32(&header[i + 44]);
[..]

[1] The signed int variable "current_track" (see [8]) is filled with user
    supplied data from the media file
[2] This statement checks if the user controlled value of "current_track"
    is greater than "fourxm->track_count". The variable "fourxm-
    >track_count" is initialized with 0 (see [9]). By supplying a value >=
    0x80000000 for "current_track" it is possible to cause a change in sign
    that results in "current_track" being negative. If "current_track" is
    negative, the if statement will always return false and the buffer
    allocation in [3] will never be reached.
[4] As "fourxm->tracks" is initialized with NULL (see [10]) and line 171 is
    never reached this leads to an exploitable NULL pointer dereference. It
    is possible to write 4 bytes of user controlled data to the memory
    location "NULL + current_track". As the value of "current_track" is
    also controlled by the user it is possible to write 4 bytes of
    arbitrary data at a wide range of memory addresses.
[5] See [4]
[6] See [4]
[7] See [4]

A malicious party may exploit this issue to execute arbitrary code by
overwriting a sensitive memory location (such as a GOT/IAT entry, a return
address, buffer length or boolean variable).



Afecta a algunos reproductores como xine Mplayer entre otros, Según yo solo podremos crear un DoS pero seria de ver.

Ya hay parche pero dudo que los linuxeros (Comunes) estén parcheando cada una de las vulnerabilidades que salen...

Bueno, he tratado de crear un PoC para la vulnerabilidad sin embargo no lo he logrado, tengo un archivo 4xm que según yo debería de funcionar o por lo menos eso creo.

Al parecer no he comprendido muy bien el formato de los los archivos 4xm.

El formato 4x Movie esta descrito aqui:
:http://multimedia.cx/4xm-format.txt

Citar
4xm files appear to have the following general structure:

  RIFF header
    LIST-HEAD chunk
      LIST-HNFO chunk
    LIST-TRK_ chunk
      LIST-VTRK chunk
      LIST-STRK chunk
      [..more tracks..]
    LIST-MOVI chunk
      LIST-FRAM chunk
      LIST-FRAM chunk
      LIST-FRAM chunk
      [..more frame tracks..]

tengo duda de LIST-HNFO ya que de este no esta entre las decalaraciones de los Tag de la libreria:

libavformat/4xm.c

Código
#define  RIFF_TAG MKTAG('R', 'I', 'F', 'F')
#define _4XMV_TAG MKTAG('4', 'X', 'M', 'V')
#define  LIST_TAG MKTAG('L', 'I', 'S', 'T')
#define  HEAD_TAG MKTAG('H', 'E', 'A', 'D')
#define  TRK__TAG MKTAG('T', 'R', 'K', '_')
#define  MOVI_TAG MKTAG('M', 'O', 'V', 'I')
#define  VTRK_TAG MKTAG('V', 'T', 'R', 'K')
#define  STRK_TAG MKTAG('S', 'T', 'R', 'K')
#define  std__TAG MKTAG('s', 't', 'd', '_')
#define  name_TAG MKTAG('n', 'a', 'm', 'e')
#define  vtrk_TAG MKTAG('v', 't', 'r', 'k')
#define  strk_TAG MKTAG('s', 't', 'r', 'k')
#define  ifrm_TAG MKTAG('i', 'f', 'r', 'm')
#define  pfrm_TAG MKTAG('p', 'f', 'r', 'm')
#define  cfrm_TAG MKTAG('c', 'f', 'r', 'm')
#define  ifr2_TAG MKTAG('i', 'f', 'r', '2')
#define  pfr2_TAG MKTAG('p', 'f', 'r', '2')
#define  cfr2_TAG MKTAG('c', 'f', 'r', '2')
#define  snd__TAG MKTAG('s', 'n', 'd', '_')
 

Por lo cual dudo de su existencia, el PoC que hice esta usando dicha LIST pero al parecer el programa dentro del codigo no lo toma en cuenta, voy a seguir probando para generar un PoC que funcione:

Aqui esta el que cree
4xm_evil.avi

El código en C con el cual lo cree esta bien raro, por lo cual mejor prefiero ordenarlo un poco mas y liberarlo.

Espero y les interese, Saludos.
« Última modificación: 24 Marzo 2009, 15:57 por Anon » En línea

Bien Super Divertido
@wifigdlmx
AlbertoBSD
Estudiante y
Colaborador
***
Desconectado Desconectado

Mensajes: 1.955


Anonymous & Paranoid


Ver Perfil WWW
Re: CVE-2009-0385: FFmpeg Type Conversion Vulnerability
« Respuesta #1 en: 24 Marzo 2009, 16:52 »

Bueno he segido con el tema un poco, la verdad que sigo sin entender el formato de los archivos 4xm lo que es la vulnerabilidad esta mas que entendida lo que si es nuevo para mi es que la vulnerabilidad es 100% controlable y yo que pensaba que solo era un bonito DoS a la aplicación reproductora.



[ES] CVE-2009-0385 mas detalles
Me he comunicado con Tobias Klein para pedir un mas detalles sobre la prueba de concepto para el bug descrito en el CVE-2009-0385, su comentario fue el siguiente

The vulnerability is 100% exploitable to execute arbitrary code. See http://tk-blog.blogspot.com/2009/01/exploitable-userland-null-pointer.html.

Tobi

Segun describe en su blog, logro confirmar la vulnerabilidad y controlar el EIP tanto en windows y opensuse.

El tiene un PoC, no le comente nada sobre el, mas que nada le pregunte sobre la estructura 4xm.

Tambien me he comunicado con Mike Melanson que al parecer hace tiempo que no hablar el tema del formato de los archivos 4xm su cometario fue el siguiente


What exactly are you trying to accomplish? I don't have all the details of the 4xm format fresh in my mind. All of my knowledge is written down in either that document, or the FFmpeg demuxer (I also wrote the xine 4xm demuxer).

Buscando sobre ello encontré con la pagina de la discusión de la vulnerabilidad

http://bugs.xine-project.org/show_bug.cgi?id=205

Ahi comenta que xine-lib tiene un problema similar al descrito por Tobias que lo discute en su blog

http://tk-blog.blogspot.com/2009/02/tkadv2009-004-vs-xine-lib.html

Bueno con esto ya tengo en mente que la vulnerabilidad del CVE-2009-0385 es explotable, espero terminar de entender el formato 4xm para poder terminar el PoC que la verdad es muy simple


Ahi mi código para generar el archivo 4xm, make4xm.c esta un poco larga, sin embargo la cosa es simple creamos los LIST y los CHUNK y después los concatenamos, una vez que tenemos los buffers listos simplemente lo escribimos en el archivo.

Segun los últimos correos que he recibido el archivo PoC no necesita del LIST-MOVI y quedaría asi:

Citar
RIFF header
  LIST HEAD
    LIST HNFO
      Chunk name
      Chunk info
      Chunk std_
  LIST-TRK_
    LIST-STRK //More times
      Chunk strk

Pero igual no me hagan mucho caso que asi lo tengo y el ffmpeg me saca que tengo errores en las cabeceras:

Código
Anon@localhost % ~/local/bin/ffmpeg -i 4xm_evil.avi -nv nuevo.avi
FFmpeg version SVN-r14424, Copyright (c) 2000-2008 Fabrice Bellard, et al.
 configuration: --enable-debug=2 --prefix=/usr/home/Anon/local --enable-x11grab --enable-gpl
 libavutil version: 49.7.0
 libavcodec version: 51.61.0
 libavformat version: 52.18.0
 libavdevice version: 52.0.0
 built on Mar 23 2009 00:36:11, gcc: 4.2.1 20070719  [FreeBSD]
4xm_evil.avi: Error while parsing header
 

Citar
4xm_evil.avi: Error while parsing header

Espero a alguien le interese

Saludos
En línea

Bien Super Divertido
@wifigdlmx
berz3k
Moderador
***
Desconectado Desconectado

Mensajes: 1.127



Ver Perfil
Re: CVE-2009-0385: FFmpeg Type Conversion Vulnerability
« Respuesta #2 en: 24 Marzo 2009, 19:44 »

Uff cuanto spam Anon... bastante pesado de leer XD

-berz3k.
En línea
AlbertoBSD
Estudiante y
Colaborador
***
Desconectado Desconectado

Mensajes: 1.955


Anonymous & Paranoid


Ver Perfil WWW
Re: CVE-2009-0385: FFmpeg Type Conversion Vulnerability
« Respuesta #3 en: 14 Abril 2009, 16:11 »

Uff cuanto spam Anon... bastante pesado de leer XD

-berz3k.


Lo he resumido en un PDF

CVE-2009-0385.pdf

Espero ahora si lo leas

Saludos



En línea

Bien Super Divertido
@wifigdlmx
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines